Add TypeMap with test.

This commit is contained in:
Juraj Kirchheim
2016-04-19 12:52:45 +02:00
parent 0284615f99
commit c3cecad472
4 changed files with 68 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ class Run {
new Exprs(),
new Types(),
new Positions(),
new TypeMapTest(),
];
#end
macro static function test() {

30
tests/TypeMapTest.hx Normal file
View File

@@ -0,0 +1,30 @@
package;
import haxe.unit.TestCase;
import tink.macro.TypeMap;
using haxe.macro.Context;
class TypeMapTest extends TestCase {
function testMap() {
var t = new TypeMap();
var t1 = (macro [{ foo: [{ bar: '5' }]}]).typeof();
var t2 = (macro [{ foo: [{ bar: 5 }]}]).typeof();
t.set(t1, 0);
assertEquals(Lambda.count(t), 1);
t.set(t2, 1);
assertEquals(Lambda.count(t), 2);
t.set(t1, 2);
assertEquals(Lambda.count(t), 2);
t.set(t2, 3);
assertEquals(Lambda.count(t), 2);
assertEquals(t.get(t1), 2);
assertEquals(t.get(t2), 3);
assertTrue(true);
}
}