summaryrefslogtreecommitdiffhomepage
path: root/tests/custom
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-03-20 23:34:56 +0100
committerGitHub <noreply@github.com>2022-03-20 23:34:56 +0100
commita88aca97633c2ec58987a76a5a8d910c37680e07 (patch)
treedee32d4bba166995bdb32d4cf8f1fcad8bcead4d /tests/custom
parent807060a5d2d40113d9d78bf9e3866efb3de4c442 (diff)
parentab46fdfe742e754a8a56207ce1fc5653085696ad (diff)
Merge pull request #52 from jow-/portability-fixes
Portability fixes for macOS
Diffstat (limited to 'tests/custom')
-rw-r--r--tests/custom/00_syntax/21_regex_literals16
-rw-r--r--tests/custom/03_stdlib/16_sort2
-rwxr-xr-xtests/custom/run_tests.sh16
3 files changed, 23 insertions, 11 deletions
diff --git a/tests/custom/00_syntax/21_regex_literals b/tests/custom/00_syntax/21_regex_literals
index 6d85e97..d7ba7c4 100644
--- a/tests/custom/00_syntax/21_regex_literals
+++ b/tests/custom/00_syntax/21_regex_literals
@@ -73,17 +73,23 @@ In line 2, byte 2:
Testing regex compilation errors.
-- Expect stderr --
-Syntax error: Unmatched \{
-In line 2, byte 3:
+Catched syntax error
+In line 7, byte 30:
- ` /foo {/`
- ^-- Near here
+ ` die("Catched syntax error");`
+ Near here ----------------------------^
-- End --
-- Testcase --
{%
- /foo {/
+ try {
+ /foo (/
+ }
+ catch (e) {
+ if (e.type == "Syntax error")
+ die("Catched syntax error");
+ }
%}
-- End --
diff --git a/tests/custom/03_stdlib/16_sort b/tests/custom/03_stdlib/16_sort
index ccc235f..ac4a0e1 100644
--- a/tests/custom/03_stdlib/16_sort
+++ b/tests/custom/03_stdlib/16_sort
@@ -31,7 +31,7 @@ Returns `null` if the given input array value is not an array.
let t1 = type(a), t2 = type(b);
if (t1 < t2)
return -1;
- else if (t2 > t2)
+ else if (t1 > t2)
return 1;
if (a < b)
diff --git a/tests/custom/run_tests.sh b/tests/custom/run_tests.sh
index c2839df..fb92379 100755
--- a/tests/custom/run_tests.sh
+++ b/tests/custom/run_tests.sh
@@ -1,7 +1,13 @@
#!/usr/bin/env bash
+if greadlink -f . &>/dev/null; then
+ readlink=greadlink
+else
+ readlink=readlink
+fi
+
testdir=$(dirname "$0")
-topdir=$(readlink -f "$testdir/../..")
+topdir=$($readlink -f "$testdir/../..")
line='........................................'
ucode_bin=${UCODE_BIN:-"$topdir/ucode"}
@@ -44,7 +50,7 @@ extract_sections() {
tag="file"
outfile="${line#-- File }"
outfile="$(echo "${outfile% --}" | xargs)"
- outfile="$dir/files$(readlink -m "/${outfile:-file}")"
+ outfile="$dir/files$($readlink -m "/${outfile:-file}")"
mkdir -p "$(dirname "$outfile")"
printf "" > "$outfile"
;;
@@ -93,7 +99,7 @@ run_testcase() {
IFS=$' \t\n'
- $ucode_bin -T -L "$ucode_lib/*.so" -D TESTFILES_PATH="$dir/files" $args - <"$in" >"$dir/res.out" 2>"$dir/res.err"
+ $ucode_bin -T"," -L "$ucode_lib/*.so" -D TESTFILES_PATH="$($readlink -f "$dir/files")" $args - <"$in" >"$dir/res.out" 2>"$dir/res.err"
)
printf "%d\n" $? > "$dir/res.code"
@@ -200,14 +206,14 @@ n_fails=0
select_tests="$@"
use_test() {
- local input="$(readlink -f "$1")"
+ local input="$($readlink -f "$1")"
local test
[ -f "$input" ] || return 1
[ -n "$select_tests" ] || return 0
for test in "$select_tests"; do
- test="$(readlink -f "$test")"
+ test="$($readlink -f "$test")"
[ "$test" != "$input" ] || return 0
done