summaryrefslogtreecommitdiff
path: root/src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testFRefFields.smp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testFRefFields.smp')
-rw-r--r--src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testFRefFields.smp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testFRefFields.smp b/src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testFRefFields.smp
new file mode 100644
index 00000000..eac0a542
--- /dev/null
+++ b/src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testFRefFields.smp
@@ -0,0 +1,20 @@
+// A hypothetical scanner class
+struct _Scan {
+ int !x;
+ u8[~] buf;
+ new _Scan={ u8[~] b -> buf=b; };
+ // Skip whitespace
+ val skip = { ->
+ while( buf[x] <= ' ' )
+ x++;
+ };
+ // Peek a character; if matched consume it, else false.
+ val peek = { u8 c ->
+ skip();
+ if( buf[x] != c ) return false;
+ x++;
+ return true;
+ };
+};
+!_Scan !s = new _Scan(" q");
+return s.peek('q');