Added basic tests for stack and arithmetic IMPs.
authorAaron Taylor <ataylor@subgeniuskitty.com>
Thu, 4 Jul 2019 22:37:06 +0000 (15:37 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Thu, 4 Jul 2019 22:37:06 +0000 (15:37 -0700)
12 files changed:
Makefile
tests/1001_stack_operations.pvvs [deleted file]
tests/1001_stack_push.pvvs [new file with mode: 0644]
tests/1002_stack_dup.pvvs [new file with mode: 0644]
tests/1003_stack_swap.pvvs [new file with mode: 0644]
tests/1004_stack_drop.pvvs [new file with mode: 0644]
tests/2001_arithmetic_addition.pvvs [new file with mode: 0644]
tests/2002_arithmetic_subtraction.pvvs [new file with mode: 0644]
tests/2003_arithmetic_multiplication.pvvs [new file with mode: 0644]
tests/2004_arithmetic_division.pvvs [new file with mode: 0644]
tests/2005_arithmetic_remainder.pvvs [new file with mode: 0644]
vv_test.py

index 6759c97..1412ac5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ vvc:
        $(CC) $(CC_FLAGS) -o $@ vv_compiler.c
 
 test: all
-       @echo "Starting test suite..."
+       @echo "Starting test suite:"
        @./vv_test.py
 
 clean:
diff --git a/tests/1001_stack_operations.pvvs b/tests/1001_stack_operations.pvvs
deleted file mode 100644 (file)
index d8333e4..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# This test verifies operations under the Stack IMP ([Space]).
-
-SSSTSSSSSTN     | ST: Push +65 (ASCII A)
-SSSTSSSSTSN     | ST: Push +66 (ASCII B)
-SNS             | ST: Duplicate TOS
-TNSS            | IO: Output character
-SNT             | ST: Swap TOS and NOS
-SNN             | ST: Discard TOS
-TNSS            | IO: Output character
-NNN             | FC: Terminate program
diff --git a/tests/1001_stack_push.pvvs b/tests/1001_stack_push.pvvs
new file mode 100644 (file)
index 0000000..234d4c7
--- /dev/null
@@ -0,0 +1,5 @@
+# This test verifies stack IMP push.
+
+SSSTSSSSSTN     | ST: Push +65 (ASCII A)
+TNSS            | IO: Output character
+NNN             | FC: Terminate program
diff --git a/tests/1002_stack_dup.pvvs b/tests/1002_stack_dup.pvvs
new file mode 100644 (file)
index 0000000..f405eeb
--- /dev/null
@@ -0,0 +1,7 @@
+# This test verifies stack IMP duplicate.
+
+SSSTSSSSSTN     | ST: Push +65 (ASCII A)
+SNS             | ST: Duplicate TOS
+TNSS            | IO: Output character
+TNSS            | IO: Output character
+NNN             | FC: Terminate program
diff --git a/tests/1003_stack_swap.pvvs b/tests/1003_stack_swap.pvvs
new file mode 100644 (file)
index 0000000..9e18a9f
--- /dev/null
@@ -0,0 +1,8 @@
+# This test verifies stack IMP swap.
+
+SSSTSSSSSTN     | ST: Push +65 (ASCII A)
+SSSTSSSSTSN     | ST: Push +66 (ASCII B)
+SNT             | ST: Swap TOS and NOS
+TNSS            | IO: Output character
+TNSS            | IO: Output character
+NNN             | FC: Terminate program
diff --git a/tests/1004_stack_drop.pvvs b/tests/1004_stack_drop.pvvs
new file mode 100644 (file)
index 0000000..55dd6b6
--- /dev/null
@@ -0,0 +1,7 @@
+# This test verifies stack IMP drop.
+
+SSSTSSSSSTN     | ST: Push +65 (ASCII A)
+SSSTSSSSTSN     | ST: Push +66 (ASCII B)
+SNN             | ST: Discard TOS
+TNSS            | IO: Output character
+NNN             | FC: Terminate program
diff --git a/tests/2001_arithmetic_addition.pvvs b/tests/2001_arithmetic_addition.pvvs
new file mode 100644 (file)
index 0000000..40b3c82
--- /dev/null
@@ -0,0 +1,7 @@
+# This test verifies arithmetic IMP addition.
+
+SSSTSSSSSTN     | ST: Push +65 (ASCII A)
+SSSTN           | ST: Push +1
+TSSS            | MA: Add
+TNSS            | IO: Output character
+NNN             | FC: Terminate program
diff --git a/tests/2002_arithmetic_subtraction.pvvs b/tests/2002_arithmetic_subtraction.pvvs
new file mode 100644 (file)
index 0000000..574e6e1
--- /dev/null
@@ -0,0 +1,7 @@
+# This test verifies arithmetic IMP subtraction.
+
+SSSTSSSSTSN     | ST: Push +66 (ASCII B)
+SSSTN           | ST: Push +1
+TSST            | MA: Subtract
+TNSS            | IO: Output character
+NNN             | FC: Terminate program
diff --git a/tests/2003_arithmetic_multiplication.pvvs b/tests/2003_arithmetic_multiplication.pvvs
new file mode 100644 (file)
index 0000000..7aa1c7c
--- /dev/null
@@ -0,0 +1,7 @@
+# This test verifies arithmetic IMP multiplication.
+
+SSSTSSSSTN      | ST: Push +33
+SSSTSN          | ST: Push +2
+TSSN            | MA: Multiply
+TNSS            | IO: Output character
+NNN             | FC: Terminate program
diff --git a/tests/2004_arithmetic_division.pvvs b/tests/2004_arithmetic_division.pvvs
new file mode 100644 (file)
index 0000000..a21f5af
--- /dev/null
@@ -0,0 +1,7 @@
+# This test verifies arithmetic IMP division.
+
+SSSTSSSSSTSN    | ST: Push +130
+SSSTSN          | ST: Push +2
+TSTS            | MA: Divide
+TNSS            | IO: Output character
+NNN             | FC: Terminate program
diff --git a/tests/2005_arithmetic_remainder.pvvs b/tests/2005_arithmetic_remainder.pvvs
new file mode 100644 (file)
index 0000000..d54c381
--- /dev/null
@@ -0,0 +1,7 @@
+# This test verifies arithmetic IMP remainder.
+
+SSSTTSSSSTSN    | ST: Push +194
+SSSTSSSSSSTN    | ST: Push +128
+TSTT            | MA: Remainder
+TNSS            | IO: Output character
+NNN             | FC: Terminate program
index 46f5bc9..4a31280 100755 (executable)
@@ -15,16 +15,25 @@ src_extension = '.pvvs'
 
 tests = [
         ['0001_push_printchar_exit', 'A'],
-        ['1001_stack_operations', 'BB']
+        ['1001_stack_push', 'A'],
+        ['1002_stack_dup', 'AA'],
+        ['1003_stack_swap', 'AB'],
+        ['1004_stack_drop', 'A'],
+        ['2001_arithmetic_addition', 'B'],
+        ['2002_arithmetic_subtraction', 'A'],
+        ['2003_arithmetic_multiplication', 'B'],
+        ['2004_arithmetic_division', 'A'],
+        ['2005_arithmetic_remainder', 'A'],
         ] 
 
 for test in tests:
+    # TODO: Catch stderr
     subprocess.run([compiler_path, '-i', path_to_tests + test[0] + src_extension, '-o', temp_file])
     result = subprocess.run([interpreter_path, '-i', temp_file], stdout=subprocess.PIPE)
     if result.stdout.decode('utf-8') != test[1]:
-        print(test[0])
+        print('\n' + test[0])
     else:
-        print('.', end='')
+        print('.', end='', flush=True)
     os.remove(temp_file)
 
 print("")