Added test for all stdio.pvvs subroutines.
authorAaron Taylor <ataylor@subgeniuskitty.com>
Sun, 8 Sep 2019 12:53:11 +0000 (05:53 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Sun, 8 Sep 2019 12:53:11 +0000 (05:53 -0700)
stdlib/stdio.pvvs
stdlib_tests/6001_printstackstring.pvvs [new file with mode: 0644]
stdlib_tests/6002_printheapstring.pvvs [new file with mode: 0644]
stdlib_tests/6003_printnumbersign.pvvs [new file with mode: 0644]
stdlib_tests/6004_printnumbermagnitude.pvvs [new file with mode: 0644]
stdlib_tests/6005_printstacknumber.pvvs [new file with mode: 0644]
stdlib_tests/6006_printf_staticstackstring.pvvs [new file with mode: 0644]
stdlib_tests/6007_printf_staticheapstring.pvvs [new file with mode: 0644]
stdlib_tests/6008_printf_escapedstackstring.pvvs [new file with mode: 0644]
stdlib_tests/6009_printf_substitutedstackstring.pvvs [new file with mode: 0644]
stdlib_tests/vv_test.py

index 8637d67..2b77d1d 100644 (file)
@@ -259,7 +259,7 @@ TSST                    | SUBTRACT
 NTSSSSSTSSSSSSSSTSSN    | BRZ > 00001000 00000100
 @ Check for ASCII '\t'
 SNS                     | DUP
 NTSSSSSTSSSSSSSSTSSN    | BRZ > 00001000 00000100
 @ Check for ASCII '\t'
 SNS                     | DUP
-SSSTSSTN                | PUSH ASCII '\t'
+SSSTTTSTSSN             | PUSH ASCII 't'
 TSST                    | SUBTRACT
 NTSSSSSTSSSSSSSSTSTN    | BRZ > 00001000 00000101
 @ No substitution necessary. Print literally.
 TSST                    | SUBTRACT
 NTSSSSSTSSSSSSSSTSTN    | BRZ > 00001000 00000101
 @ No substitution necessary. Print literally.
diff --git a/stdlib_tests/6001_printstackstring.pvvs b/stdlib_tests/6001_printstackstring.pvvs
new file mode 100644 (file)
index 0000000..05656bc
--- /dev/null
@@ -0,0 +1,5 @@
+A"test"
+NSTTSSSTSSN     | JSR > 1000100 (printstackstring)
+NNN             | DIE
+
+#include <stdio.pvvs>
diff --git a/stdlib_tests/6002_printheapstring.pvvs b/stdlib_tests/6002_printheapstring.pvvs
new file mode 100644 (file)
index 0000000..68e4942
--- /dev/null
@@ -0,0 +1,12 @@
+A"test"
+SSSTSSSSSN      | PUSH 32 (address)
+SSSTSSN         | PUSH 4 (count)
+NSTTTTTTN       | JSR > 11111 (spew)
+
+SSSTSSSSSN      | PUSH 32 (address)
+NSTTSSSTSTN     | JSR > 1000101 (printheapstring)
+
+NNN             | DIE
+
+#include <heap.pvvs>
+#include <stdio.pvvs>
diff --git a/stdlib_tests/6003_printnumbersign.pvvs b/stdlib_tests/6003_printnumbersign.pvvs
new file mode 100644 (file)
index 0000000..5d27555
--- /dev/null
@@ -0,0 +1,9 @@
+SSSTSSSSSN      | PUSH +32
+NSTTSSSSTSN     | JSR > 1000010 (printnumbersign)
+
+SSTTSSSSSN      | PUSH -32
+NSTTSSSSTSN     | JSR > 1000010 (printnumbersign)
+
+NNN             | DIE
+
+#include <stdio.pvvs>
diff --git a/stdlib_tests/6004_printnumbermagnitude.pvvs b/stdlib_tests/6004_printnumbermagnitude.pvvs
new file mode 100644 (file)
index 0000000..ad7bd8e
--- /dev/null
@@ -0,0 +1,15 @@
+SSSTSSSSSN      | PUSH +32
+NSTTSSSSTTN     | JSR > 1000011 (printnumbermagnitude)
+
+SSTTSSSSSN      | PUSH -32
+NSTTSSSSTTN     | JSR > 1000011 (printnumbermagnitude)
+
+SSTSN           | PUSH -0
+NSTTSSSSTTN     | JSR > 1000011 (printnumbermagnitude)
+
+SSTTSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSN | -(2^63)
+NSTTSSSSTTN     | JSR > 1000011 (printnumbermagnitude)
+
+NNN             | DIE
+
+#include <stdio.pvvs>
diff --git a/stdlib_tests/6005_printstacknumber.pvvs b/stdlib_tests/6005_printstacknumber.pvvs
new file mode 100644 (file)
index 0000000..b6e88ed
--- /dev/null
@@ -0,0 +1,15 @@
+SSSTSSSSSN      | PUSH +32
+NSTTSSTN        | JSR > 1001 (printstacknumber)
+
+SSTTSSSSSN      | PUSH -32
+NSTTSSTN        | JSR > 1001 (printstacknumber)
+
+SSTSN           | PUSH -0
+NSTTSSTN        | JSR > 1001 (printstacknumber)
+
+SSTTSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSN | -(2^63)
+NSTTSSTN        | JSR > 1001 (printstacknumber)
+
+NNN             | DIE
+
+#include <stdio.pvvs>
diff --git a/stdlib_tests/6006_printf_staticstackstring.pvvs b/stdlib_tests/6006_printf_staticstackstring.pvvs
new file mode 100644 (file)
index 0000000..fe82476
--- /dev/null
@@ -0,0 +1,7 @@
+A"test"
+SSSSN           | PUSH 0 (number of substitutions)
+NSTTSSSN        | JSR > 1000 (printf)
+
+NNN             | DIE
+
+#include <stdio.pvvs>
diff --git a/stdlib_tests/6007_printf_staticheapstring.pvvs b/stdlib_tests/6007_printf_staticheapstring.pvvs
new file mode 100644 (file)
index 0000000..5d9b7b1
--- /dev/null
@@ -0,0 +1,14 @@
+A"test"
+SSSTSSSSSN      | PUSH 32 (address)
+SSSTSSN         | PUSH 4 (count)
+NSTTTTTTN       | JSR > 11111 (spew)
+
+SSSTSSSSSN      | PUSH 32 (address)
+SSSSN           | PUSH 0 (string terminator)
+SSSSN           | PUSH 0 (number of substitutions)
+NSTTSSSN        | JSR > 1000 (printf)
+
+NNN             | DIE
+
+#include <heap.pvvs>
+#include <stdio.pvvs>
diff --git a/stdlib_tests/6008_printf_escapedstackstring.pvvs b/stdlib_tests/6008_printf_escapedstackstring.pvvs
new file mode 100644 (file)
index 0000000..721f943
--- /dev/null
@@ -0,0 +1,7 @@
+A"\\\%\t\n"
+SSSSN           | PUSH 0 (number of substitutions)
+NSTTSSSN        | JSR > 1000 (printf)
+
+NNN             | DIE
+
+#include <stdio.pvvs>
diff --git a/stdlib_tests/6009_printf_substitutedstackstring.pvvs b/stdlib_tests/6009_printf_substitutedstackstring.pvvs
new file mode 100644 (file)
index 0000000..4b1dbef
--- /dev/null
@@ -0,0 +1,20 @@
+@ First setup a string on the heap for use as a substitution.
+A"test"
+SSSTSSSSSN      | PUSH 32 (address)
+SSSTSSN         | PUSH 4 (count)
+NSTTTTTTN       | JSR > 11111 (spew)
+
+@ Now prepare arguments and call printf.
+A"%c%s%d%u%i"
+SSSTSTSTSN      | PUSH +42
+SSSTSTSTSN      | PUSH +42
+SSSTN           | PUSH +1
+SSSTSSSSSN      | PUSH +32 (address)
+SSSTSSSSSTN     | PUSH ASCII 'A'
+SSSTSTN         | PUSH 5 (number of substitutions)
+NSTTSSSN        | JSR > 1000 (printf)
+
+NNN             | DIE
+
+#include <heap.pvvs>
+#include <stdio.pvvs>
index d3420f1..bd6aeca 100755 (executable)
@@ -39,6 +39,15 @@ tests = [
         ['4001_strlen', '', '+11'],
         ['5001_abs', '', '+1+1+0+0'],
         ['5002_random', '', ''],
         ['4001_strlen', '', '+11'],
         ['5001_abs', '', '+1+1+0+0'],
         ['5002_random', '', ''],
+        ['6001_printstackstring', '', 'test'],
+        ['6002_printheapstring', '', 'test'],
+        ['6003_printnumbersign', '', '+-'],
+        ['6004_printnumbermagnitude', '', '323209223372036854775808'],
+        ['6005_printstacknumber', '', '+32-32+0-9223372036854775808'],
+        ['6006_printf_staticstackstring', '', 'test'],
+        ['6007_printf_staticheapstring', '', 'test'],
+        ['6008_printf_escapedstackstring', '', '\\%\t\n'],
+        ['6009_printf_substitutedstackstring', '', 'Atest142+42'],
         ] 
 
 for test in tests:
         ] 
 
 for test in tests: