aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/test.cff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-26 07:42:27 +0200
committerlemon <lsof@mailbox.org>2022-08-26 07:42:27 +0200
commitd08e43f70d7482543c9bb2ba548bcd31e7eba978 (patch)
tree399d55b97973c226feffb100fb12336ca049e7e7 /bootstrap/test.cff
parent2a25159b7e5f7f94300aa68251a3598ed4fed824 (diff)
gensym fix, offset fix, str statics
Diffstat (limited to 'bootstrap/test.cff')
-rw-r--r--bootstrap/test.cff20
1 files changed, 20 insertions, 0 deletions
diff --git a/bootstrap/test.cff b/bootstrap/test.cff
index 3a7599a..6b0e188 100644
--- a/bootstrap/test.cff
+++ b/bootstrap/test.cff
@@ -82,6 +82,17 @@ enum union Number {
flo f32,
}
+defmacro match(ty, x, &body) [
+ (do
+ let $res ty = {};
+ #'match do {
+ defmacro yield(X) [ $res = (X); break #'match ]
+ switch (x) body
+ } while #f;
+ $res;
+ )
+]
+
extern fn main (argc int, argv **u8) int {
let colors [3]Color = { :Red, :Green, :Blue } ;
@@ -95,6 +106,13 @@ extern fn main (argc int, argv **u8) int {
let x = Number:none;
let x = Number:int{};
+ printf("match: %d\n", match(int, x) {
+ case none; yield(42);
+ case int i; yield(i - 7);
+ case flo f; yield(f * 0.5f);
+ });
+
+
let is []int = { [4] = 1, 2, [1 - 1] = 3 };
isort(is, is.#len);
each(i, x, is) {
@@ -102,6 +120,8 @@ extern fn main (argc int, argv **u8) int {
}
let slice [#]int = is[3::5];
+ static test *const u8 = "hi";
+
printf("sl %d\n", slice[0]);
slice = slice[1::4];
printf("sl %d\n", slice[0]);