diff options
| author | Thalia Archibald <thalia@archibald.dev> | 2024-07-01 08:42:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-01 08:42:23 -0700 |
| commit | d6442ce5d00b9bea52d366ff4d6ae8c03b84aabb (patch) | |
| tree | f74a567beac80bbe4c7dfb8cecac853d7ba6ec80 /chapter01/src/test/java/com/seaofnodes | |
| parent | 383a1b7c38d444ea8a1b8643b0be2608a6f8e84d (diff) | |
| download | Simple-d6442ce5d00b9bea52d366ff4d6ae8c03b84aabb.tar.gz Simple-d6442ce5d00b9bea52d366ff4d6ae8c03b84aabb.zip | |
Fix grammar and forward-port minor changes (#91)
* Backport test exception handling to chapter 1
* Add unary ! to chapter 10 and 11 grammars
* Lex { } ! as punctuation
* Forward-port format whitespace
* Forward-port test organization
* Forward-port replace build-graphs.sh with Makefile
* Add chapter title to chapter 11
Diffstat (limited to 'chapter01/src/test/java/com/seaofnodes')
| -rw-r--r-- | chapter01/src/test/java/com/seaofnodes/simple/Chapter01Test.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/chapter01/src/test/java/com/seaofnodes/simple/Chapter01Test.java b/chapter01/src/test/java/com/seaofnodes/simple/Chapter01Test.java index 6989d0b9..a91aabb1 100644 --- a/chapter01/src/test/java/com/seaofnodes/simple/Chapter01Test.java +++ b/chapter01/src/test/java/com/seaofnodes/simple/Chapter01Test.java @@ -1,17 +1,12 @@ package com.seaofnodes.simple; import com.seaofnodes.simple.node.*; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import static org.junit.Assert.*; public class Chapter01Test { - @Rule - public ExpectedException exceptionRule = ExpectedException.none(); - @Test public void testSimpleProgram() { Parser parser = new Parser("return 1;"); @@ -60,9 +55,12 @@ public class Chapter01Test { @Test public void testBad3() { - exceptionRule.expect(RuntimeException.class); - exceptionRule.expectMessage("Syntax error, expected integer literal"); - new Parser("return --12;").parse(); + try { + new Parser("return --12;").parse(); + fail(); + } catch( RuntimeException e ) { + assertEquals("Syntax error, expected integer literal",e.getMessage()); + } } @Test @@ -78,9 +76,12 @@ public class Chapter01Test { // Negative numbers require unary operator support that is not in scope @Test public void testBad5() { - exceptionRule.expect(RuntimeException.class); - exceptionRule.expectMessage("Syntax error, expected integer literal"); - new Parser("return -100;").parse(); + try { + new Parser("return -100;").parse(); + fail(); + } catch( RuntimeException e ) { + assertEquals("Syntax error, expected integer literal",e.getMessage()); + } } @Test |
