git @ Cat's Eye Technologies PL-GOTO.NET / 1dd3be4
Modernize test suite. --HG-- rename : PLexceptGOTOdotNET.falderal => PLexceptGOTOdotNET.markdown Cat's Eye Technologies 8 years ago
3 changed file(s) with 100 addition(s) and 96 deletion(s). Raw diff Collapse all Expand all
+0
-89
PLexceptGOTOdotNET.falderal 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)
0 Test Suite for PL-{GOTO}.NET
1 ============================
2
3 This test suite is written in the format of Falderal 0.7. It is far from
4 exhaustive, but provides a basic sanity check that the language we've
5 implemented comes close to PL-{GOTO}.
6
7 PL-{GOTO} Parsing
8 -----------------
9
10 -> Tests for functionality "Parse PL-{GOTO} Program"
11
12 -> Functionality "Parse PL-{GOTO} Program" is implemented by
13 -> shell command
14 -> "ghc -e "do c <- readFile \"%(test-file)\"; putStrLn $ PLexceptGOTOdotNET.pa c" PLexceptGOTOdotNET.lhs"
15
16 | n ← 0;
17 = Block [AssignZero "n"]
18
19 | n ← m;
20 = Block [AssignOther "n" "m"]
21
22 | n ← n + 1;
23 = Block [AssignIncr "n" "n"]
24
25 | n ← 0; LOOP n; m ← n; END;
26 = Block [AssignZero "n",Loop 0 "n" (Block [AssignOther "m" "n"])]
27
28 | n ← 0; m ← 0;
29 | LOOP n;
30 | m ← n + 1;
31 | END;
32 = Block [AssignZero "n",AssignZero "m",Loop 0 "n" (Block [AssignIncr "m" "n"])]
33
34 It's perfectly valid to have variables called LOOP and END.
35
36 | LOOP ← 0; LOOP LOOP; LOOP ← LOOP + 1; END;
37 = Block [AssignZero "LOOP",Loop 0 "LOOP" (Block [AssignIncr "LOOP" "LOOP"])]
38
39 | END ← 0; LOOP END; END ← END + 1; END;
40 = Block [AssignZero "END",Loop 0 "END" (Block [AssignIncr "END" "END"])]
41
42 PL-{GOTO} Evaluation
43 --------------------
44
45 -> Tests for functionality "Evaluate PL-{GOTO} Program"
46
47 -> Functionality "Evaluate PL-{GOTO} Program" is implemented by
48 -> shell command
49 -> "ghc -e "do c <- readFile \"%(test-file)\"; putStrLn $ PLexceptGOTOdotNET.run c" PLexceptGOTOdotNET.lhs"
50
51 | n ← 0;
52 = [("n",0)]
53
54 | n ← 0; LOOP n; m ← n; END;
55 = [("n",0)]
56
57 | n ← 0; n ← n + 1; LOOP n; m ← n; END;
58 = [("m",1),("n",1)]
59
60 | m ← 0; n ← 0; n ← n + 1; n ← n + 1; LOOP n; m ← m + 1; END;
61 = [("m",2),("n",2)]
62
63 | n ← 0; n ← n + 1; n ← n + 1; n ← n + 1; n ← n + 1;
64 | m ← 0; k ← 0;
65 | LOOP n;
66 | m ← m + 1;
67 | LOOP m;
68 | k ← k + 1;
69 | END;
70 | END;
71 = [("k",10),("m",4),("n",4)]
72
73 Changing the value of a loop variable inside the loop does not change
74 the number of times the loop executes.
75
76 | n ← 0; n ← n + 1; n ← n + 1; n ← n + 1; n ← n + 1;
77 | m ← 0;
78 | LOOP n;
79 | n ← 0; n ← n + 1;
80 | m ← m + 1;
81 | END;
82 = [("m",4),("n",1)]
83
84 Loop Labeling
85 -------------
86
87 -> Tests for functionality "Label PL-{GOTO} Loops"
88
89 -> Functionality "Label PL-{GOTO} Loops" is implemented by
90 -> shell command
91 -> "ghc -e "do c <- readFile \"%(test-file)\"; putStrLn $ PLexceptGOTOdotNET.testLoopLabeling c" PLexceptGOTOdotNET.lhs"
92
93 | n ← 0; m ← 0; LOOP n;
94 | LOOP m;
95 | n ← 0;
96 | END;
97 | END;
98 = (Block [AssignZero "n",AssignZero "m",Loop 1 "n" (Block [Loop 0 "m" (Block [AssignZero "n"])])],2)
00 #!/bin/sh
11
2 # This assumes Falderal 0.4 is installed. The easiest way to do this
3 # currently is to install it as a local Cabal package:
4 # $ hg clone https://bitbucket.org/catseye/falderal
5 # $ cd falderal
6 # $ ./install.sh
7
8 falderal test PLexceptGOTOdotNET.falderal
2 falderal test PLexceptGOTOdotNET.markdown