-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
398 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version=2.1.0 | ||
src=src | ||
bin=build | ||
report=report | ||
hxml=unit-test.hxml | ||
classPaths=../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package ; | ||
|
||
import massive.munit.util.Timer; | ||
import massive.munit.Assert; | ||
import massive.munit.async.AsyncFactory; | ||
import org.msgpack.MsgPack; | ||
|
||
|
||
class ArrayTest | ||
{ | ||
|
||
|
||
public function new() | ||
{ | ||
|
||
} | ||
|
||
@BeforeClass | ||
public function beforeClass():Void | ||
{ | ||
} | ||
|
||
@AfterClass | ||
public function afterClass():Void | ||
{ | ||
} | ||
|
||
@Before | ||
public function setup():Void | ||
{ | ||
} | ||
|
||
@After | ||
public function tearDown():Void | ||
{ | ||
} | ||
|
||
@Test | ||
public function testExample():Void | ||
{ | ||
var a = [ 3, 2, 1, 7, 8, 9 ]; | ||
var e = MsgPack.encode(a); | ||
var d = MsgPack.decode(e); | ||
|
||
Assert.isType(d, Array); | ||
Assert.isTrue(Lambda.fold(d, function(v, b) { | ||
return b && a[Lambda.indexOf(d, v)] == v; | ||
}, true)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package ; | ||
|
||
import massive.munit.util.Timer; | ||
import massive.munit.Assert; | ||
import massive.munit.async.AsyncFactory; | ||
import org.msgpack.MsgPack; | ||
|
||
|
||
class BasicTest | ||
{ | ||
|
||
|
||
public function new() | ||
{ | ||
|
||
} | ||
|
||
@BeforeClass | ||
public function beforeClass():Void | ||
{ | ||
} | ||
|
||
@AfterClass | ||
public function afterClass():Void | ||
{ | ||
} | ||
|
||
@Before | ||
public function setup():Void | ||
{ | ||
} | ||
|
||
@After | ||
public function tearDown():Void | ||
{ | ||
} | ||
|
||
@Test | ||
public function testExample():Void | ||
{ | ||
Assert.isTrue(doTest(null, "TNull" )); | ||
Assert.isTrue(doTest(true, "TBool" )); | ||
Assert.isTrue(doTest(1000, "TInt" )); | ||
Assert.isTrue(doTest(1.01, "TFloat")); | ||
Assert.isTrue(doTest("ab", "String")); | ||
} | ||
|
||
function doTest<T>(a:T, n:String) | ||
{ | ||
var e = MsgPack.encode(a); | ||
var d = MsgPack.decode(e); | ||
|
||
switch (Type.typeof(a)) | ||
{ | ||
case TNull : return n == "TNull"; | ||
case TBool : return n == "TBool"; | ||
case TInt : return n == "TInt"; | ||
case TFloat : return n == "TFloat"; | ||
case TClass(c): | ||
switch (Type.getClassName(c)) | ||
{ | ||
case "String": | ||
return n == "String"; | ||
} | ||
|
||
default: | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package ; | ||
|
||
import haxe.ds.IntMap; | ||
import haxe.ds.StringMap; | ||
import massive.munit.util.Timer; | ||
import massive.munit.Assert; | ||
import massive.munit.async.AsyncFactory; | ||
import org.msgpack.Decoder.DecodeOption.AsMap; | ||
import org.msgpack.MsgPack; | ||
|
||
|
||
class MapTest | ||
{ | ||
|
||
|
||
public function new() | ||
{ | ||
|
||
} | ||
|
||
@BeforeClass | ||
public function beforeClass():Void | ||
{ | ||
} | ||
|
||
@AfterClass | ||
public function afterClass():Void | ||
{ | ||
} | ||
|
||
@Before | ||
public function setup():Void | ||
{ | ||
} | ||
|
||
@After | ||
public function tearDown():Void | ||
{ | ||
} | ||
|
||
@Test | ||
public function testExample():Void | ||
{ | ||
var im = new IntMap<String>(); | ||
im.set(1, "one"); | ||
im.set(3, "Three"); | ||
im.set(9, "Nine"); | ||
|
||
var e = MsgPack.encode(im); | ||
var d = MsgPack.decode(e, AsMap); | ||
|
||
Assert.isType(d, IntMap); | ||
|
||
var ni = cast(d, IntMap<Dynamic>); | ||
for (k in im.keys()) | ||
Assert.isTrue(ni.exists(k) && ni.get(k) == im.get(k)); | ||
|
||
|
||
var sm = new StringMap<Int>(); | ||
sm.set("one", 1); | ||
sm.set("Three", 3); | ||
sm.set("Nine", 9); | ||
|
||
e = MsgPack.encode(sm); | ||
d = MsgPack.decode(e, AsMap); | ||
|
||
Assert.isType(d, StringMap); | ||
|
||
var ns = cast(d, StringMap<Dynamic>); | ||
for (k in sm.keys()) | ||
Assert.isTrue(ns.exists(k) && ns.get(k) == sm.get(k)); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package ; | ||
|
||
import massive.munit.util.Timer; | ||
import massive.munit.Assert; | ||
import massive.munit.async.AsyncFactory; | ||
import org.msgpack.Decoder.DecodeOption.AsObject; | ||
import org.msgpack.MsgPack; | ||
|
||
|
||
class ObjectTest | ||
{ | ||
|
||
|
||
public function new() | ||
{ | ||
|
||
} | ||
|
||
@BeforeClass | ||
public function beforeClass():Void | ||
{ | ||
} | ||
|
||
@AfterClass | ||
public function afterClass():Void | ||
{ | ||
} | ||
|
||
@Before | ||
public function setup():Void | ||
{ | ||
} | ||
|
||
@After | ||
public function tearDown():Void | ||
{ | ||
} | ||
|
||
@Test | ||
public function testExample():Void | ||
{ | ||
var e = MsgPack.encode({ a: 10, b: "abc"}); | ||
var d = MsgPack.decode(e, AsObject); | ||
|
||
Assert.isTrue(Reflect.hasField(d, "a") | ||
&& Reflect.hasField(d, "b") | ||
&& Reflect.field(d, "a") == 10 | ||
&& Reflect.field(d, "b") == "abc"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import massive.munit.client.PrintClient; | ||
import massive.munit.client.RichPrintClient; | ||
import massive.munit.client.HTTPClient; | ||
import massive.munit.client.JUnitReportClient; | ||
import massive.munit.client.SummaryReportClient; | ||
import massive.munit.TestRunner; | ||
|
||
#if js | ||
import js.Lib; | ||
#end | ||
|
||
/** | ||
* Auto generated Test Application. | ||
* Refer to munit command line tool for more information (haxelib run munit) | ||
*/ | ||
class TestMain | ||
{ | ||
static function main(){ new TestMain(); } | ||
|
||
public function new() | ||
{ | ||
var suites = new Array<Class<massive.munit.TestSuite>>(); | ||
suites.push(TestSuite); | ||
|
||
#if MCOVER | ||
var client = new mcover.coverage.munit.client.MCoverPrintClient(); | ||
var httpClient = new HTTPClient(new mcover.coverage.munit.client.MCoverSummaryReportClient()); | ||
#else | ||
var client = new RichPrintClient(); | ||
var httpClient = new HTTPClient(new SummaryReportClient()); | ||
#end | ||
|
||
var runner:TestRunner = new TestRunner(client); | ||
runner.addResultClient(httpClient); | ||
//runner.addResultClient(new HTTPClient(new JUnitReportClient())); | ||
|
||
runner.completionHandler = completionHandler; | ||
runner.run(suites); | ||
} | ||
|
||
/* | ||
updates the background color and closes the current browser | ||
for flash and html targets (useful for continous integration servers) | ||
*/ | ||
function completionHandler(successful:Bool):Void | ||
{ | ||
try | ||
{ | ||
#if flash | ||
flash.external.ExternalInterface.call("testResult", successful); | ||
#elseif js | ||
js.Lib.eval("testResult(" + successful + ");"); | ||
#elseif sys | ||
Sys.exit(0); | ||
#end | ||
} | ||
// if run from outside browser can get error which we can ignore | ||
catch (e:Dynamic) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import massive.munit.TestSuite; | ||
|
||
import MapTest; | ||
import BasicTest; | ||
import ArrayTest; | ||
import ObjectTest; | ||
|
||
/** | ||
* Auto generated Test Suite for MassiveUnit. | ||
* Refer to munit command line tool for more information (haxelib run munit) | ||
*/ | ||
|
||
class TestSuite extends massive.munit.TestSuite | ||
{ | ||
|
||
public function new() | ||
{ | ||
super(); | ||
|
||
add(MapTest); | ||
add(BasicTest); | ||
add(ArrayTest); | ||
add(ObjectTest); | ||
} | ||
} |
Oops, something went wrong.