exprTo tests
This commit is contained in:
@@ -15,7 +15,9 @@ class ExprBindTest extends BuddySuite {
|
||||
|
||||
var callNum:Int;
|
||||
var from:String;
|
||||
var target:{a:String};
|
||||
before({
|
||||
target = {a:null};
|
||||
from = null;
|
||||
callNum = 0;
|
||||
});
|
||||
@@ -27,6 +29,7 @@ class ExprBindTest extends BuddySuite {
|
||||
b.str = "b1";
|
||||
inline function val() return b.str + "ab".charAt(a.str.length - 2) + Std.string(1);
|
||||
|
||||
BindExt.exprTo(b.str + "ab".charAt(a.str.length - 2) + Std.string(1), target.a);
|
||||
BindExt.expr(b.str + "ab".charAt(a.str.length - 2) + Std.string(1), function (f, to:String) {
|
||||
f.should.be(from);
|
||||
from = to;
|
||||
@@ -34,14 +37,17 @@ class ExprBindTest extends BuddySuite {
|
||||
callNum ++;
|
||||
});
|
||||
|
||||
target.a.should.be(val());
|
||||
callNum.should.be(1);
|
||||
|
||||
a.str = "a2";
|
||||
|
||||
target.a.should.be(val());
|
||||
callNum.should.be(2);
|
||||
|
||||
b.str = "b2";
|
||||
|
||||
target.a.should.be(val());
|
||||
callNum.should.be(3);
|
||||
});
|
||||
|
||||
@@ -52,9 +58,11 @@ class ExprBindTest extends BuddySuite {
|
||||
a.str = "a1";
|
||||
b.str = "";
|
||||
c.str = "1";
|
||||
var target:{a:Null<Int>} = {a:null};
|
||||
inline function val() return if (a.str.charAt(b.str.length) == Std.string(c.str)) 1 else 0;
|
||||
var from:Null<Int> = null;
|
||||
|
||||
BindExt.exprTo(if (a.str.charAt(b.str.length) == Std.string(c.str)) 1 else 0, target.a);
|
||||
BindExt.expr(if (a.str.charAt(b.str.length) == Std.string(c.str)) 1 else 0, function (f:Null<Int>, to:Null<Int>) {
|
||||
(f == from).should.be(true); // f.should.be(from); cast f to Int
|
||||
from = to;
|
||||
@@ -62,22 +70,27 @@ class ExprBindTest extends BuddySuite {
|
||||
callNum ++;
|
||||
});
|
||||
|
||||
target.a.should.be(val());
|
||||
callNum.should.be(1);
|
||||
|
||||
b.str = "1";
|
||||
|
||||
target.a.should.be(val());
|
||||
callNum.should.be(2);
|
||||
|
||||
b.str = "";
|
||||
|
||||
target.a.should.be(val());
|
||||
callNum.should.be(3);
|
||||
|
||||
a.str = "b2";
|
||||
|
||||
target.a.should.be(val());
|
||||
callNum.should.be(4);
|
||||
|
||||
c.str = "b";
|
||||
|
||||
target.a.should.be(val());
|
||||
callNum.should.be(5);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user