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