Skip to content

Commit 658ddc6

Browse files
committed
Check String.fromCharCode without smart strings
1 parent 4cff17a commit 658ddc6

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,19 @@ jobs:
221221
run: haxe compile-cpp.hxml -D ${{ env.HXCPP_ARCH_FLAG }} -D no_http
222222
- name: run
223223
run: bin${{ inputs.sep }}cpp${{ inputs.sep }}TestMain-debug
224+
225+
regression:
226+
runs-on: ${{ inputs.os }}
227+
name: regression tests
228+
defaults:
229+
run:
230+
working-directory: test/regression
231+
steps:
232+
- name: checkout
233+
uses: actions/checkout@v4
234+
- name: setup
235+
uses: ./.github/workflows/setup
236+
with:
237+
haxe: ${{ inputs.haxe }}
238+
- name: run
239+
run: haxe --run Run -D ${{ env.HXCPP_ARCH_FLAG }}

test/regression/IssueXXX/Main.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Main {
2+
static function main() {
3+
trace(String.fromCharCode("á".code) == "á");
4+
}
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-cpp bin
2+
-m Main
3+
-D disable-unicode-strings

test/regression/IssueXXX/stdout.txt

Whitespace-only changes.

test/regression/Run.hx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import sys.io.Process;
2+
import sys.io.File;
3+
import sys.FileSystem;
4+
5+
using StringTools;
6+
7+
function runOutput(test:String):String {
8+
final slash = Sys.systemName() == "Windows" ? "\\" : "/";
9+
final proc = new Process([test, "bin", 'Main'].join(slash));
10+
final code = proc.exitCode();
11+
12+
if (code != 0) {
13+
throw 'return code was $code';
14+
}
15+
16+
return proc.stdout.readAll().toString().replace("\r\n", "\n");
17+
}
18+
19+
function main() {
20+
var successes = 0;
21+
var total = 0;
22+
23+
final args = Sys.args();
24+
25+
for (test in FileSystem.readDirectory(".")) {
26+
if (!FileSystem.isDirectory(test)) {
27+
continue;
28+
}
29+
30+
total++;
31+
32+
final buildExitCode = Sys.command("haxe", ["-C", test, "build.hxml"].concat(args));
33+
if (buildExitCode != 0) {
34+
Sys.println('Failed to build test $test. Exit code: $buildExitCode');
35+
continue;
36+
}
37+
38+
final expectedStdout = File.getContent('$test/stdout.txt').replace("\r\n", "\n");
39+
final actualStdout = try {
40+
runOutput(test);
41+
} catch (e) {
42+
Sys.println('Test $test failed: $e');
43+
continue;
44+
};
45+
46+
if (actualStdout != expectedStdout) {
47+
Sys.println('Test $test failed: Output did not match');
48+
49+
Sys.println("Expected stdout:");
50+
Sys.println(expectedStdout);
51+
Sys.println("Actual stdout:");
52+
Sys.println(actualStdout);
53+
continue;
54+
}
55+
56+
successes++;
57+
}
58+
59+
Sys.println('Regression tests complete. Successes: $successes / $total');
60+
}

0 commit comments

Comments
 (0)