diff --git a/src/bindx/BindMacros.hx b/src/bindx/BindMacros.hx index f005cf8..819ab2c 100644 --- a/src/bindx/BindMacros.hx +++ b/src/bindx/BindMacros.hx @@ -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 _: diff --git a/test/BaseTest.hx b/test/BaseTest.hx index b1787cb..ddb768b 100644 --- a/test/BaseTest.hx +++ b/test/BaseTest.hx @@ -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; diff --git a/test/MetaTest.hx b/test/MetaTest.hx index cf4e935..fe8b178 100644 --- a/test/MetaTest.hx +++ b/test/MetaTest.hx @@ -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() {} } \ No newline at end of file diff --git a/test/TestProperty.hx b/test/TestProperty.hx index 980b531..9bcfead 100644 --- a/test/TestProperty.hx +++ b/test/TestProperty.hx @@ -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;