Browse Source

Merge pull request #1198 from sjwarner-bp/forth-update

forth: update tests suite to 1.4.0
FridaTveit 8 years ago
parent
commit
7c13971dd6
No account linked to committer's email
2 changed files with 53 additions and 13 deletions
  1. 1
    1
      exercises/forth/.meta/version
  2. 52
    12
      exercises/forth/src/test/java/ForthEvaluatorTest.java

+ 1
- 1
exercises/forth/.meta/version View File

@@ -1 +1 @@
1
-1.2.0
1
+1.4.0

+ 52
- 12
exercises/forth/src/test/java/ForthEvaluatorTest.java View File

@@ -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
 }