32 lines
612 B
Bash
32 lines
612 B
Bash
# set -euo pipefail
|
|
|
|
assert_eq() {
|
|
expected="$1"
|
|
actual="$2"
|
|
if [ "$expected" != "$actual" ]; then
|
|
echo "assert failed: expected '$expected', got '$actual'"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
verify_expr() {
|
|
./main "$1"
|
|
clang out.s -o test
|
|
./test
|
|
assert_eq $? $2
|
|
}
|
|
|
|
if [[ ! -e build ]]; then
|
|
mkdir build
|
|
fi
|
|
cd build
|
|
clang -o meta $(realpath ../meta.c) -g -Wall -Wextra -Wshadow -fdiagnostics-absolute-paths
|
|
./meta > ../meta_gen.c
|
|
clang -o main $(realpath ../main.c) -g -Wall -Wextra -Wshadow -fdiagnostics-absolute-paths
|
|
|
|
./main
|
|
verify_expr "2+1-1" 2
|
|
verify_expr "(2+1-1)*3" 6
|
|
|
|
|
|
echo done |