Skip to content

Commit

Permalink
add cppia test for multi level inheritance in host (#1154)
Browse files Browse the repository at this point in the history
* add cppia test for multi level inheritance in host

* only run new tests for haxe 5

* fix version define
  • Loading branch information
Aidan63 authored Sep 17, 2024
1 parent 8e19a09 commit 5ed5825
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/cppia/Client.hx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ class Client
return;
}


final extending = new ClientExtendedExtendedRoot();

extending.addValue();

Common.clientRoot = extending;


Common.clientImplementation = new ClientOne();
Common.status = "ok";

Expand Down
7 changes: 7 additions & 0 deletions test/cppia/ClientExtendedExtendedRoot.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ClientExtendedExtendedRoot extends HostExtendedRoot {
override function addValue() {
super.addValue();

values.push(2);
}
}
1 change: 1 addition & 0 deletions test/cppia/Common.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Common
public static var status:String = "tests not run";
public static var hostImplementation:pack.HostInterface;
public static var clientImplementation:pack.HostInterface;
public static var clientRoot:HostRoot;

public static var callbackSet:Int = 0;
public static var callback: Void->Void;
Expand Down
15 changes: 15 additions & 0 deletions test/cppia/CppiaHost.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cpp.cppia.Host;

import HostBase;
import HostExtendedRoot;

class HostOne implements pack.HostInterface
{
Expand Down Expand Up @@ -84,6 +85,20 @@ class CppiaHost
Sys.println("Bad cppia closure");
Sys.exit(-1);
}

#if (haxe >= version("4.3.6"))
if (Common.clientRoot == null) {
Sys.println("null client root class");
Sys.exit(-1);
}
switch Common.clientRoot.values {
case [ 0, 1, 2 ]:
//
case _:
Sys.println("Unexpected items in array");
Sys.exit(-1);
}
#end
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/cppia/HostExtendedRoot.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class HostExtendedRoot extends HostRoot {
override function addValue() {
super.addValue();

values.push(1);
}
}
11 changes: 11 additions & 0 deletions test/cppia/HostRoot.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class HostRoot {
public final values:Array<Int>;

public function new() {
values = [];
}

public function addValue() {
values.push(0);
}
}

0 comments on commit 5ed5825

Please sign in to comment.