summaryrefslogtreecommitdiff
path: root/src/test/java/com/seaofnodes/simple/Chapter03Test.java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2025-06-13 15:42:08 -0700
committerCliff Click <cliffc@acm.org>2025-07-08 20:29:09 -0700
commitfcce1e13814a02d8358eae9a40e33a7e6f2b5400 (patch)
treeb9623369d88e22a0be21dbba472eebfa476d02ab /src/test/java/com/seaofnodes/simple/Chapter03Test.java
parent664761624f4b0e3d6d1593b99e576854beec5949 (diff)
downloadSimple-linear-chapter24.tar.gz
Simple-linear-chapter24.zip
Unifying Structs and Arrayslinear-chapter24
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/Chapter03Test.java')
-rw-r--r--src/test/java/com/seaofnodes/simple/Chapter03Test.java73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/src/test/java/com/seaofnodes/simple/Chapter03Test.java
deleted file mode 100644
index c4e4c91e..00000000
--- a/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.seaofnodes.simple;
-
-import com.seaofnodes.simple.codegen.CodeGen;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class Chapter03Test {
-
- @Test
- public void testVarDecl() {
- CodeGen code = new CodeGen("int a=1; return a;");
- code.parse(); assertEquals("return 1;", code.print());
- }
-
- @Test
- public void testVarAdd() {
- CodeGen code = new CodeGen("int a=1; int b=2; return a+b;");
- code.parse();
- assertEquals("return 3;", code.print());
- }
-
- @Test
- public void testVarScope() {
- CodeGen code = new CodeGen("int a=1; int b=2; int c=0; { int b=3; c=a+b; } return c;");
- code.parse();
- assertEquals("return 4;", code.print());
- }
-
- @Test
- public void testVarScopeNoPeephole() {
- CodeGen code = new CodeGen("int a=1; int b=2; int !c=0; { int b=3; c=a+b; } return c; ");
- code.parse(); // Peepholes always run now
- assertEquals("return 4;", code.print());
- }
-
- @Test
- public void testVarDist() {
- CodeGen code = new CodeGen("int x0=1; int y0=2; int x1=3; int y1=4; return (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1); ");
- code.parse();
- assertEquals("return 8;", code.print());
- }
-
- @Test
- public void testSelfAssign() {
- try {
- new CodeGen("int a=a; return a;").parse();
- fail();
- } catch( RuntimeException e ) {
- assertEquals("Undefined name 'a'",e.getMessage());
- }
- }
-
- @Test
- public void testRedeclareVar() {
- try {
- new CodeGen("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 CodeGen("int a=1; int b=2; int !c=0; { int b=3; c=a+b;").parse();
- fail();
- } catch( RuntimeException e ) {
- assertEquals("Syntax error, expected }: ",e.getMessage());
- }
- }
-
-}