diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-01-24 01:43:01 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-01-24 01:43:01 +0900 |
| commit | c780cbb6acd0e0526f2d305138190392bdc8cdd7 (patch) | |
| tree | df1edba6eb5778a00e1f4c8a5051414d5bb37e71 /tests/cli.sh | |
| parent | d179d944c0633d3aa2420009335791b115f67052 (diff) | |
| download | ducc-c780cbb6acd0e0526f2d305138190392bdc8cdd7.tar.gz ducc-c780cbb6acd0e0526f2d305138190392bdc8cdd7.tar.zst ducc-c780cbb6acd0e0526f2d305138190392bdc8cdd7.zip | |
refactor: organize test files
Diffstat (limited to 'tests/cli.sh')
| -rw-r--r-- | tests/cli.sh | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/cli.sh b/tests/cli.sh new file mode 100644 index 0000000..fc8a481 --- /dev/null +++ b/tests/cli.sh @@ -0,0 +1,79 @@ +# --version +expected="ducc v0.3.0" + +if [[ "$("$ducc" --version)" != "$expected" ]]; then + echo "invalid output" >&2 + exit 1 +fi + +# assembly output +cat > foo.c <<'EOF' +int main() {} +EOF + +"$ducc" -o bar.s foo.c +if [[ $? -ne 0 ]]; then + exit 1 +fi +gcc -o a.out bar.s +./a.out "$@" +exit_code=$? + +if [[ $exit_code -ne 0 ]]; then + echo "invalid exit code: $exit_code" >&2 + exit 1 +fi + +# argc/argv +cat <<'EOF' > expected +argc = 4 +argv[1] = hoge +argv[2] = piyo +argv[3] = fuga +EOF +test_diff hoge piyo fuga<<'EOF' +int printf(); + +int main(int argc, char** argv) { + printf("argc = %d\n", argc); + int i; + for (i = 1; i < argc; ++i) { + printf("argv[%d] = %s\n", i, argv[i]); + } + return 0; +} +EOF + +# compile errors +cat <<'EOF' > expected +main.c:2: undefined function: f +EOF +test_compile_error <<'EOF' +int main() { + f(); +} +EOF + +# TODO: improve error message +# cat <<'EOF' > expected +# main.c:1: expected ';' or '{', but got '}' +# EOF +cat <<'EOF' > expected +main.c:1: expected ';', but got '}' +EOF + +test_compile_error <<'EOF' +int main() } +EOF + +# TODO: improve error message +# cat <<'EOF' > expected +# main.c:1: expected ';' or '{', but got '}' +# EOF +cat <<'EOF' > expected +main.c:1: expected ';', but got '123' +EOF + +test_compile_error <<'EOF' +int main() 123 +EOF |
