diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-03-16 19:24:02 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-03-16 19:24:02 -0400 |
commit | a48fdca56dfb7cab319789fb51b2d8959cf04c84 (patch) | |
tree | fdf19c1debd02dbd8cbdfde6e2b434736c29c9c2 /tests | |
parent | 81e79161151912c86c6892bf8d4349360826c971 (diff) |
sizeof, alignof
Diffstat (limited to 'tests')
-rw-r--r-- | tests/sizeof.toc | 17 | ||||
-rw-r--r-- | tests/sizeof_expected | 2 | ||||
-rwxr-xr-x | tests/test.sh | 8 |
3 files changed, 26 insertions, 1 deletions
diff --git a/tests/sizeof.toc b/tests/sizeof.toc new file mode 100644 index 0000000..0bc806b --- /dev/null +++ b/tests/sizeof.toc @@ -0,0 +1,17 @@ +#include "io.toc", io; + +Point3D ::= struct { + x, y, z: f32; +} + +calculation ::= fn() int { + p: Point3D; + (#sizeof Point3D) * (#sizeof typeof p) * (sizeof Point3D) * (sizeof typeof p) + * (#alignof Point3D) * (#alignof typeof p) * (alignof Point3D) * (alignof typeof p) +} + +main ::= fn() { + x ::= calculation(); + io.puti(x); + io.puti(calculation()); +}
\ No newline at end of file diff --git a/tests/sizeof_expected b/tests/sizeof_expected new file mode 100644 index 0000000..d93e228 --- /dev/null +++ b/tests/sizeof_expected @@ -0,0 +1,2 @@ +5308416 +5308416 diff --git a/tests/test.sh b/tests/test.sh index 4016151..5e4535a 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -2,6 +2,7 @@ tests='bf control_flow +sizeof arr arr2 arr3 @@ -30,6 +31,8 @@ compile_c() { $CC $CFLAGS $EXTRA_FLAGS -Werror -o a.out out.c || exit 1 } +failed=false + do_tests() { valgrind -q --exit-on-first-error=yes --error-exitcode=1 $TOC "$1.toc" -o out.c || exit 1 for CC in "gcc -O0 -g" "tcc" "clang -O3 -s"; do @@ -40,7 +43,7 @@ do_tests() { printf '\x1b[92mpassed!\x1b[0m\n' else printf '\x1b[91mfailed!\x1b[0m\n' - exit 1 + failed=true fi done } @@ -49,3 +52,6 @@ for x in $tests; do done rm got a.out out.c +if $failed; then + exit 1 +fi |