From 5ed582597a091d19e0edf535cb91d74202807f58 Mon Sep 17 00:00:00 2001 From: Aidan Lee Date: Tue, 17 Sep 2024 18:32:16 +0100 Subject: [PATCH] add cppia test for multi level inheritance in host (#1154) * add cppia test for multi level inheritance in host * only run new tests for haxe 5 * fix version define --- test/cppia/Client.hx | 8 ++++++++ test/cppia/ClientExtendedExtendedRoot.hx | 7 +++++++ test/cppia/Common.hx | 1 + test/cppia/CppiaHost.hx | 15 +++++++++++++++ test/cppia/HostExtendedRoot.hx | 7 +++++++ test/cppia/HostRoot.hx | 11 +++++++++++ 6 files changed, 49 insertions(+) create mode 100644 test/cppia/ClientExtendedExtendedRoot.hx create mode 100644 test/cppia/HostExtendedRoot.hx create mode 100644 test/cppia/HostRoot.hx diff --git a/test/cppia/Client.hx b/test/cppia/Client.hx index f73cb3078..85a8b274a 100644 --- a/test/cppia/Client.hx +++ b/test/cppia/Client.hx @@ -159,6 +159,14 @@ class Client return; } + + final extending = new ClientExtendedExtendedRoot(); + + extending.addValue(); + + Common.clientRoot = extending; + + Common.clientImplementation = new ClientOne(); Common.status = "ok"; diff --git a/test/cppia/ClientExtendedExtendedRoot.hx b/test/cppia/ClientExtendedExtendedRoot.hx new file mode 100644 index 000000000..9465dc60e --- /dev/null +++ b/test/cppia/ClientExtendedExtendedRoot.hx @@ -0,0 +1,7 @@ +class ClientExtendedExtendedRoot extends HostExtendedRoot { + override function addValue() { + super.addValue(); + + values.push(2); + } +} \ No newline at end of file diff --git a/test/cppia/Common.hx b/test/cppia/Common.hx index 7f4c1920f..99f80f815 100644 --- a/test/cppia/Common.hx +++ b/test/cppia/Common.hx @@ -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; diff --git a/test/cppia/CppiaHost.hx b/test/cppia/CppiaHost.hx index 3ef7e3108..611a09c2e 100644 --- a/test/cppia/CppiaHost.hx +++ b/test/cppia/CppiaHost.hx @@ -1,6 +1,7 @@ import cpp.cppia.Host; import HostBase; +import HostExtendedRoot; class HostOne implements pack.HostInterface { @@ -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 } } } diff --git a/test/cppia/HostExtendedRoot.hx b/test/cppia/HostExtendedRoot.hx new file mode 100644 index 000000000..ad45ae1b3 --- /dev/null +++ b/test/cppia/HostExtendedRoot.hx @@ -0,0 +1,7 @@ +class HostExtendedRoot extends HostRoot { + override function addValue() { + super.addValue(); + + values.push(1); + } +} \ No newline at end of file diff --git a/test/cppia/HostRoot.hx b/test/cppia/HostRoot.hx new file mode 100644 index 000000000..1d4181918 --- /dev/null +++ b/test/cppia/HostRoot.hx @@ -0,0 +1,11 @@ +class HostRoot { + public final values:Array; + + public function new() { + values = []; + } + + public function addValue() { + values.push(0); + } +} \ No newline at end of file