git @ Cat's Eye Technologies PL-GOTO.NET / df00fe7
The tests are fully in Falderal format now, so rename the file. --HG-- rename : Tests.lhs => PLexceptGOTOdotNET.falderal Chris Pressey 8 years ago
3 changed file(s) with 90 addition(s) and 90 deletion(s). Raw diff Collapse all Expand all
0 encoding: UTF-8
1
2 Test Suite for PL-{GOTO}.NET
3 ============================
4
5 This test suite is written in the format of Falderal 0.3. It is far from
6 exhaustive, but provides a basic sanity check that the language we've
7 implemented comes close to PL-{GOTO}.
8
9 PL-{GOTO} Parsing
10 -----------------
11
12 -> Tests for Haskell function PLexceptGOTOdotNET:pa
13
14 | n ← 0;
15 = Block [AssignZero "n"]
16
17 | n ← m;
18 = Block [AssignOther "n" "m"]
19
20 | n ← n + 1;
21 = Block [AssignIncr "n" "n"]
22
23 | n ← 0; LOOP n; m ← n; END;
24 = Block [AssignZero "n",Loop 0 "n" (Block [AssignOther "m" "n"])]
25
26 | n ← 0; m ← 0;
27 | LOOP n;
28 | m ← n + 1;
29 | END;
30 = Block [AssignZero "n",AssignZero "m",Loop 0 "n" (Block [AssignIncr "m" "n"])]
31
32 It's perfectly valid to have variables called LOOP and END.
33
34 | LOOP ← 0; LOOP LOOP; LOOP ← LOOP + 1; END;
35 = Block [AssignZero "LOOP",Loop 0 "LOOP" (Block [AssignIncr "LOOP" "LOOP"])]
36
37 | END ← 0; LOOP END; END ← END + 1; END;
38 = Block [AssignZero "END",Loop 0 "END" (Block [AssignIncr "END" "END"])]
39
40 PL-{GOTO} Evaluation
41 --------------------
42
43 -> Tests for Haskell function PLexceptGOTOdotNET:run
44
45 | n ← 0;
46 = [("n",0)]
47
48 | n ← 0; LOOP n; m ← n; END;
49 = [("n",0)]
50
51 | n ← 0; n ← n + 1; LOOP n; m ← n; END;
52 = [("m",1),("n",1)]
53
54 | m ← 0; n ← 0; n ← n + 1; n ← n + 1; LOOP n; m ← m + 1; END;
55 = [("m",2),("n",2)]
56
57 | n ← 0; n ← n + 1; n ← n + 1; n ← n + 1; n ← n + 1;
58 | m ← 0; k ← 0;
59 | LOOP n;
60 | m ← m + 1;
61 | LOOP m;
62 | k ← k + 1;
63 | END;
64 | END;
65 = [("k",10),("m",4),("n",4)]
66
67 Changing the value of a loop variable inside the loop does not change
68 the number of times the loop executes.
69
70 | n ← 0; n ← n + 1; n ← n + 1; n ← n + 1; n ← n + 1;
71 | m ← 0;
72 | LOOP n;
73 | n ← 0; n ← n + 1;
74 | m ← m + 1;
75 | END;
76 = [("m",4),("n",1)]
77
78 Loop Labeling
79 -------------
80
81 -> Tests for Haskell function PLexceptGOTOdotNET:testLoopLabeling
82
83 | n ← 0; m ← 0; LOOP n;
84 | LOOP m;
85 | n ← 0;
86 | END;
87 | END;
88 = (Block [AssignZero "n",AssignZero "m",Loop 1 "n" (Block [Loop 0 "m" (Block [AssignZero "n"])])],2)
+0
-89
Tests.lhs less more
0 encoding: UTF-8
1
2 Test Suite for PL-{GOTO}.NET
3 ============================
4
5 This test suite is written in the format of Falderal 0.3. It is far from
6 exhaustive, but provides a basic sanity check that the language we've
7 implemented comes close to PL-{GOTO}.
8
9 PL-{GOTO} Parsing
10 -----------------
11
12 -> Tests for Haskell function PLexceptGOTOdotNET:pa
13
14 | n ← 0;
15 = Block [AssignZero "n"]
16
17 | n ← m;
18 = Block [AssignOther "n" "m"]
19
20 | n ← n + 1;
21 = Block [AssignIncr "n" "n"]
22
23 | n ← 0; LOOP n; m ← n; END;
24 = Block [AssignZero "n",Loop 0 "n" (Block [AssignOther "m" "n"])]
25
26 | n ← 0; m ← 0;
27 | LOOP n;
28 | m ← n + 1;
29 | END;
30 = Block [AssignZero "n",AssignZero "m",Loop 0 "n" (Block [AssignIncr "m" "n"])]
31
32 It's perfectly valid to have variables called LOOP and END.
33
34 | LOOP ← 0; LOOP LOOP; LOOP ← LOOP + 1; END;
35 = Block [AssignZero "LOOP",Loop 0 "LOOP" (Block [AssignIncr "LOOP" "LOOP"])]
36
37 | END ← 0; LOOP END; END ← END + 1; END;
38 = Block [AssignZero "END",Loop 0 "END" (Block [AssignIncr "END" "END"])]
39
40 PL-{GOTO} Evaluation
41 --------------------
42
43 -> Tests for Haskell function PLexceptGOTOdotNET:run
44
45 | n ← 0;
46 = [("n",0)]
47
48 | n ← 0; LOOP n; m ← n; END;
49 = [("n",0)]
50
51 | n ← 0; n ← n + 1; LOOP n; m ← n; END;
52 = [("m",1),("n",1)]
53
54 | m ← 0; n ← 0; n ← n + 1; n ← n + 1; LOOP n; m ← m + 1; END;
55 = [("m",2),("n",2)]
56
57 | n ← 0; n ← n + 1; n ← n + 1; n ← n + 1; n ← n + 1;
58 | m ← 0; k ← 0;
59 | LOOP n;
60 | m ← m + 1;
61 | LOOP m;
62 | k ← k + 1;
63 | END;
64 | END;
65 = [("k",10),("m",4),("n",4)]
66
67 Changing the value of a loop variable inside the loop does not change
68 the number of times the loop executes.
69
70 | n ← 0; n ← n + 1; n ← n + 1; n ← n + 1; n ← n + 1;
71 | m ← 0;
72 | LOOP n;
73 | n ← 0; n ← n + 1;
74 | m ← m + 1;
75 | END;
76 = [("m",4),("n",1)]
77
78 Loop Labeling
79 -------------
80
81 -> Tests for Haskell function PLexceptGOTOdotNET:testLoopLabeling
82
83 | n ← 0; m ← 0; LOOP n;
84 | LOOP m;
85 | n ← 0;
86 | END;
87 | END;
88 = (Block [AssignZero "n",AssignZero "m",Loop 1 "n" (Block [Loop 0 "m" (Block [AssignZero "n"])])],2)
11 if [ "${FALDERAL}x" = "x" ]; then
22 FALDERAL=../falderal/
33 fi
4 ghc -i$FALDERAL $FALDERAL/Test/Falderal/Driver.hs -e 'format "haskell" "Tests.lhs"' > GeneratedFalderalTests.hs
4 ghc -i$FALDERAL $FALDERAL/Test/Falderal/Driver.hs -e 'format "haskell" "PLexceptGOTOdotNET.falderal"' > GeneratedFalderalTests.hs
55 ghc -i$FALDERAL GeneratedFalderalTests.hs -e testModule