@@ -40,82 +40,82 @@ class InterpreterSuite extends FunSuite {
40
40
}
41
41
42
42
test(" empty" ) {
43
- assertEquals(interpreter.execute (Nil ), context(Nil ))
43
+ assertEquals(interpreter.executeProgram (Nil ), context(Nil ))
44
44
}
45
45
46
46
test(" push items" ) {
47
- assertEquals(interpreter.execute (List (" foo" , " bar" )), context(List (" bar" , " foo" )))
47
+ assertEquals(interpreter.executeProgram (List (" foo" , " bar" )), context(List (" bar" , " foo" )))
48
48
}
49
49
50
50
test(" execute word" ) {
51
- assertEquals(interpreter.execute (List (" :push-foo" )), context(List (" foo" )))
51
+ assertEquals(interpreter.executeProgram (List (" :push-foo" )), context(List (" foo" )))
52
52
}
53
53
54
54
test(" overloaded word" ) {
55
- assertEquals(interpreter.execute (List (" :overloaded" )), context(List (" one" )))
55
+ assertEquals(interpreter.executeProgram (List (" :overloaded" )), context(List (" one" )))
56
56
}
57
57
58
58
test(" overloaded word and some don't match" ) {
59
- assertEquals(interpreter.execute (List (" :overloaded2" )), context(List (" two" )))
59
+ assertEquals(interpreter.executeProgram (List (" :overloaded2" )), context(List (" two" )))
60
60
}
61
61
62
62
test(" word with no matches" ) {
63
63
val e = intercept[IllegalStateException ] {
64
- interpreter.execute (List (" :no-match" ))
64
+ interpreter.executeProgram (List (" :no-match" ))
65
65
}
66
66
val expected = " no matches for word ':no-match' with stack [], candidates: [exception]"
67
67
assertEquals(e.getMessage, expected)
68
68
}
69
69
70
70
test(" using unstable word fails by default" ) {
71
71
val e = intercept[IllegalStateException ] {
72
- interpreter.execute (List (" :unstable" ))
72
+ interpreter.executeProgram (List (" :unstable" ))
73
73
}
74
74
val expected = " to use :unstable enable unstable features"
75
75
assertEquals(e.getMessage, expected)
76
76
}
77
77
78
78
test(" unknown word" ) {
79
79
val e = intercept[IllegalStateException ] {
80
- interpreter.execute (List (" foo" , " :unknown" ))
80
+ interpreter.executeProgram (List (" foo" , " :unknown" ))
81
81
}
82
82
assertEquals(e.getMessage, " unknown word ':unknown'" )
83
83
}
84
84
85
85
test(" unmatched closing paren" ) {
86
86
val e = intercept[IllegalStateException ] {
87
- interpreter.execute (List (" )" ))
87
+ interpreter.executeProgram (List (" )" ))
88
88
}
89
89
assertEquals(e.getMessage, " unmatched closing parenthesis" )
90
90
}
91
91
92
92
test(" unmatched closing paren 2" ) {
93
93
val e = intercept[IllegalStateException ] {
94
- interpreter.execute (List (" (" , " )" , " )" ))
94
+ interpreter.executeProgram (List (" (" , " )" , " )" ))
95
95
}
96
96
assertEquals(e.getMessage, " unmatched closing parenthesis" )
97
97
}
98
98
99
99
test(" unmatched opening paren" ) {
100
100
val e = intercept[IllegalStateException ] {
101
- interpreter.execute (List (" (" ))
101
+ interpreter.executeProgram (List (" (" ))
102
102
}
103
103
assertEquals(e.getMessage, " unmatched opening parenthesis" )
104
104
}
105
105
106
106
test(" list" ) {
107
107
val list = List (" (" , " 1" , " )" )
108
- assertEquals(interpreter.execute (list), context(List (List (" 1" ))))
108
+ assertEquals(interpreter.executeProgram (list), context(List (List (" 1" ))))
109
109
}
110
110
111
111
test(" nested list" ) {
112
112
val list = List (" (" , " 1" , " (" , " )" , " )" )
113
- assertEquals(interpreter.execute (list), context(List (List (" 1" , " (" , " )" ))))
113
+ assertEquals(interpreter.executeProgram (list), context(List (List (" 1" , " (" , " )" ))))
114
114
}
115
115
116
116
test(" multiple lists" ) {
117
117
val list = List (" (" , " 1" , " )" , " (" , " 2" , " )" )
118
- assertEquals(interpreter.execute (list), context(List (List (" 2" ), List (" 1" ))))
118
+ assertEquals(interpreter.executeProgram (list), context(List (List (" 2" ), List (" 1" ))))
119
119
}
120
120
121
121
test(" debug" ) {
0 commit comments