Skip to content

Commit da77567

Browse files
Tutez64dimensionscape
authored andcommitted
Test a cppia new of a class the host does not have.
ClientUnlinked constructs an extern class, which the cppia module only names. Loading it must fail to link: before the fix, the JIT segfaulted while compiling the module, and without the JIT the load succeeded and left a null class to construct.
1 parent 40b6285 commit da77567

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎test/cppia/ClientUnlinked.hx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// The host does not have this class: a module constructing it must fail to link.
2+
extern class Unlinked
3+
{
4+
public function new();
5+
}
6+
7+
class ClientUnlinked
8+
{
9+
public static function main()
10+
{
11+
new Unlinked();
12+
}
13+
}

‎test/cppia/cases/TestCommon.hx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ class TestCommon extends Test {
5959
Assert.equals(2, Common.callbackSet, 'Bad cppia closure');
6060
}
6161

62+
function testNewOfUnlinkedClass() {
63+
final source = sys.io.File.getBytes('bin/unlinked.cppia');
64+
65+
Assert.raises(() -> cpp.cppia.Module.fromData(source.getData()), String, 'Linked a new of a class the host does not have');
66+
}
67+
6268
@:depends(testStatus)
6369
function testInterfaceCalling() {
6470
final obj : IFoo = Type.createInstance(Type.resolveClass('ClientFoo'), []);

‎test/cppia/compile-client.hxml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
-m Client
22
-D dll_import=host_classes.info
3-
--cppia bin/client.cppia
3+
--cppia bin/client.cppia
4+
5+
--next
6+
7+
-m ClientUnlinked
8+
--cppia bin/unlinked.cppia

0 commit comments

Comments
 (0)