Added tests for stdlib stack functions. Fixed some small bugs.
authorAaron Taylor <ataylor@subgeniuskitty.com>
Sat, 27 Jul 2019 22:59:37 +0000 (15:59 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Sat, 27 Jul 2019 22:59:37 +0000 (15:59 -0700)
stdlib/stack.pvvs
stdlib_tests/1001_stackrotate.pvvs [new file with mode: 0644]
stdlib_tests/1002_stackrotatereverse.pvvs [new file with mode: 0644]
stdlib_tests/1003_deepdup.pvvs [new file with mode: 0644]
stdlib_tests/vv_test.py

index c543d98..8705c6a 100644 (file)
@@ -6,6 +6,7 @@
 @   stackrotate
 @ Description:
 @   Maximum rotation depth is 14. Stomps on heap[1]-heap[15].
 @   stackrotate
 @ Description:
 @   Maximum rotation depth is 14. Stomps on heap[1]-heap[15].
+@   Assumes rotation depth is at least 2.
 @ Call Stack:
 @   stack word n
 @   ...
 @ Call Stack:
 @   stack word n
 @   ...
@@ -22,10 +23,11 @@ NSSVTSTSN               | Mark: 1010 (stackrotate)
 
 @ For the convenience of other functions, modulo the
 @ rotation depth by the available registers.
 
 @ For the convenience of other functions, modulo the
 @ rotation depth by the available registers.
-SSSTTTSN                | PUSH 14
+SSSTTTTN                | PUSH 15
 TSTT                    | MODULO
 
 @ Use heap[15] for generating register addresses.
 TSTT                    | MODULO
 
 @ Use heap[15] for generating register addresses.
+@ TODO: Switch to using heap[1] so number of registers is limited only by user.
 SSSTTTTN                | PUSH 15 (ptr)
 SSSSN                   | PUSH 0
 TTS                     | STORE
 SSSTTTTN                | PUSH 15 (ptr)
 SSSSN                   | PUSH 0
 TTS                     | STORE
@@ -109,6 +111,7 @@ NTN                     | RTS
 @   stackrotatereverse
 @ Description:
 @   Maximum rotation depth is 14. Stomps on heap[1]-heap[15].
 @   stackrotatereverse
 @ Description:
 @   Maximum rotation depth is 14. Stomps on heap[1]-heap[15].
+@   Assumes rotation depth is at least 2.
 @ Call Stack:
 @   stack word n
 @   ...
 @ Call Stack:
 @   stack word n
 @   ...
@@ -125,10 +128,11 @@ NSSVTSTTN               | Mark: 1011 (stackrotatereverse)
 
 @ For the convenience of other functions, modulo the
 @ rotation depth by the available registers.
 
 @ For the convenience of other functions, modulo the
 @ rotation depth by the available registers.
-SSSTTTSN                | PUSH 14
+SSSTTTTN                | PUSH 15
 TSTT                    | MODULO
 
 @ Use heap[15] for generating register addresses.
 TSTT                    | MODULO
 
 @ Use heap[15] for generating register addresses.
+@ TODO: Switch to using heap[1] so number of registers is limited only by user.
 SSSTTTTN                | PUSH 15 (ptr)
 SSSSN                   | PUSH 0
 TTS                     | STORE
 SSSTTTTN                | PUSH 15 (ptr)
 SSSSN                   | PUSH 0
 TTS                     | STORE
diff --git a/stdlib_tests/1001_stackrotate.pvvs b/stdlib_tests/1001_stackrotate.pvvs
new file mode 100644 (file)
index 0000000..9a38f03
--- /dev/null
@@ -0,0 +1,28 @@
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTTTTSTSSN    | PUSH 244
+SSSTTTTSSTTN    | PUSH 243
+SSSTTTTSSTSN    | PUSH 242
+
+SSSTTTSN        | PUSH 14
+NSTTSTSN        | JSR > 1010 (stackrotate)
+SSSTSSSN        | PUSH 8
+NSTTSTSN        | JSR > 1010 (stackrotate)
+SSSTSN          | PUSH 2
+NSTTSTSN        | JSR > 1010 (stackrotate)
+
+SSSTTSTN        | PUSH 13
+NSTTTTSSTN      | JSR > 111001 (dumpstack)
+NNN             | DIE
+
+#include <stack.pvvs>
+#include <debug.pvvs>
diff --git a/stdlib_tests/1002_stackrotatereverse.pvvs b/stdlib_tests/1002_stackrotatereverse.pvvs
new file mode 100644 (file)
index 0000000..e695a23
--- /dev/null
@@ -0,0 +1,26 @@
+SSSTTTTSTSSN    | PUSH 244
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+
+SSSTTTSN        | PUSH 14
+NSTTSTTN        | JSR > 1011 (stackrotatereverse)
+SSSTSN          | PUSH 2
+NSTTSTTN        | JSR > 1011 (stackrotatereverse)
+
+SSSTTSTN        | PUSH 13
+NSTTTTSSTN      | JSR > 111001 (dumpstack)
+NNN             | DIE
+
+#include <stack.pvvs>
+#include <debug.pvvs>
diff --git a/stdlib_tests/1003_deepdup.pvvs b/stdlib_tests/1003_deepdup.pvvs
new file mode 100644 (file)
index 0000000..ead3319
--- /dev/null
@@ -0,0 +1,26 @@
+SSSTTTTSTSSN    | PUSH 244
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+SSSTN           | PUSH 1
+
+@SSSTTTSN        | PUSH 14
+SSSTTSTN        | PUSH 13
+NSTTTSSN        | JSR > 1100 (deepdup)
+SSSTSN          | PUSH 2
+NSTTTSSN        | JSR > 1100 (deepdup)
+
+SSSTTTSN        | PUSH 14
+NSTTTTSSTN      | JSR > 111001 (dumpstack)
+NNN             | DIE
+
+#include <stack.pvvs>
+#include <debug.pvvs>
index 4b51b01..ff79a25 100755 (executable)
@@ -20,6 +20,9 @@ tests = [
         # Format: ['filename_without_extension', 'string for stdin', 'string for expected stdout']
         ['0001_dumpstack', '', 'TOS:\n1:\t+42\n0:\t+255\n'],
         ['0002_dumpheap', '', '32:\t+255\n33:\t+42\n'],
         # Format: ['filename_without_extension', 'string for stdin', 'string for expected stdout']
         ['0001_dumpstack', '', 'TOS:\n1:\t+42\n0:\t+255\n'],
         ['0002_dumpheap', '', '32:\t+255\n33:\t+42\n'],
+        ['1001_stackrotate', '', 'TOS:\n13:\t+1\n12:\t+244\n11:\t+1\n10:\t+1\n9:\t+1\n8:\t+1\n7:\t+1\n6:\t+243\n5:\t+1\n4:\t+1\n3:\t+1\n2:\t+1\n1:\t+1\n0:\t+242\n'],
+        ['1002_stackrotatereverse', '', 'TOS:\n13:\t+1\n12:\t+244\n11:\t+1\n10:\t+1\n9:\t+1\n8:\t+1\n7:\t+1\n6:\t+1\n5:\t+1\n4:\t+1\n3:\t+1\n2:\t+1\n1:\t+1\n0:\t+1\n'],
+        ['1003_deepdup', '', 'TOS:\n14:\t+1\n13:\t+244\n12:\t+1\n11:\t+1\n10:\t+1\n9:\t+1\n8:\t+1\n7:\t+1\n6:\t+1\n5:\t+1\n4:\t+1\n3:\t+1\n2:\t+1\n1:\t+1\n0:\t+244\n'],
         ] 
 
 for test in tests:
         ] 
 
 for test in tests: