summaryrefslogtreecommitdiff
path: root/src/test/java/com/seaofnodes/simple/Chapter13Test.java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2024-10-21 09:25:15 -0700
committerCliff Click <cliffc@acm.org>2024-11-22 15:23:43 -0800
commitb0e1da2a7d0d39347e247d9fbda924b720d4b0a0 (patch)
treef40907ed72bdffff46e2fd6c79b47e8d672803fb /src/test/java/com/seaofnodes/simple/Chapter13Test.java
parent4b24919a2cd06dd5debcc0322cbeb314d77aaba1 (diff)
downloadSimple-linear-chapter17.tar.gz
Simple-linear-chapter17.zip
Chapter 17: Syntax Sugarlinear-chapter17
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/Chapter13Test.java')
-rw-r--r--src/test/java/com/seaofnodes/simple/Chapter13Test.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/test/java/com/seaofnodes/simple/Chapter13Test.java b/src/test/java/com/seaofnodes/simple/Chapter13Test.java
index 165d23e5..30d9b147 100644
--- a/src/test/java/com/seaofnodes/simple/Chapter13Test.java
+++ b/src/test/java/com/seaofnodes/simple/Chapter13Test.java
@@ -23,9 +23,9 @@ return 3.14;
Parser parser = new Parser(
"""
struct LLI { LLI? next; int i; };
-LLI? head = null;
+LLI? !head = null;
while( arg ) {
- LLI x = new LLI;
+ LLI !x = new LLI;
x.next = head;
x.i = arg;
head = x;
@@ -42,9 +42,9 @@ return head.next.i;
Parser parser = new Parser(
"""
struct LLI { LLI? next; int i; };
-LLI? head = null;
+LLI? !head = null;
while( arg ) {
- LLI x = new LLI;
+ LLI !x = new LLI;
x.next = head;
x.i = arg;
head = x;
@@ -66,9 +66,9 @@ return next.i;
"""
struct int0 { int i; flt0? f; };
struct flt0 { flt f; int0? i; };
-int0 i0 = new int0;
+int0 !i0 = new int0;
i0.i = 17;
-flt0 f0 = new flt0;
+flt0 !f0 = new flt0;
f0.f = 3.14;
i0.f = f0;
f0.i = i0;
@@ -100,7 +100,7 @@ N n = new N { next = new M; };
return n.next;
""");
StopNode stop = parser.parse().iterate();
- assertEquals("return M;", stop.toString());
+ assertEquals("return (const)M;", stop.toString());
}
@Test
@@ -121,12 +121,12 @@ return n.next;
Parser parser = new Parser(
"""
struct N { N? next; int i; };
-N n = new N;
+N !n = new N;
n.i = 3.14;
return n.i;
""");
try { parser.parse().iterate(); fail(); }
- catch( Exception e ) { assertEquals("Cannot store 3.14 into field int i",e.getMessage()); }
+ catch( Exception e ) { assertEquals("Type 3.14 is not of declared type int",e.getMessage()); }
}
@Test
@@ -144,7 +144,7 @@ struct S{};
public void testForwardRef0() {
Parser parser = new Parser(
"""
-struct S1 { S2 s; };
+struct S1 { S2? s; };
return new S2;
""");
try { parser.parse().iterate(); fail(); }
@@ -169,7 +169,7 @@ return new S1.s=new S2;
"""
struct I {int i;};
struct P { I? pi; };
-P p1 = new P;
+P !p1 = new P;
P p2 = new P;
p2.pi = new I;
p2.pi.i = 2;