commit 7c9cd3c7c56240cf7246eeedbc8941a77a6fe351
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Sat Jul 2 08:00:17 2022 -0600
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Sat Jul 2 08:00:17 2022 -0600
Add e2e test for for loop optimization bug
---
test/Makefile | 2 +-
test/carts/loop_max_val.p8 | 25 +++++++++++++++++++++++++
test/carts/screenshots/loop_max_val_f01.png | Bin 0 -> 700 bytes
test/endtoendtests.cpp | 14 ++++++++++++++
4 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/test/Makefile b/test/Makefile
index 88078fd..2b99ab6 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,6 +1,6 @@
#match flags from 3ds and switch makefiles. This may not all be necessary
# removed -O2 to make debugging tests easier
-CFLAGS := -Wall -Wno-deprecated -std=c++17 -g -c \
+CFLAGS := -Wall -O2 -Wno-deprecated -std=c++17 -g -c \
-fno-rtti -fno-exceptions
diff --git a/test/carts/loop_max_val.p8 b/test/carts/loop_max_val.p8
new file mode 100644
index 0000000..38495bc
--- /dev/null
+++ b/test/carts/loop_max_val.p8
@@ -0,0 +1,25 @@
+pico-8 cartridge // http://www.pico-8.com
+version 35
+__lua__
+function _init()
+end
+
+function _draw()
+cls()
+for i=32760,32767,1 do
+ print("i: " .. i)
+ if i < 0 then
+ print("this shouldn't print :(")
+ goto outofloop
+ end
+end
+:: outofloop ::
+
+end
+__gfx__
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
diff --git a/test/carts/screenshots/loop_max_val_f01.png b/test/carts/screenshots/loop_max_val_f01.png
new file mode 100644
index 0000000..e0dd7e1
Binary files /dev/null and b/test/carts/screenshots/loop_max_val_f01.png differ
diff --git a/test/endtoendtests.cpp b/test/endtoendtests.cpp
index c388e39..7f9ce13 100644
--- a/test/endtoendtests.cpp
+++ b/test/endtoendtests.cpp
@@ -609,6 +609,20 @@ TEST_CASE("Loading and running carts") {
vm->CloseCart();
}
+ SUBCASE("loop with max number value test"){
+ vm->LoadCart("loop_max_val.p8");
+
+ SUBCASE("No error reported"){
+ CHECK(vm->GetBiosError() == "");
+ }
+ SUBCASE("sceen matches screenshot"){
+ vm->UpdateAndDraw();
+
+ CHECK(verifyScreenshot(vm, host, "carts/screenshots/loop_max_val_f01.png"));
+ }
+
+ vm->CloseCart();
+ }
delete vm;
delete host;