diff options
| author | tannal <tannal2409@gmail.com> | 2025-01-19 21:52:02 +0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-01-19 11:35:22 -0800 |
| commit | 8d9cd9a0aa846b44dde6dc97138398f6d7ce00d9 (patch) | |
| tree | 122f2422d573608e15925b03af1d09828942f74b /chapter09/src/test/java/com | |
| parent | 83bc7cc22d7ace761b6d1be565e2dc71d556d31e (diff) | |
| download | Simple-8d9cd9a0aa846b44dde6dc97138398f6d7ce00d9.tar.gz Simple-8d9cd9a0aa846b44dde6dc97138398f6d7ce00d9.zip | |
Add testRedeclareVar in all later chapters
Diffstat (limited to 'chapter09/src/test/java/com')
| -rw-r--r-- | chapter09/src/test/java/com/seaofnodes/simple/Chapter03Test.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/chapter09/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter09/src/test/java/com/seaofnodes/simple/Chapter03Test.java index a243beb1..2246b927 100644 --- a/chapter09/src/test/java/com/seaofnodes/simple/Chapter03Test.java +++ b/chapter09/src/test/java/com/seaofnodes/simple/Chapter03Test.java @@ -56,6 +56,16 @@ public class Chapter03Test { } @Test + public void testRedeclareVar() { + try { + new Parser("int a=1; int b=2; int c=0; int b=3; c=a+b;").parse(); + fail(); + } catch( RuntimeException e ) { + assertEquals("Redefining name 'b'",e.getMessage()); + } + } + + @Test public void testBad1() { try { new Parser("int a=1; int b=2; int c=0; { int b=3; c=a+b;").parse(); |
