New facade. Rudimentary tests.

This commit is contained in:
back2dos
2013-09-25 14:32:19 +02:00
parent 4054939a7c
commit cd15e4b00c
15 changed files with 330 additions and 349 deletions

View File

@@ -13,8 +13,8 @@ abstract PhysicalType<T>(Either<Class<T>, Enum<T>>) {
public function toString()
return
switch this {
case Left(c): return Type.getClassName(c);
case Right(e): return Type.getEnumName(e);
case Left(c): Type.getClassName(c);
case Right(e): Type.getEnumName(e);
}
public function check(v:T)
@@ -37,10 +37,10 @@ class Base extends TestCase {
currentTest.posInfos = c;
throw currentTest;
}
function throws<A>(f:Void->Void, t:PhysicalType<A>, ?check:A->Bool, ?pos:PosInfos):Void {
function throws<A>(f:Void->Void, ?t:PhysicalType<A>, ?check:A->Bool, ?pos:PosInfos):Void {
try f()
catch (e:Dynamic) {
if (!t.check(e)) fail('Exception $e not of type $t', pos);
if (t != null && !t.check(e)) fail('Exception $e not of type $t', pos);
if (check != null && !check(e)) fail('Exception $e does not satisfy condition', pos);
assertTrue(true);
return;