mirror of
https://github.com/rui314/chibicc
synced 2025-02-16 21:53:57 +03:00
25 lines
369 B
Bash
Executable File
25 lines
369 B
Bash
Executable File
#!/bin/bash
|
|
assert() {
|
|
expected="$1"
|
|
input="$2"
|
|
|
|
./chibicc "$input" > tmp.s || exit
|
|
gcc -static -o tmp tmp.s
|
|
./tmp
|
|
actual="$?"
|
|
|
|
if [ "$actual" = "$expected" ]; then
|
|
echo "$input => $actual"
|
|
else
|
|
echo "$input => $expected expected, but got $actual"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
assert 0 0
|
|
assert 42 42
|
|
assert 21 '5+20-4'
|
|
assert 41 ' 12 + 34 - 5 '
|
|
|
|
echo OK
|