From 8397d327563086db0fbe9d96fd1c867bfa28f36c Mon Sep 17 00:00:00 2001 From: 0x4261756D <38735823+0x4261756D@users.noreply.github.com> Date: Thu, 22 Dec 2022 00:48:02 +0100 Subject: [PATCH] Add array tests --- tests/array_oob_high_read.qbl | 5 +++++ tests/array_oob_high_write.qbl | 5 +++++ tests/array_oob_low_read.qbl | 5 +++++ tests/array_oob_low_write.qbl | 5 +++++ tests/array_tests.qbl | 25 +++++++++++++++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 tests/array_oob_high_read.qbl create mode 100644 tests/array_oob_high_write.qbl create mode 100644 tests/array_oob_low_read.qbl create mode 100644 tests/array_oob_low_write.qbl create mode 100644 tests/array_tests.qbl diff --git a/tests/array_oob_high_read.qbl b/tests/array_oob_high_read.qbl new file mode 100644 index 0000000..63f0713 --- /dev/null +++ b/tests/array_oob_high_read.qbl @@ -0,0 +1,5 @@ +//invalid,Attempted an out of bounds read for array test (5 >= 4) at 5:12:END: + +arr test { bool 4 } + +5 test.read deq \ No newline at end of file diff --git a/tests/array_oob_high_write.qbl b/tests/array_oob_high_write.qbl new file mode 100644 index 0000000..9cfda34 --- /dev/null +++ b/tests/array_oob_high_write.qbl @@ -0,0 +1,5 @@ +//invalid,Attempted an out of bounds write for array test (5 >= 4) at 5:19:END: + +arr test { bool 4 } + +5 false test.write \ No newline at end of file diff --git a/tests/array_oob_low_read.qbl b/tests/array_oob_low_read.qbl new file mode 100644 index 0000000..a810cca --- /dev/null +++ b/tests/array_oob_low_read.qbl @@ -0,0 +1,5 @@ +//invalid,Attempted an out of bounds read for array test (-1 < 0) at 5:13:END: + +arr test { bool 4 } + +-1 test.read deq \ No newline at end of file diff --git a/tests/array_oob_low_write.qbl b/tests/array_oob_low_write.qbl new file mode 100644 index 0000000..df6a89f --- /dev/null +++ b/tests/array_oob_low_write.qbl @@ -0,0 +1,5 @@ +//invalid,Attempted an out of bounds write for array test (-1 < 0) at 5:19:END: + +arr test { bool 4 } + +-1 true test.write \ No newline at end of file diff --git a/tests/array_tests.qbl b/tests/array_tests.qbl new file mode 100644 index 0000000..a75cb25 --- /dev/null +++ b/tests/array_tests.qbl @@ -0,0 +1,25 @@ +//valid,0000 +//0100 +//2100 +//2103 +//:END: +arr test { int 4 } + +function => dump +{ + true 0 + while + { + dup test.read req print + 1 + test.length dup < req + } + deq "" println +} + +dump +1 1 test.write +dump +0 2 test.write +dump +3 3 test.write +dump