Anonymous avatar Anonymous committed 23c9287

Update imports for newer Haskell, tests for newer Falderal.

Comments (0)

Files changed (5)

 -- ============================== Main ============================= --
 -----------------------------------------------------------------------
 
-import System
+import System.Environment
 
 import Map
 import AST
 
 module Scanner where
 
-import Char
+import Data.Char
 
 data Token = Ident String
            | IntLit Integer
 #!/bin/sh
 
-# This assumes Falderal 0.4 is installed.  The easiest way to do this is to
-# install it as a Cabal package:
-#   $ hg clone https://bitbucket.org/catseye/falderal
-#   $ cd falderal
-#   $ cabal install --prefix=$HOME --user
-
 cd src && make iphi && cd ..
-falderal test standard tests/Iphigeneia.falderal && echo "All tests passed!"
+falderal test tests/Iphigeneia.markdown && echo "All tests passed!"
 rm -f foo.txt
-cd src && make clean && cd ..
+#cd src && make clean && cd ..

tests/Iphigeneia.falderal

-Test Suite for Iphigeneia
-=========================
-
--> Functionality "Interpret Iphigeneia program" is implemented by
--> shell command "(cat >foo.txt && src/iphi foo.txt)"
-
--> Tests for functionality "Interpret Iphigeneia program"
-
-Test 'var ... in ...' and assignment.
-
-| var k in k := 5
-= k=5
-
-Test 'begin ... end'.
-
-| var k in begin
-|     k := 5;
-|     k := k + 1
-| end
-= k=6
-
-Test nested 'var ... in ...' and arithmetic operators.
-
-| var i in var j in var k in begin
-|     i := 2;
-|     j := 3;
-|     k := i + j;   (*  5 *)
-|     i := j * k;   (* 15 *)
-|     j := i / 2;   (*  7 *)
-|     j := j - 1    (*  6 *)
-| end
-= j=6
-= i=15
-= k=5
-
-Test 'if ... then ... else' command with negative result.
-
-| var i in var j in begin
-|     i := 2;
-|     if i > 4 then
-|       j := i * 2
-|     else
-|       j := i + 1
-| end
-= j=3
-= i=2
-
-Test 'if ... then ... else' command with positive result.
-
-| var i in var j in begin
-|     i := 2;
-|     j := 1;
-|     if i < 4 & j = 1 then
-|       j := i * 6
-|     else
-|       j := i + 1
-| end
-= j=12
-= i=2
-
-Test 'while ... do ...'.
-
-| var i in var j in begin
-|     i := 100;
-|     j := 0;
-|     while i > 0 do begin
-|         j := j + i;
-|         i := i - 1
-|     end
-| end
-= i=0
-= j=5050
-
-Test 'while ... do ...'.
-
-| var a in var b in var c in
-| begin
-|     a := 10;
-|     b := 1;
-|     c := 2;
-|     while a > 0 do
-|         begin
-|             b := b * c;
-|             c := c + b;
-|             a := a - 1
-|         end
-| end
-= a=0
-= c=140982598893793678070294688422804665931354981644880911847733136248186424030732278900819020480668973702640170212905160639132296847654374706155245147715674612235227680384069415566749494180212370357849936526549755341591854042821940420766722160615645816921368300
-= b=140982598893793678070294688422804665931354981644880911847733136248186424030732278900819020480668973702640170212905160639132296847278898210361175931159590631877400396153764977561991761037132722898953457959352992281368361865140291306311370294857131871923863552
-
-Test 'if ... then ... else' expression with negative result.
-
-| var a in var b in var c in
-| begin
-|     a := 10;
-|     b := 2;
-|     c := if a > 20 then a - b else a / b
-| end
-= c=5
-= b=2
-= a=10
-
-Test 'if ... then ... else' expression with positive result.
-
-| var a in var b in var c in
-| begin
-|     a := 10;
-|     b := 2;
-|     c := if a < 20 then a - b else a / b
-| end
-= c=8
-= b=2
-= a=10
-
-Test 'let ... in ...'.
-
-| var a in a := let b = 7 in 10 - b;
-= a=3
-
-Test 'valueof ... in ...'.
-
-| var a in var b in begin
-|     a := 10;
-|     b := valueof c in begin
-|         c := a * 2
-|     end + 7
-| end
-= b=27
-= a=10
-
-Test that 'var ... in ...' does not shadow.
-
-| var a in var b in
-| begin
-|     a := 1;
-|     b := 2;
-|     var a in
-|         a := 3
-| end
-= ["Variable a already declared"]
-
-Test that 'let ... in ...' does shadow.
-
-| var a in var b in
-| begin
-|     a := 2;
-|     b := 3;
-|     a := let b = 7 in a * b
-| end
-= a=14
-= b=3
-
-Test 'loop ...' and 'repeat'.
-
-| var a in a :=
-|     let c = 5 in let d = 1 in
-|         loop
-|             if c = 0 then
-|                 d
-|             else
-|                 let d = d * c in
-|                     let c = c - 1 in
-|                         repeat
-= a=120

tests/Iphigeneia.markdown

+Test Suite for Iphigeneia
+=========================
+
+This test suite is in the format of Falderal version 0.7.
+
+    -> Functionality "Interpret Iphigeneia program" is implemented by
+    -> shell command "(cat >foo.txt && src/iphi foo.txt)"
+
+    -> Tests for functionality "Interpret Iphigeneia program"
+
+Test 'var ... in ...' and assignment.
+
+    | var k in k := 5
+    = k=5
+
+Test 'begin ... end'.
+
+    | var k in begin
+    |     k := 5;
+    |     k := k + 1
+    | end
+    = k=6
+
+Test nested 'var ... in ...' and arithmetic operators.
+
+    | var i in var j in var k in begin
+    |     i := 2;
+    |     j := 3;
+    |     k := i + j;   (*  5 *)
+    |     i := j * k;   (* 15 *)
+    |     j := i / 2;   (*  7 *)
+    |     j := j - 1    (*  6 *)
+    | end
+    = j=6
+    = i=15
+    = k=5
+
+Test 'if ... then ... else' command with negative result.
+
+    | var i in var j in begin
+    |     i := 2;
+    |     if i > 4 then
+    |       j := i * 2
+    |     else
+    |       j := i + 1
+    | end
+    = j=3
+    = i=2
+
+Test 'if ... then ... else' command with positive result.
+
+    | var i in var j in begin
+    |     i := 2;
+    |     j := 1;
+    |     if i < 4 & j = 1 then
+    |       j := i * 6
+    |     else
+    |       j := i + 1
+    | end
+    = j=12
+    = i=2
+
+Test 'while ... do ...'.
+
+    | var i in var j in begin
+    |     i := 100;
+    |     j := 0;
+    |     while i > 0 do begin
+    |         j := j + i;
+    |         i := i - 1
+    |     end
+    | end
+    = i=0
+    = j=5050
+
+Test 'while ... do ...'.
+
+    | var a in var b in var c in
+    | begin
+    |     a := 10;
+    |     b := 1;
+    |     c := 2;
+    |     while a > 0 do
+    |         begin
+    |             b := b * c;
+    |             c := c + b;
+    |             a := a - 1
+    |         end
+    | end
+    = a=0
+    = c=140982598893793678070294688422804665931354981644880911847733136248186424030732278900819020480668973702640170212905160639132296847654374706155245147715674612235227680384069415566749494180212370357849936526549755341591854042821940420766722160615645816921368300
+    = b=140982598893793678070294688422804665931354981644880911847733136248186424030732278900819020480668973702640170212905160639132296847278898210361175931159590631877400396153764977561991761037132722898953457959352992281368361865140291306311370294857131871923863552
+
+Test 'if ... then ... else' expression with negative result.
+
+    | var a in var b in var c in
+    | begin
+    |     a := 10;
+    |     b := 2;
+    |     c := if a > 20 then a - b else a / b
+    | end
+    = c=5
+    = b=2
+    = a=10
+
+Test 'if ... then ... else' expression with positive result.
+
+    | var a in var b in var c in
+    | begin
+    |     a := 10;
+    |     b := 2;
+    |     c := if a < 20 then a - b else a / b
+    | end
+    = c=8
+    = b=2
+    = a=10
+
+Test 'let ... in ...'.
+
+    | var a in a := let b = 7 in 10 - b;
+    = a=3
+
+Test 'valueof ... in ...'.
+
+    | var a in var b in begin
+    |     a := 10;
+    |     b := valueof c in begin
+    |         c := a * 2
+    |     end + 7
+    | end
+    = b=27
+    = a=10
+
+Test that 'var ... in ...' does not shadow.
+
+    | var a in var b in
+    | begin
+    |     a := 1;
+    |     b := 2;
+    |     var a in
+    |         a := 3
+    | end
+    = ["Variable a already declared"]
+
+Test that 'let ... in ...' does shadow.
+
+    | var a in var b in
+    | begin
+    |     a := 2;
+    |     b := 3;
+    |     a := let b = 7 in a * b
+    | end
+    = a=14
+    = b=3
+
+Test 'loop ...' and 'repeat'.
+
+    | var a in a :=
+    |     let c = 5 in let d = 1 in
+    |         loop
+    |             if c = 0 then
+    |                 d
+    |             else
+    |                 let d = d * c in
+    |                     let c = c - 1 in
+    |                         repeat
+    = a=120
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.