summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/custiter.myr33
-rw-r--r--test/tests1
2 files changed, 34 insertions, 0 deletions
diff --git a/test/custiter.myr b/test/custiter.myr
new file mode 100644
index 0000000..53238cd
--- /dev/null
+++ b/test/custiter.myr
@@ -0,0 +1,33 @@
+use std
+
+type range = struct
+ lo : int
+ hi : int
+;;
+
+/* iterate up to 100 */
+impl iterable range -> int =
+ __iternext__ = {rng, output
+ if rng.lo > rng.hi
+ -> false
+ else
+ output# = rng.lo++
+ -> true
+ ;;
+ }
+
+ __iterfin__ = {it, val
+ }
+;;
+
+const main = {
+ var r : range
+ var x : int
+
+ r = [.lo=6, .hi=11]
+ for v in r
+ x = v
+ std.put("{}", x)
+ ;;
+ std.put("\n")
+}
diff --git a/test/tests b/test/tests
index eb38ffc..4753f91 100644
--- a/test/tests
+++ b/test/tests
@@ -66,6 +66,7 @@ B fncast P ok
B loop P 0123401236789
B subrangefor P 12
B patiter P 23512
+B custiter P 67891011
B condiftrue E 7
B condiffalse E 9
B condifrel E 7