Skip to content

Commit

Permalink
Added sample unit-tests
Browse files Browse the repository at this point in the history
Updated to latest jar and swcs
  • Loading branch information
humboldtjs committed Apr 24, 2014
1 parent 12e855d commit 9b29719
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 5 deletions.
1 change: 1 addition & 0 deletions .actionScriptProperties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<sourceAttachmentPath/>
</compiler>
<applications>
<application path="HumboldtJSTest.as"/>
<application path="HumboldtJSEmpty.as"/>
</applications>
<modules/>
Expand Down
29 changes: 24 additions & 5 deletions build/build.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="compile debug" name="Compile HumboldtJSEmpty project">
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
<!--ANT 1.7 is required -->
<target name="compile release">
<project default="Compile debug" name="Compile HumboldtJSEmpty project">

<target name="Compile release">
<mkdir dir="../bin-release"/>
<java jar="humboldtjs.jar" fork="true">
<arg value="-basedir"/>
Expand All @@ -17,7 +16,8 @@
<arg value="HumboldtJSEmpty.as"/>
</java>
</target>
<target name="compile debug">

<target name="Compile debug">
<mkdir dir="../bin-debug"/>
<java jar="humboldtjs.jar" fork="true">
<arg value="-basedir"/>
Expand All @@ -32,4 +32,23 @@
<arg value="HumboldtJSEmpty.as"/>
</java>
</target>

<target name="Compile tests">
<mkdir dir="../bin-release"/>
<java jar="humboldtjs.jar" fork="true">
<arg value="-basedir"/>
<arg value="../src"/>
<arg value="-debug"/>
<arg value="-L"/>
<arg value="../lib/HumboldtJSLibrary.swc"/>
<arg value="-L"/>
<arg value="../lib/PureMVC.swc"/>
<arg value="-L"/>
<arg value="../lib/HJSUnit.swc"/>
<arg value="-o"/>
<arg value="../bin-debug"/>
<arg value="HumboldtJSTest.as"/>
</java>
</target>

</project>
Binary file modified build/humboldtjs.jar
Binary file not shown.
Binary file added lib/HJSUnit.swc
Binary file not shown.
Binary file modified lib/HumboldtJSDOM.swc
Binary file not shown.
Binary file modified lib/HumboldtJSLibrary.swc
Binary file not shown.
Binary file modified lib/PureMVC.swc
Binary file not shown.
34 changes: 34 additions & 0 deletions src/HumboldtJSTest.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package
{
import com.humboldtjs.events.HJSEvent;
import com.humboldtjs.hjsunit.UITestRunner;
import com.humboldtjs.system.Application;

import tests.SampleTestSuite;

[Application]
public class HumboldtJSTest extends Application
{
public function HumboldtJSTest()
{
super();
}

override protected function initialize():void
{
super.initialize();

var theTestRunner:UITestRunner = new UITestRunner();

addChild(theTestRunner.getUI());
theTestRunner.addEventListener(HJSEvent.COMPLETE, onComplete);
theTestRunner.run(new SampleTestSuite());
}

protected function onComplete(aEvent:HJSEvent):void
{
aEvent.getCurrentTarget().removeEventListener(HJSEvent.COMPLETE, onComplete);
// done
}
}
}
52 changes: 52 additions & 0 deletions src/tests/SampleTestCase.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package tests
{
import com.humboldtjs.hjsunit.Test;
import com.humboldtjs.hjsunit.TestCase;

import dom.window;

public class SampleTestCase extends TestCase
{
public function SampleTestCase()
{
super();

setName("Sample tests");
addTestMethod(new Test("Test integer math", testIntegerMath, true));
addTestMethod(new Test("Test floating point math", testFloatMath));
}

override protected function setup():void
{
// setup anything needed to run the test
// if this should happen asynchronous call setSetupAsync(true)
// in the constructor, and call _assert.done() when the setup
// is complete

_assert.message("Setting up tests");
}

public function testIntegerMath():void
{
var i:int = 5;
_assert.equals(5, i);
i += 4;
_assert.equals(9, i);

window.setTimeout(testIntegerMathComplete, 1000);
}

public function testIntegerMathComplete():void
{
_assert.done();
}

public function testFloatMath():void
{
var i:Number = 5;
_assert.equals(5, i);
i += 4.5;
_assert.equals(9.5, i);
}
}
}
16 changes: 16 additions & 0 deletions src/tests/SampleTestSuite.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tests
{
import com.humboldtjs.hjsunit.TestSuite;


public class SampleTestSuite extends TestSuite
{
public function SampleTestSuite()
{
super();

setName("A sample test-suite");
addTest(new SampleTestCase());
}
}
}

0 comments on commit 9b29719

Please sign in to comment.