Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,19 @@ jobs:
run: haxe compile-cpp.hxml -D ${{ env.HXCPP_ARCH_FLAG }} -D no_http
- name: run
run: bin${{ inputs.sep }}cpp${{ inputs.sep }}TestMain-debug

regression:
runs-on: ${{ inputs.os }}
name: regression tests
defaults:
run:
working-directory: test/regression
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup
uses: ./.github/workflows/setup
with:
haxe: ${{ inputs.haxe }}
- name: run
run: haxe --run Run -D ${{ env.HXCPP_ARCH_FLAG }}
2 changes: 1 addition & 1 deletion include/cpp/Pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ class Pointer_obj
}

template<typename T>
inline static AutoCast ofArray(::Array<T> array) { return AutoCast(&array[0]); }
inline static AutoCast ofArray(::Array<T> array) { return AutoCast(array->Pointer()); }
inline static AutoCast ofArray(Dynamic inVal)
{
if (inVal==null() || !inVal->__IsArray())
Expand Down
7 changes: 7 additions & 0 deletions test/regression/Issue1028/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Main {
static function main() {
var array:Array<Int> = [];
cpp.Pointer.ofArray(array);
trace(array.length);
}
}
2 changes: 2 additions & 0 deletions test/regression/Issue1028/build.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--cpp bin
-m Main
1 change: 1 addition & 0 deletions test/regression/Issue1028/stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main.hx:5: 0
60 changes: 60 additions & 0 deletions test/regression/Run.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import sys.io.Process;
import sys.io.File;
import sys.FileSystem;

using StringTools;

function runOutput(test:String):String {
final slash = Sys.systemName() == "Windows" ? "\\" : "/";
final proc = new Process([test, "bin", 'Main'].join(slash));
final code = proc.exitCode();

if (code != 0) {
throw 'return code was $code';
}

return proc.stdout.readAll().toString().replace("\r\n", "\n");
}

function main() {
var successes = 0;
var total = 0;

final args = Sys.args();

for (test in FileSystem.readDirectory(".")) {
if (!FileSystem.isDirectory(test)) {
continue;
}

total++;

final buildExitCode = Sys.command("haxe", ["-C", test, "build.hxml"].concat(args));
if (buildExitCode != 0) {
Sys.println('Failed to build test $test. Exit code: $buildExitCode');
continue;
}

final expectedStdout = File.getContent('$test/stdout.txt').replace("\r\n", "\n");
final actualStdout = try {
runOutput(test);
} catch (e) {
Sys.println('Test $test failed: $e');
continue;
};

if (actualStdout != expectedStdout) {
Sys.println('Test $test failed: Output did not match');

Sys.println("Expected stdout:");
Sys.println(expectedStdout);
Sys.println("Actual stdout:");
Sys.println(actualStdout);
continue;
}

successes++;
}

Sys.println('Regression tests complete. Successes: $successes / $total');
}
Loading