updated python scripts to be true python not iron python. Added Makefile to run 3...
authorMichael Welch <michaelgwelch@gmail.com>
Thu, 1 Feb 2007 03:18:59 +0000 (03:18 +0000)
committerMichael Welch <michaelgwelch@gmail.com>
Thu, 1 Feb 2007 03:18:59 +0000 (03:18 +0000)
samples/Makefile [new file with mode: 0644]
samples/testCore.py [new file with mode: 0644]
samples/testData.py
samples/testPrint.mbas [deleted file]
samples/testPrint.py
samples/testRead.py

diff --git a/samples/Makefile b/samples/Makefile
new file mode 100644 (file)
index 0000000..8633733
--- /dev/null
@@ -0,0 +1,20 @@
+MONO := mono
+MBASIC := $(MONO) ../bin/mbasic.exe
+
+.PHONY: all
+all: printTest readTest dataTest
+
+.PHONY: printTest
+printTest: print.mbas testPrint.py
+       $(MBASIC) print.mbas
+       $(MONO) print.exe | ./testPrint.py
+
+.PHONY: readTest
+readTest: read.mbas testRead.py
+       $(MBASIC) read.mbas
+       $(MONO) read.exe | ./testRead.py
+
+.PHONY: dataTest
+dataTest: data.mbas testData.py
+       $(MBASIC) data.mbas
+       $(MONO) data.exe | ./testData.py
diff --git a/samples/testCore.py b/samples/testCore.py
new file mode 100644 (file)
index 0000000..2569b0e
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+lineNumber = 0
+def assertEquals(x):
+       global lineNumber
+       lineNumber = lineNumber + 1
+       input = raw_input()
+       if (x == input): return
+       print "Line %d: '%s' != '%s'" % (lineNumber,x,input)
+
index 1f5521f..74c99fa 100644 (file)
@@ -1,13 +1,12 @@
-import clr
-from System import *
-
+#!/usr/bin/env python
+from testCore import assertEquals
 lineNumber = 0
 def assertEquals(x):
        global lineNumber
        lineNumber = lineNumber + 1
-       input = Console.ReadLine()
-       if x.Equals(input): return
-       Console.WriteLine("Line {0}: '{1}' != '{2}'",lineNumber,x,input)
+       input = raw_input()
+       if (x == input): return
+       print "Line %d: '%s' != '%s'" % (lineNumber,x,input)
 # Page II-63
 assertEquals(" 2  4 ")
 assertEquals(" 6  7 ")
diff --git a/samples/testPrint.mbas b/samples/testPrint.mbas
deleted file mode 100644 (file)
index 5c04211..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-\r
-100 expected$ = " 10  20 "\r
-110 gosub 1000\r
-\r
-1000 REM Subroutine Assert Equals( expected$, actual$ )\r
-l1005 lineNumber = lineNumber + 1\r
-1007 input actual$\r
-1010 if expected$ = actual$ then 1030\r
-1020 print "Line";lineNumber;":";expected$;"<>";actual$\r
-1030 return\r
-\r
-1040 end
\ No newline at end of file
index cf9d054..46390ee 100755 (executable)
@@ -1,26 +1,13 @@
-import clr
-from System import *
-
-lineNumber = 0
-def assertEquals(x):
-       global lineNumber
-       lineNumber = lineNumber + 1
-       input = Console.ReadLine()
-       if x.Equals(input): return
-       Console.WriteLine("Line {0}: '{1}' != '{2}'",lineNumber,x,input)
+#!/usr/bin/env python
+from testCore import assertEquals
 
+# Scenarios from II-65
 assertEquals(" 10  20 ")
-
 assertEquals("TI COMPUTER")
-
 assertEquals("HELLO, FRIEND")
-
 assertEquals("HIJOAN")
-
 assertEquals("HI JOAN")
-
 assertEquals("HELLO JOAN")
-
 assertEquals(" 10.2 -30.5  16.7 ")
 assertEquals("-20.3 ")
 
@@ -75,4 +62,3 @@ assertEquals(" 75 ");
 assertEquals("HELLO");
 assertEquals("TO PRINT \"QUOTE MARKS\" YOU M")
 assertEquals("UST USE DOUBLE QUOTES.")
-Console.WriteLine("done")
index 94f16c4..a8e8404 100644 (file)
@@ -1,13 +1,5 @@
-import clr
-from System import *
-
-lineNumber = 0
-def assertEquals(x):
-       global lineNumber
-       lineNumber = lineNumber + 1
-       input = Console.ReadLine()
-       if x.Equals(input): return
-       Console.WriteLine("Line {0}: '{1}' != '{2}'",lineNumber,x,input)
+#!/usr/bin/env python
+from testCore import assertEquals
 # Page II-61
 assertEquals(" 22  15 ")
 assertEquals(" 36  52 ")
@@ -16,5 +8,4 @@ assertEquals(" 48  96.5 ")
 assertEquals(" 2  4  6  8  10  12  14  16 ")
 assertEquals(" 12  14  16  18  20  22  24 ")
 assertEquals(" 26 ")
-Console.WriteLine("done")