Add TypeMap with test.
This commit is contained in:
@@ -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
30
tests/TypeMapTest.hx
Normal 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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user