|
|
@@ -22,14 +22,6 @@ public class ForthEvaluatorTest {
|
|
22
|
22
|
}
|
|
23
|
23
|
|
|
24
|
24
|
@Test
|
|
25
|
|
- public void testEmptyProgramResultsInEmptyStack() {
|
|
26
|
|
- assertEquals(
|
|
27
|
|
- Collections.emptyList(),
|
|
28
|
|
- forthEvaluator.evaluateProgram(Collections.emptyList()));
|
|
29
|
|
- }
|
|
30
|
|
-
|
|
31
|
|
- @Ignore("Remove to run test")
|
|
32
|
|
- @Test
|
|
33
|
25
|
public void testNumbersAreJustPushedOntoTheStack() {
|
|
34
|
26
|
assertEquals(
|
|
35
|
27
|
Arrays.asList(1, 2, 3, 4, 5),
|
|
|
@@ -175,18 +167,18 @@ public class ForthEvaluatorTest {
|
|
175
|
167
|
|
|
176
|
168
|
@Ignore("Remove to run test")
|
|
177
|
169
|
@Test
|
|
178
|
|
- public void testDupCopiesTheTopValueOnTheStack() {
|
|
|
170
|
+ public void testDupCopiesAValueOnTheStack() {
|
|
179
|
171
|
assertEquals(
|
|
180
|
172
|
Arrays.asList(1, 1),
|
|
181
|
|
- forthEvaluator.evaluateProgram(Collections.singletonList("1 DUP")));
|
|
|
173
|
+ forthEvaluator.evaluateProgram(Collections.singletonList("1 dup")));
|
|
182
|
174
|
}
|
|
183
|
175
|
|
|
184
|
176
|
@Ignore("Remove to run test")
|
|
185
|
177
|
@Test
|
|
186
|
|
- public void testDupParsingIsCaseInsensitive() {
|
|
|
178
|
+ public void testDupCopiesTopValueOnTheStack() {
|
|
187
|
179
|
assertEquals(
|
|
188
|
180
|
Arrays.asList(1, 2, 2),
|
|
189
|
|
- forthEvaluator.evaluateProgram(Collections.singletonList("1 2 Dup")));
|
|
|
181
|
+ forthEvaluator.evaluateProgram(Collections.singletonList("1 2 dup")));
|
|
190
|
182
|
}
|
|
191
|
183
|
|
|
192
|
184
|
@Ignore("Remove to run test")
|
|
|
@@ -349,4 +341,52 @@ public class ForthEvaluatorTest {
|
|
349
|
341
|
forthEvaluator.evaluateProgram(Collections.singletonList("foo"));
|
|
350
|
342
|
}
|
|
351
|
343
|
|
|
|
344
|
+ @Ignore("Remove to run test")
|
|
|
345
|
+ @Test
|
|
|
346
|
+ public void testDupIsCaseInsensitive() {
|
|
|
347
|
+ assertEquals(
|
|
|
348
|
+ Arrays.asList(1, 1, 1, 1),
|
|
|
349
|
+ forthEvaluator.evaluateProgram(Collections.singletonList("1 DUP Dup dup")));
|
|
|
350
|
+ }
|
|
|
351
|
+
|
|
|
352
|
+ @Ignore("Remove to run test")
|
|
|
353
|
+ @Test
|
|
|
354
|
+ public void testDropIsCaseInsensitive() {
|
|
|
355
|
+ assertEquals(
|
|
|
356
|
+ Arrays.asList(1),
|
|
|
357
|
+ forthEvaluator.evaluateProgram(Collections.singletonList("1 2 3 4 DROP Drop drop")));
|
|
|
358
|
+ }
|
|
|
359
|
+
|
|
|
360
|
+ @Ignore("Remove to run test")
|
|
|
361
|
+ @Test
|
|
|
362
|
+ public void testSwapIsCaseInsensitive() {
|
|
|
363
|
+ assertEquals(
|
|
|
364
|
+ Arrays.asList(2, 3, 4, 1),
|
|
|
365
|
+ forthEvaluator.evaluateProgram(Collections.singletonList("1 2 SWAP 3 Swap 4 swap")));
|
|
|
366
|
+ }
|
|
|
367
|
+
|
|
|
368
|
+ @Ignore("Remove to run test")
|
|
|
369
|
+ @Test
|
|
|
370
|
+ public void testOverIsCaseInsensitive() {
|
|
|
371
|
+ assertEquals(
|
|
|
372
|
+ Arrays.asList(1, 2, 1, 2, 1),
|
|
|
373
|
+ forthEvaluator.evaluateProgram(Collections.singletonList("1 2 OVER Over over")));
|
|
|
374
|
+ }
|
|
|
375
|
+
|
|
|
376
|
+ @Ignore("Remove to run test")
|
|
|
377
|
+ @Test
|
|
|
378
|
+ public void testUserDefinedWordsAreCaseInsensitive() {
|
|
|
379
|
+ assertEquals(
|
|
|
380
|
+ Arrays.asList(1, 1, 1, 1),
|
|
|
381
|
+ forthEvaluator.evaluateProgram(Arrays.asList(": foo dup ;", "1 FOO Foo foo")));
|
|
|
382
|
+ }
|
|
|
383
|
+
|
|
|
384
|
+ @Ignore("Remove to run test")
|
|
|
385
|
+ @Test
|
|
|
386
|
+ public void testDefinitionsAreCaseInsensitive() {
|
|
|
387
|
+ assertEquals(
|
|
|
388
|
+ Arrays.asList(1, 1, 1, 1),
|
|
|
389
|
+ forthEvaluator.evaluateProgram(Arrays.asList(": SWAP DUP Dup dup ;", "1 swap")));
|
|
|
390
|
+ }
|
|
|
391
|
+
|
|
352
|
392
|
}
|