inline tests

This commit is contained in:
Dima Granetchi
2014-11-16 02:00:58 +02:00
parent 6c70b0eb78
commit 8a6e196d67
+63 -2
View File
@@ -3,6 +3,8 @@ package ;
import bindx.Bind;
import bindx.IBindable;
import buddy.BuddySuite;
import haxe.rtti.CType;
import haxe.rtti.XmlParser;
using buddy.Should;
@@ -12,9 +14,68 @@ class InlineTest extends BuddySuite {
describe("Using @:bindable(inlineSetter=true/false, inlineSignalGetter=true/false)", {
it("bindx should generate inline setter");
it("bindx should generate inline signal getter");
var b:BindableInline;
var cd:Classdef;
var foundFields:Int;
before({
foundFields = 0;
b = new BindableInline();
var rttiData:String = untyped BindableInline.__rtti;
var rtti = new XmlParser().processElement(Xml.parse(rttiData).firstChild());
cd = switch (rtti) { case TClassdecl(c): c; case _: null; };
});
it("bindx should generate inline setter", {
for (c in cd.fields) {
switch (c.name) {
case "set_str":
foundFields ++;
c.get.match(RInline).should.be(true);
case "set_str2":
foundFields ++;
c.get.match(RNormal).should.be(true);
case _:
}
}
foundFields.should.be(2);
});
it("bindx should generate inline signal getter", {
for (c in cd.fields) {
switch (c.name) {
case "get_str3Changed":
foundFields ++;
c.get.match(RInline).should.be(true);
case "get_str4Changed":
foundFields ++;
c.get.match(RNormal).should.be(true);
case _:
}
}
foundFields.should.be(2);
});
});
}
}
@:rtti
@:bindable(lazySignal=true)
class BindableInline implements bindx.IBindable {
@:bindable(inlineSetter=true)
public var str:String;
@:bindable(inlineSetter=false)
public var str2:String;
@:bindable(inlineSignalGetter=true)
public var str3:String;
@:bindable(inlineSignalGetter=false)
public var str4:String;
public function new() {
}
}