summaryrefslogtreecommitdiff
path: root/src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testMethod.smp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testMethod.smp')
-rw-r--r--src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testMethod.smp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testMethod.smp b/src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testMethod.smp
new file mode 100644
index 00000000..ced649e3
--- /dev/null
+++ b/src/test/java/com/seaofnodes/simple/spill/Chapter23Test-testMethod.smp
@@ -0,0 +1,17 @@
+// A hypothetical scanner class
+struct _Scan {
+ int !x;
+ u8[~] buf;
+ new _Scan={ u8[~] b -> buf=b; };
+ // Skip whitespace
+ val skip = { ->
+ while( buf[x] <= ' ' )
+ x++;
+ };
+ val require = { u8 ch ->
+ skip();
+ buf[x++]==ch;
+ };
+};
+!_Scan !s = new _Scan(" [1,2]");
+return s.require('[');