Skip to content

Commit b66a290

Browse files
MeguminBOTdimensionscape
authored andcommitted
Test the storage of a cppia member field declared Bool
Type.typeof on a Bool member field and a Bool static read by name must both give TBool. HaxeFoundation/hxcpp#1367
1 parent 28c74a2 commit b66a290

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎test/cppia/Client.hx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ class ClientModuleValues {
6666
}
6767
}
6868

69+
class ClientBoolField {
70+
71+
public var flag:Bool = true;
72+
73+
public static var staticFlag:Bool = true;
74+
75+
public function new() {}
76+
}
77+
6978
class Client
7079
{
7180
public static var clientBool0 = true;

‎test/cppia/cases/TestCommon.hx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ class TestCommon extends Test {
122122
return [for (name in ['literal', 'assigned']) new WeakRef<Dynamic>(Reflect.callMethod(values, Reflect.field(values, name), []))];
123123
}
124124

125+
@:depends(testStatus)
126+
function testBoolMemberStorage() {
127+
final cls = Type.resolveClass('ClientBoolField');
128+
129+
if (Assert.notNull(cls, 'Unable to resolve ClientBoolField')) {
130+
final obj = Type.createInstance(cls, []);
131+
132+
Assert.same(Type.ValueType.TBool, Type.typeof(Reflect.field(obj, 'flag')), 'Member Bool did not read back as a boolean');
133+
Assert.same(Type.ValueType.TBool, Type.typeof(Reflect.field(cls, 'staticFlag')), 'Static Bool did not read back as a boolean');
134+
}
135+
}
136+
125137
@:depends(testStatus)
126138
function testInterfaceCalling() {
127139
final obj : IFoo = Type.createInstance(Type.resolveClass('ClientFoo'), []);

0 commit comments

Comments
 (0)