New facade. Rudimentary tests.
This commit is contained in:
46
tests/Types.hx
Normal file
46
tests/Types.hx
Normal file
@@ -0,0 +1,46 @@
|
||||
package ;
|
||||
|
||||
import haxe.macro.Expr;
|
||||
import haxe.macro.Context;
|
||||
using tink.Macro;
|
||||
|
||||
class Types extends Base {
|
||||
function type(c:ComplexType)
|
||||
return c.toType().sure();
|
||||
|
||||
function resolve(type:String)
|
||||
return Context.getType(type);
|
||||
|
||||
inline function assertSuccess<S, F>(o:Outcome<S, F>)
|
||||
assertTrue(o.isSuccess());
|
||||
|
||||
inline function assertFailure<S, F>(o:Outcome<S, F>)
|
||||
assertFalse(o.isSuccess());
|
||||
|
||||
function testIs() {
|
||||
assertSuccess(resolve('Int').isSubTypeOf(resolve('Float')));
|
||||
assertFailure(resolve('Float').isSubTypeOf(resolve('Int')));
|
||||
}
|
||||
|
||||
function testFields() {
|
||||
var iterator = type(macro : haxe.ds.StringMap<Arrayish>).getFields(true).sure().filter(function (c) return c.name == 'iterator')[0];
|
||||
var expected = type(macro : Void -> Iterator<Arrayish>);
|
||||
|
||||
assertSuccess(iterator.type.isSubTypeOf(expected));
|
||||
assertSuccess(expected.isSubTypeOf(iterator.type));
|
||||
}
|
||||
|
||||
function testConvert() {
|
||||
assertSuccess((macro : Int).toType());
|
||||
assertFailure((macro : Tni).toType());
|
||||
function blank()
|
||||
return type(Macro.pos().makeBlankType());
|
||||
|
||||
var bool = type(macro : Bool);
|
||||
assertTrue(blank().isSubTypeOf(bool).isSuccess());
|
||||
assertTrue(bool.isSubTypeOf(blank()).isSuccess());
|
||||
|
||||
Macro.pos().makeBlankType().toString();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user