aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/002.sh
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-05-03 13:44:48 +0900
committernsfisis <nsfisis@gmail.com>2025-05-03 13:44:48 +0900
commit0177c5753334cc3120e52871bedc9ea836c99022 (patch)
tree4bf0f5cbce99763f83ad55baec9ae329b1619524 /tests/002.sh
parent3ca8ddc7b2825e8a91f02c3cb1262ab064467030 (diff)
downloadP4Dcc-0177c5753334cc3120e52871bedc9ea836c99022.tar.gz
P4Dcc-0177c5753334cc3120e52871bedc9ea836c99022.tar.zst
P4Dcc-0177c5753334cc3120e52871bedc9ea836c99022.zip
binary arightmetic operations
Diffstat (limited to 'tests/002.sh')
-rw-r--r--tests/002.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/002.sh b/tests/002.sh
new file mode 100644
index 0000000..65d3d69
--- /dev/null
+++ b/tests/002.sh
@@ -0,0 +1,21 @@
+cat <<'EOF' > main.c
+int main() {
+ return 5+20-4;
+}
+EOF
+
+"$p4dcc" < main.c > main.s
+if [[ $? -ne 0 ]]; then
+ cat main.s >&2
+ exit 1
+fi
+gcc -o a.out main.s
+./a.out
+exit_code=$?
+
+expected=21
+
+if [[ ! $exit_code -eq $expected ]]; then
+ echo "expected $expected, but $exit_code" >&2
+ exit 1
+fi