major bug fix in setter patch
This commit is contained in:
@@ -101,7 +101,7 @@ class BindMacros {
|
||||
func.expr = macro {
|
||||
var $OLD_VALUE = this.$fieldName;
|
||||
if ($i{OLD_VALUE} == $i{func.args[0].name}) return $i{OLD_VALUE};
|
||||
$e{func.expr.map(patchSetter)};
|
||||
$e{patchSetter(func.expr)};
|
||||
};
|
||||
patchField = null;
|
||||
case _:
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ class BaseTest extends BuddySuite {
|
||||
callNum = 0;
|
||||
});
|
||||
|
||||
it ("bindx should bind/unbind fields (lazySignal=true)", {
|
||||
it("bindx should bind/unbind fields (lazySignal=true)", {
|
||||
var strFrom = b.str = "a";
|
||||
var callNum2 = 0;
|
||||
|
||||
@@ -51,7 +51,7 @@ class BaseTest extends BuddySuite {
|
||||
callNum2.should.be(1);
|
||||
});
|
||||
|
||||
it ("bindx should bind/unbind fields (lazySignal=false)", {
|
||||
it("bindx should bind/unbind fields (lazySignal=false)", {
|
||||
var strFrom = b.str2 = "a";
|
||||
var callNum2 = 0;
|
||||
|
||||
|
||||
+43
-3
@@ -1,19 +1,59 @@
|
||||
package ;
|
||||
|
||||
import bindx.Bind;
|
||||
import bindx.IBindable;
|
||||
import buddy.BuddySuite;
|
||||
|
||||
using buddy.Should;
|
||||
|
||||
class MetaTest extends BuddySuite {
|
||||
|
||||
public function new() {
|
||||
|
||||
describe("bindx should inherit @bindable meta", {
|
||||
|
||||
var b:BindableMeta;
|
||||
var callNum:Int;
|
||||
|
||||
before({
|
||||
|
||||
b = new BindableMeta();
|
||||
callNum = 0;
|
||||
});
|
||||
|
||||
it("bindx inherit metadata bindable for public fields");
|
||||
it("bindx inherit metadata params");
|
||||
it("bindx inherit metadata bindable for public fields", {
|
||||
b.str = "a";
|
||||
Bind.bind(b.str, function(_, _) callNum++);
|
||||
|
||||
b.str = "b";
|
||||
callNum.should.be(1);
|
||||
});
|
||||
|
||||
it("bindx inherit metadata bindable for public fields", {
|
||||
b.str2 = "a";
|
||||
Bind.bind(b.str2, function(_, _) callNum++);
|
||||
|
||||
b.str2 = "b";
|
||||
callNum.should.be(1);
|
||||
});
|
||||
|
||||
it("bindx inherit metadata params", {
|
||||
Reflect.hasField(b, "strChanged").should.be(true); // lazySignal=false
|
||||
Reflect.hasField(b, "str2Changed").should.be(true); // lazySignal=false
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@:bindable(lazySignal=false)
|
||||
class BindableMeta implements IBindable {
|
||||
|
||||
public var str:String;
|
||||
|
||||
public var str2(get, set):String;
|
||||
|
||||
function get_str2() return "";
|
||||
function set_str2(value) return value;
|
||||
|
||||
public function new() {}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class TestProperty extends BuddySuite {
|
||||
callNum = 0;
|
||||
});
|
||||
|
||||
it ("bindx should bind/unbind fields (lazySignal=true)", {
|
||||
it("bindx should bind/unbind fields (lazySignal=true)", {
|
||||
var strFrom = b.str = "a";
|
||||
var callNum2 = 0;
|
||||
|
||||
@@ -50,7 +50,7 @@ class TestProperty extends BuddySuite {
|
||||
callNum2.should.be(1);
|
||||
});
|
||||
|
||||
it ("bindx should bind/unbind fields (lazySignal=false)", {
|
||||
it("bindx should bind/unbind fields (lazySignal=false)", {
|
||||
var strFrom = b.str2 = "a";
|
||||
var callNum2 = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user