-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathtest.sh
executable file
·55 lines (44 loc) · 1.01 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2020-2023 UnionTech Software Technology Co.,Ltd.
# shellcheck disable=2016
set -e
OUT=/tmp/out
ERR=/tmp/err
touch "$OUT"
touch "$ERR"
: "${UNILANG:=./unilang}"
if test -d "$UNILANG" || test ! -x "$UNILANG"; then
echo "ERROR: Wrong '$UNILANG' found as the interpreter."
exit 1
fi
call_intp()
{
set +e
echo > "$ERR"
# echo "$1" | "$UNILANG" 1> "$OUT" 2> "$ERR"
"$UNILANG" -e "$1" 1> "$OUT" 2> "$ERR"
set -e
}
# NOTE: Test cases should print no errors.
run_case()
{
echo "Running case:" "$1"
if ! (call_intp "$1") || test -s "$ERR"; then
echo "FAIL."
echo "Error:"
cat "$ERR"
else
echo "PASS."
fi
}
if test -n "$PTC"; then
# NOTE: Test cases should print no errors.
echo "The following case are expected to be non-terminating."
echo "However, the maximum memory consumption is expected constant."
echo "Please exit manually by SIGINT."
run_case '$defl! f (n) $if #t (f n); f 1'
fi
# Sanity.
run_case 'display'
# Documented examples.
run_case 'load "test.txt"'