108 lines
2.7 KiB
Bash
Executable File
108 lines
2.7 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
make clean
|
|
make
|
|
|
|
output=$(./peppermint smoke.ppm argument)
|
|
expected='hello peppermint
|
|
argument'
|
|
if [ "$output" != "$expected" ]; then
|
|
printf '%s\n' "unexpected legacy smoke output:" "$output" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cat > /tmp/peppermint-c89-lang.ppm <<'PPM'
|
|
let a := 7
|
|
let b = a * 3 + 2
|
|
b
|
|
b = b + 1
|
|
b == 24
|
|
b != 23
|
|
b >= 24
|
|
b <= 24
|
|
b > 23
|
|
b < 25
|
|
"hello" + " world"
|
|
@env:PEPPERMINT_TEST_VALUE
|
|
@argv:1
|
|
PPM
|
|
output=$(PEPPERMINT_TEST_VALUE=present ./peppermint run --file=/tmp/peppermint-c89-lang.ppm --args zero one)
|
|
expected='23
|
|
1
|
|
1
|
|
1
|
|
1
|
|
1
|
|
1
|
|
hello world
|
|
present
|
|
one'
|
|
if [ "$output" != "$expected" ]; then
|
|
printf '%s\n' "unexpected language output:" "$output" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cat > /tmp/peppermint-c89-const.ppm <<'PPM'
|
|
let locked := 1
|
|
locked = 2
|
|
PPM
|
|
if ./peppermint /tmp/peppermint-c89-const.ppm >/tmp/peppermint-c89-const.out 2>/tmp/peppermint-c89-const.err; then
|
|
printf '%s\n' 'constant assignment unexpectedly succeeded' >&2
|
|
exit 1
|
|
fi
|
|
if ! grep 'cannot assign to constant' /tmp/peppermint-c89-const.err >/dev/null; then
|
|
printf '%s\n' 'constant assignment error missing' >&2
|
|
exit 1
|
|
fi
|
|
|
|
tmpdir=${TMPDIR:-/tmp}/peppermint-c89-project-$$
|
|
mkdir "$tmpdir"
|
|
oldpwd=$(pwd)
|
|
cd "$tmpdir"
|
|
PEPPERMINT_STORE="$tmpdir/store.tsv" "$oldpwd/peppermint" init --name=demo --author=Tester --license=MIT >/tmp/peppermint-c89-init.out
|
|
cd "$oldpwd"
|
|
if [ ! -f "$tmpdir/demo/.peppermint" ] || [ ! -f "$tmpdir/demo/app.ppm" ] || [ ! -f "$tmpdir/demo/tests/test.ppm" ]; then
|
|
printf '%s\n' 'init did not create expected project files' >&2
|
|
exit 1
|
|
fi
|
|
printf '%s\n' '"project run"' > "$tmpdir/demo/app.ppm"
|
|
oldpwd=$(pwd)
|
|
cd "$tmpdir/demo"
|
|
output=$(PEPPERMINT_STORE="$tmpdir/store.tsv" "$oldpwd/peppermint" run)
|
|
cd "$oldpwd"
|
|
if [ "$output" != 'project run' ]; then
|
|
printf '%s\n' "unexpected project run output:" "$output" >&2
|
|
exit 1
|
|
fi
|
|
output=$(PEPPERMINT_STORE="$tmpdir/store.tsv" ./peppermint list)
|
|
case "$output" in
|
|
*demo*) ;;
|
|
*) printf '%s\n' "list output missing project:" "$output" >&2; exit 1 ;;
|
|
esac
|
|
|
|
cat > /tmp/peppermint-c89-bf.bf <<'BF'
|
|
++++++++[>++++++++<-]>+.
|
|
BF
|
|
output=$(./peppermint bf --file=/tmp/peppermint-c89-bf.bf)
|
|
expected='A'
|
|
if [ "$output" != "$expected" ]; then
|
|
printf '%s\n' "unexpected bf output:" "$output" >&2
|
|
exit 1
|
|
fi
|
|
rm -rf dist
|
|
./peppermint bf --file=/tmp/peppermint-c89-bf.bf --compile=true >/tmp/peppermint-c89-bf.out
|
|
if [ ! -f dist/test.long ]; then
|
|
printf '%s\n' 'bf compile did not create dist/test.long' >&2
|
|
exit 1
|
|
fi
|
|
rm -rf dist "$tmpdir"
|
|
|
|
output=$(./peppermint version)
|
|
case "$output" in
|
|
'Peppermint Version 0.0.1['*) ;;
|
|
*) printf '%s\n' "unexpected version output:" "$output" >&2; exit 1 ;;
|
|
esac
|
|
|
|
printf '%s\n' 'C89 feature tests passed'
|