summaryrefslogtreecommitdiff
path: root/tests/features
diff options
context:
space:
mode:
Diffstat (limited to 'tests/features')
-rw-r--r--tests/features/test_alias.zc24
-rw-r--r--tests/features/test_asm.zc4
-rw-r--r--tests/features/test_auto_deref.zc10
-rw-r--r--tests/features/test_bool_mutability.zc6
-rw-r--r--tests/features/test_build_directives.zc4
-rw-r--r--tests/features/test_comptime_suite.zc2
-rw-r--r--tests/features/test_concurrency_suite.zc30
-rw-r--r--tests/features/test_const_def.zc10
-rw-r--r--tests/features/test_default_args.zc10
-rw-r--r--tests/features/test_defer_control_flow.zc14
-rw-r--r--tests/features/test_destructuring.zc10
-rw-r--r--tests/features/test_embed.zc24
-rw-r--r--tests/features/test_enum_tuples.zc6
-rw-r--r--tests/features/test_fstring.zc4
-rw-r--r--tests/features/test_intel.zc4
-rw-r--r--tests/features/test_iterator.zc6
-rw-r--r--tests/features/test_iterator_drop.zc6
-rw-r--r--tests/features/test_match_composition.zc28
-rw-r--r--tests/features/test_match_ref.zc10
-rw-r--r--tests/features/test_mixin_methods.zc4
-rw-r--r--tests/features/test_operators_suite.zc30
-rw-r--r--tests/features/test_smart_derive.zc4
-rw-r--r--tests/features/test_traits_suite.zc30
-rw-r--r--tests/features/test_tuples.zc12
-rw-r--r--tests/features/test_unions.zc6
-rw-r--r--tests/features/test_varargs.zc6
-rw-r--r--tests/features/test_vec_iter.zc4
27 files changed, 154 insertions, 154 deletions
diff --git a/tests/features/test_alias.zc b/tests/features/test_alias.zc
index 5ec14f1..e3f71b3 100644
--- a/tests/features/test_alias.zc
+++ b/tests/features/test_alias.zc
@@ -39,18 +39,18 @@ alias Vec2f = Vec2<f32>;
alias Vec2i = Vec2<int>;
test "alias basic" {
- var x: MyInt = 10;
- var ptr: MyIntPtr = &x;
+ let x: MyInt = 10;
+ let ptr: MyIntPtr = &x;
assert(x == 10, "Basic alias failed");
assert(*ptr == 10, "Pointer alias failed");
- var res = process(x);
+ let res = process(x);
assert(res == 11, "Function with alias arg failed");
}
test "alias struct" {
- var p: Point = Point{x: 0, y: 0};
+ let p: Point = Point{x: 0, y: 0};
p.x = 100;
p.y = 200;
@@ -58,30 +58,30 @@ test "alias struct" {
}
test "alias generic struct" {
- var v = Vec2f{x: 1.5, y: 2.5};
+ let v = Vec2f{x: 1.5, y: 2.5};
assert(v.x > 1.0, "Generic alias field access failed");
assert(v.y > 2.0, "Generic alias field access failed");
- var vi = Vec2i{x: 10, y: 20};
+ let vi = Vec2i{x: 10, y: 20};
assert(vi.x == 10, "Generic int alias failed");
assert(vi.y == 20, "Generic int alias failed");
}
test "alias fstring" {
- var v = Vec2f{x: 3.14, y: 6.28};
+ let v = Vec2f{x: 3.14, y: 6.28};
// This tests that f-string interpolation correctly resolves the alias
println "v.x = {v.x}, v.y = {v.y}";
}
test "alias function pointer" {
- // var op: BinOp;
+ // let op: BinOp;
// Assignment currently not supported for function types without casting
// op = add;
// assert(op(1, 2) == 3, "Function alias");
}
test "alias operator overloading" {
- var v = Vec2f{x: 1.0, y: 1.0};
+ let v = Vec2f{x: 1.0, y: 1.0};
v = -v; // Should call __neg
assert(v.x == -1.0, "Unary operator generic alias failed");
@@ -89,7 +89,7 @@ test "alias operator overloading" {
assert(v.x == -2.0, "Compound assignment generic alias failed");
// Control
- var v2 = Vec2<f32>{x: 1.0, y: 1.0};
+ let v2 = Vec2<f32>{x: 1.0, y: 1.0};
v2 = -v2;
v2 += v2;
assert(v2.x == -2.0, "Control generic operator overloading failed");
@@ -97,11 +97,11 @@ test "alias operator overloading" {
test "alias static methods" {
- var v1 = Vec2f::zero();
+ let v1 = Vec2f::zero();
assert(v1.x == 0.0, "Direct static call on alias failed");
println "Static call in f-string: {Vec2f::zero().x}";
- var v2 = Vec2<f32>::zero();
+ let v2 = Vec2<f32>::zero();
assert(v2.x == 0.0, "Direct static call on generic failed");
}
diff --git a/tests/features/test_asm.zc b/tests/features/test_asm.zc
index 01f35d5..02d268d 100644
--- a/tests/features/test_asm.zc
+++ b/tests/features/test_asm.zc
@@ -32,7 +32,7 @@ test "test_asm" {
}
fn add_five(x: int) -> int {
- var result: int;
+ let result: int;
asm {
"mov {x}, {result}"
"add $5, {result}"
@@ -44,7 +44,7 @@ fn add_five(x: int) -> int {
test "test_asm_params" {
println "Testing assembly parameters...";
- var val = add_five(10);
+ let val = add_five(10);
if (val == 15) {
println "-> Success! add_five(10) = 15";
} else {
diff --git a/tests/features/test_auto_deref.zc b/tests/features/test_auto_deref.zc
index b7b0c51..5d1cf40 100644
--- a/tests/features/test_auto_deref.zc
+++ b/tests/features/test_auto_deref.zc
@@ -5,8 +5,8 @@ struct Point {
}
test "auto_deref" {
- var p = Point { x: 10, y: 20 };
- var ptr = &p;
+ let p = Point { x: 10, y: 20 };
+ let ptr = &p;
// This uses the dot operator on a pointer
// In standard C, this requires ->. In Zen-C w/ Auto-Deref, . should work.
@@ -17,9 +17,9 @@ test "auto_deref" {
assert(ptr.y == 30, "read ptr.y after write failed");
- var i = Inner { val: 42 };
- var o = Outer { inner: i };
- var p_out = &o;
+ let i = Inner { val: 42 };
+ let o = Outer { inner: i };
+ let p_out = &o;
// Nested access: p.inner.val -> p->inner.val
assert(p_out.inner.val == 42, "Nested access failed");
diff --git a/tests/features/test_bool_mutability.zc b/tests/features/test_bool_mutability.zc
index 553e871..5426b6f 100644
--- a/tests/features/test_bool_mutability.zc
+++ b/tests/features/test_bool_mutability.zc
@@ -1,7 +1,7 @@
test "boolean_mutability" {
- // Regression test for issue where 'var b = true' was inferred as const
- var b = true;
+ // Regression test for issue where 'let b = true' was inferred as const
+ let b = true;
assert(b, "Expected true");
// This assignment should be valid (previously failed with 'Cannot assign to const variable')
@@ -9,7 +9,7 @@ test "boolean_mutability" {
assert(!b, "Expected false after assignment");
// Verify explicit type works too
- var c: bool = true;
+ let c: bool = true;
c = false;
assert(!c, "Expected false for explicit type");
}
diff --git a/tests/features/test_build_directives.zc b/tests/features/test_build_directives.zc
index d6e35b3..7edd317 100644
--- a/tests/features/test_build_directives.zc
+++ b/tests/features/test_build_directives.zc
@@ -6,8 +6,8 @@ extern fn sin(x: double) -> double;
test "test_build_directives" {
println "Running Build Directives Test...";
- var x = 3.14159 / 2.0; // PI/2
- var s = sin(x);
+ let x = 3.14159 / 2.0; // PI/2
+ let s = sin(x);
// sin(PI/2) should be 1.0
println "sin(PI/2) = {s}";
diff --git a/tests/features/test_comptime_suite.zc b/tests/features/test_comptime_suite.zc
index b8127ec..677e0ff 100644
--- a/tests/features/test_comptime_suite.zc
+++ b/tests/features/test_comptime_suite.zc
@@ -17,7 +17,7 @@ test "test_comptime_block" {
}
test "test_comptime_attr" {
- var x = double_ct(21);
+ let x = double_ct(21);
assert(x == 42, "Comptime function failed");
println "Comptime function called successfully";
}
diff --git a/tests/features/test_concurrency_suite.zc b/tests/features/test_concurrency_suite.zc
index aa7512a..a0b571b 100644
--- a/tests/features/test_concurrency_suite.zc
+++ b/tests/features/test_concurrency_suite.zc
@@ -29,48 +29,48 @@ struct Counter {
}
test "test_async_basics" {
- var future1 = double_slowly(21);
- var future2 = add_async(10, 20);
+ let future1 = double_slowly(21);
+ let future2 = add_async(10, 20);
- var result1 = await future1;
- var result2 = await future2;
+ let result1 = await future1;
+ let result2 = await future2;
assert(result1 == 42, "Async double failed");
assert(result2 == 30, "Async add failed");
}
test "test_async_struct_return" {
- var f = make_point(5, 7);
- var p = await f;
+ let f = make_point(5, 7);
+ let p = await f;
assert(p.x == 5, "Async struct x failed");
assert(p.y == 7, "Async struct y failed");
}
test "test_async_void" {
- var f = say_hello();
+ let f = say_hello();
await f;
}
test "test_thread" {
println "Testing Concurrency...";
- var c = (Counter*)malloc(sizeof(Counter));
+ let c = (Counter*)malloc(sizeof(Counter));
c.val = 0;
c.lock = Mutex::new();
def N = 10000;
- var t1_res = Thread::spawn(fn() {
- for (var i=0; i<N; ++i) {
+ let t1_res = Thread::spawn(fn() {
+ for (let i=0; i<N; ++i) {
c.lock.lock();
c.val = c.val + 1;
c.lock.unlock();
}
});
- var t2_res = Thread::spawn(fn() {
- for (var i=0; i<N; ++i) {
+ let t2_res = Thread::spawn(fn() {
+ for (let i=0; i<N; ++i) {
c.lock.lock();
c.val = c.val + 1;
c.lock.unlock();
@@ -80,15 +80,15 @@ test "test_thread" {
assert(t1_res.is_err() == false, "T1 failed to spawn");
assert(t2_res.is_err() == false, "T2 failed to spawn");
- var t1 = t1_res.unwrap();
- var t2 = t2_res.unwrap();
+ let t1 = t1_res.unwrap();
+ let t2 = t2_res.unwrap();
t1.join();
t2.join();
println "Final Count: {c.val} (Expected {2 * N})";
- var final_val = c.val;
+ let final_val = c.val;
c.lock.free();
free(c);
diff --git a/tests/features/test_const_def.zc b/tests/features/test_const_def.zc
index b104196..8c548ae 100644
--- a/tests/features/test_const_def.zc
+++ b/tests/features/test_const_def.zc
@@ -6,7 +6,7 @@ test "def_constants" {
assert(MAX == 100, "def constant value mismatch");
// PI check (float) - exact match might be tricky but 3.14159 is literal
- var x = MAX;
+ let x = MAX;
assert(x == 100, "Assign from def");
}
@@ -20,12 +20,12 @@ test "def_scoping" {
}
test "const_type_qualifier" {
- var x: const int = 10;
+ let x: const int = 10;
assert(x == 10, "const Var init");
- // Address of const var should be allowed
- var p: const int* = &x;
- assert(*p == 10, "Pointer to const var");
+ // Address of const let should be allowed
+ let p: const int* = &x;
+ assert(*p == 10, "Pointer to const let");
}
// Note: Negative tests (compilation failures) are hard to test in this harness currently
diff --git a/tests/features/test_default_args.zc b/tests/features/test_default_args.zc
index cbeba83..6e98813 100644
--- a/tests/features/test_default_args.zc
+++ b/tests/features/test_default_args.zc
@@ -16,16 +16,16 @@ fn operation(a: int, b: int = 5 * 2) -> int {
}
fn main() {
- var p1 = Point { x: 5, y: 5 };
- var res1 = add_points(p1);
+ let p1 = Point { x: 5, y: 5 };
+ let res1 = add_points(p1);
println "res1.x: {res1.x}, res1.y: {res1.y}";
assert(res1.x == 15, "result is not 15");
assert(res1.y == 15, "result is not 15");
- var p2 = Point { x: 1, y: 1 };
- var p3 = Point { x: 5, y: 5 };
- var res2 = add_points(p3, p2);
+ let p2 = Point { x: 1, y: 1 };
+ let p3 = Point { x: 5, y: 5 };
+ let res2 = add_points(p3, p2);
println "res2.x: {res2.x}, res2.y: {res2.y}";
assert(res2.x == 6, "result is not 6");
diff --git a/tests/features/test_defer_control_flow.zc b/tests/features/test_defer_control_flow.zc
index 40c7f37..e459134 100644
--- a/tests/features/test_defer_control_flow.zc
+++ b/tests/features/test_defer_control_flow.zc
@@ -1,6 +1,6 @@
test "defer_runs_on_break" {
- var result = 0;
+ let result = 0;
for i in 0..5 {
defer { result = result + 1; }
@@ -14,7 +14,7 @@ test "defer_runs_on_break" {
}
test "defer_runs_on_continue" {
- var result = 0;
+ let result = 0;
for i in 0..5 {
defer { result = result + 1; }
@@ -28,7 +28,7 @@ test "defer_runs_on_continue" {
}
fn early_return(x: int) -> int {
- var side_effect = 0;
+ let side_effect = 0;
defer { side_effect = 42; }
if x > 0 {
@@ -39,12 +39,12 @@ fn early_return(x: int) -> int {
}
test "defer_runs_on_return" {
- var result = early_return(10);
+ let result = early_return(10);
assert(result == 10, "early return should work with defer");
}
test "defer_lifo_order" {
- var result = 0;
+ let result = 0;
for i in 0..2 {
defer { result = result * 10 + 1; }
@@ -59,8 +59,8 @@ test "defer_lifo_order" {
}
test "nested_loops_defer" {
- var outer_count = 0;
- var inner_count = 0;
+ let outer_count = 0;
+ let inner_count = 0;
for i in 0..3 {
defer { outer_count = outer_count + 1; }
diff --git a/tests/features/test_destructuring.zc b/tests/features/test_destructuring.zc
index b898582..3e24001 100644
--- a/tests/features/test_destructuring.zc
+++ b/tests/features/test_destructuring.zc
@@ -13,24 +13,24 @@ fn tuple_ret() -> (int, int) {
}
test "test_destructuring" {
- var p = Point{x: 1, y: 2};
+ let p = Point{x: 1, y: 2};
// Explicit Struct Destructuring (Shorthand)
- var Point{x, y} = p;
+ let Point{x, y} = p;
assert(x == 1, "x is 1");
assert(y == 2, "y is 2");
// Explicit Struct Destructuring (Renamed)
- var Point{x: a, y: b} = p;
+ let Point{x: a, y: b} = p;
assert(a == 1, "a is 1");
assert(b == 2, "b is 2");
// Anonymous Struct Destructuring (Inferred)
// Note: Anonymous block only supports shorthand {x, y} currently.
- // var {x: x2} = p; // Not supported yet in anonymous block parser
+ // let {x: x2} = p; // Not supported yet in anonymous block parser
// Tuple Destructuring
- var (t1, t2) = tuple_ret();
+ let (t1, t2) = tuple_ret();
assert(t1 == 10, "t1 is 10");
assert(t2 == 20, "t2 is 20");
diff --git a/tests/features/test_embed.zc b/tests/features/test_embed.zc
index 33acef2..ad7247c 100644
--- a/tests/features/test_embed.zc
+++ b/tests/features/test_embed.zc
@@ -2,22 +2,22 @@
test "test_embed" {
"=> Static File Analyzer";
- var data = embed "std.zc";
+ let data = embed "std.zc";
"Target File: 'std.zc'";
"File Size: {data.len} bytes";
"";
- var lines: I32 = 1;
- var words: I32 = 0;
- var sum: U64 = 0;
- var in_word: bool = 0;
+ let lines: I32 = 1;
+ let words: I32 = 0;
+ let sum: U64 = 0;
+ let in_word: bool = 0;
"Analyzing content...";
- var i: int = 0;
+ let i: int = 0;
while (i < data.len) {
- var c: char = data.data[i];
+ let c: char = data.data[i];
match c {
'\n' => {
@@ -37,7 +37,7 @@ test "test_embed" {
}
}
- var b: U8 = c;
+ let b: U8 = c;
sum = sum + b;
i++;
@@ -57,7 +57,7 @@ test "test_embed" {
test "typed_embed" {
// String
- var s = embed "tests/features/embed_data.txt" as string;
+ let s = embed "tests/features/embed_data.txt" as string;
// "Hello World!\n" ? No newline in my file creation?
// echo "Hello World!" > ... likely adds newline.
// My previous tool 'write_to_file' wrote "Hello World!". It usually doesn't add newline unless specified?
@@ -65,17 +65,17 @@ test "typed_embed" {
if (s[0] != 'H') exit(101);
// Fixed array
- var arr = embed "tests/features/embed_data.txt" as u8[5];
+ let arr = embed "tests/features/embed_data.txt" as u8[5];
if (arr[0] != 'H') exit(102);
if (arr[4] != 'o') exit(103);
// Slice
- var sl = embed "tests/features/embed_data.txt" as u8[];
+ let sl = embed "tests/features/embed_data.txt" as u8[];
if (sl.len < 5) exit(104);
if (sl.data[0] != 'H') exit(105);
// Untyped regression
- var raw = embed "tests/features/embed_data.txt";
+ let raw = embed "tests/features/embed_data.txt";
if (raw.len < 5) exit(106);
if (raw.data[0] != 'H') exit(107);
diff --git a/tests/features/test_enum_tuples.zc b/tests/features/test_enum_tuples.zc
index 12d9088..7e43bad 100644
--- a/tests/features/test_enum_tuples.zc
+++ b/tests/features/test_enum_tuples.zc
@@ -5,9 +5,9 @@ enum Shape {
}
fn main() {
- var r = Shape.Rect(10.0, 20.0);
+ let r = Shape.Rect(10.0, 20.0);
- var matched = 0;
+ let matched = 0;
match r {
Shape::Rect(w, h) => {
assert(w == 10.0, "w == 10.0");
@@ -20,7 +20,7 @@ fn main() {
}
assert(matched == 1, "Matched Rect");
- var c = Shape.Circle(5.0);
+ let c = Shape.Circle(5.0);
match c {
Shape::Circle(val) => {
assert(val == 5.0, "val == 5.0");
diff --git a/tests/features/test_fstring.zc b/tests/features/test_fstring.zc
index b2a8f36..cb46cda 100644
--- a/tests/features/test_fstring.zc
+++ b/tests/features/test_fstring.zc
@@ -2,7 +2,7 @@ import "tests/features/_fstring_mod.zc" as Mod;
test "alias namespace fstring" {
// Tests that {Mod::get_val()} is parsed correctly (Mod_get_val)
- var res = f"{Mod::get_val()}";
+ let res = f"{Mod::get_val()}";
assert(res == "42", "Import namespace in f-string failed");
// Check local string formatting via println (compile check)
@@ -15,7 +15,7 @@ test "alias C header fstring" {
// Tests that {Lib::lib_val()} resolves to lib_val() (no mangling/prefix)
// parser_expr.c strips alias for C headers.
// parser_utils.c rewrite_expr_methods needs to do the same.
- var res = f"{Lib::lib_val()}";
+ let res = f"{Lib::lib_val()}";
assert(res == "99", "C header namespace in f-string failed");
// Verify println (rewrite_expr_methods path)
diff --git a/tests/features/test_intel.zc b/tests/features/test_intel.zc
index 8547501..3b88178 100644
--- a/tests/features/test_intel.zc
+++ b/tests/features/test_intel.zc
@@ -1,7 +1,7 @@
//> cflags: -masm=intel
fn add_five_intel(x: int) -> int {
- var result: int;
+ let result: int;
asm {
"mov {result}, {x}"
"add {result}, 5"
@@ -12,7 +12,7 @@ fn add_five_intel(x: int) -> int {
}
test "test_intel" {
- var val = add_five_intel(10);
+ let val = add_five_intel(10);
"Sum Intel: 10 + 5 = {val}";
match val {
diff --git a/tests/features/test_iterator.zc b/tests/features/test_iterator.zc
index 1340a00..6efd413 100644
--- a/tests/features/test_iterator.zc
+++ b/tests/features/test_iterator.zc
@@ -9,7 +9,7 @@ struct RangeIter {
impl RangeIter {
fn next(self) -> Option<int> {
if (self.current < self.stop) {
- var v = self.current;
+ let v = self.current;
self.current += 1;
return Option<int>::Some(v);
}
@@ -32,8 +32,8 @@ impl MyRange {
}
test "iterator_desugaring" {
- var range = MyRange { start: 0, end: 5 };
- var sum = 0;
+ let range = MyRange { start: 0, end: 5 };
+ let sum = 0;
// This loop should be desugared by the compiler
for i in range {
diff --git a/tests/features/test_iterator_drop.zc b/tests/features/test_iterator_drop.zc
index 43e22a7..bc513df 100644
--- a/tests/features/test_iterator_drop.zc
+++ b/tests/features/test_iterator_drop.zc
@@ -1,7 +1,7 @@
import "../../std/iter.zc"
import "../../std/mem.zc"
-var DROP_CALLED = 0;
+let DROP_CALLED = 0;
struct DropIter {
count: int;
@@ -36,10 +36,10 @@ impl DropRange {
test "iterator_drop" {
{
- var range = DropRange { len: 3 };
+ let range = DropRange { len: 3 };
for i in range {
// Loop runs 3 times
- var _ignore = i;
+ let _ignore = i;
}
// Iterator should be dropped here
}
diff --git a/tests/features/test_match_composition.zc b/tests/features/test_match_composition.zc
index f25b90f..1015a1f 100644
--- a/tests/features/test_match_composition.zc
+++ b/tests/features/test_match_composition.zc
@@ -25,13 +25,13 @@ enum MixinResult {
// Test match binding with named composition - field access
test "match_binding_named_composition" {
- var inner = Inner { value: 42 };
- var wrapper = NamedWrapper { inner: inner };
- var result = NamedResult::Ok(wrapper);
+ let inner = Inner { value: 42 };
+ let wrapper = NamedWrapper { inner: inner };
+ let result = NamedResult::Ok(wrapper);
match result {
NamedResult::Ok(w) => {
- var val = w.inner.value;
+ let val = w.inner.value;
assert(val == 42, "Named composition field access failed");
},
NamedResult::Err(e) => assert(false, "Should not be Err")
@@ -40,12 +40,12 @@ test "match_binding_named_composition" {
// Test match binding with mixin composition - field access
test "match_binding_mixin_composition" {
- var wrapper = MixinWrapper { value: 77 };
- var result = MixinResult::Ok(wrapper);
+ let wrapper = MixinWrapper { value: 77 };
+ let result = MixinResult::Ok(wrapper);
match result {
MixinResult::Ok(w) => {
- var val = w.value;
+ let val = w.value;
assert(val == 77, "Mixin composition field access failed");
},
MixinResult::Err(e) => assert(false, "Should not be Err")
@@ -54,8 +54,8 @@ test "match_binding_mixin_composition" {
// Test match binding with mixin - f-string interpolation
test "match_binding_mixin_fstring" {
- var wrapper = MixinWrapper { value: 88 };
- var result = MixinResult::Ok(wrapper);
+ let wrapper = MixinWrapper { value: 88 };
+ let result = MixinResult::Ok(wrapper);
match result {
MixinResult::Ok(w) => {
@@ -68,8 +68,8 @@ test "match_binding_mixin_fstring" {
// Test match binding with ref - mixin composition
test "match_binding_ref_mixin" {
- var wrapper = MixinWrapper { value: 33 };
- var result = MixinResult::Ok(wrapper);
+ let wrapper = MixinWrapper { value: 33 };
+ let result = MixinResult::Ok(wrapper);
match result {
MixinResult::Ok(ref w) => {
@@ -90,9 +90,9 @@ test "match_binding_ref_mixin" {
// Test match binding with ref - named composition
test "match_binding_ref_named" {
- var inner = Inner { value: 55 };
- var wrapper = NamedWrapper { inner: inner };
- var result = NamedResult::Ok(wrapper);
+ let inner = Inner { value: 55 };
+ let wrapper = NamedWrapper { inner: inner };
+ let result = NamedResult::Ok(wrapper);
match result {
NamedResult::Ok(ref w) => {
diff --git a/tests/features/test_match_ref.zc b/tests/features/test_match_ref.zc
index 0442dc7..45ab0f4 100644
--- a/tests/features/test_match_ref.zc
+++ b/tests/features/test_match_ref.zc
@@ -5,7 +5,7 @@ enum MyOption<T> {
}
test "match_ref_int" {
- var r = MyOption<int>::Some(42);
+ let r = MyOption<int>::Some(42);
match r {
MyOption::Some(ref i) => {
// i is int*
@@ -21,9 +21,9 @@ struct Mover {
}
test "match_ref_mover" {
- var m = Mover { val: 100 };
+ let m = Mover { val: 100 };
// MyOption<Mover> instantiation
- var opt = MyOption<Mover>::Some(m);
+ let opt = MyOption<Mover>::Some(m);
match opt {
MyOption::Some(ref x) => {
@@ -50,9 +50,9 @@ enum Test {
}
test "match ref binding concrete" {
- var t = Test::ONE(Hello{ world: 123 });
+ let t = Test::ONE(Hello{ world: 123 });
- var val = 0;
+ let val = 0;
match t {
Test::ONE(ref o) => {
// o should be Hello*
diff --git a/tests/features/test_mixin_methods.zc b/tests/features/test_mixin_methods.zc
index 0932429..f69ae7c 100644
--- a/tests/features/test_mixin_methods.zc
+++ b/tests/features/test_mixin_methods.zc
@@ -19,11 +19,11 @@ struct Bar {
}
test "test_mixin_methods" {
- var b: Bar;
+ let b: Bar;
b.i = 42;
b.f = 3.14;
- var val = b.get_i();
+ let val = b.get_i();
assert(val == 42, "Mixin method get_i() should return 42");
b.set_i(100);
diff --git a/tests/features/test_operators_suite.zc b/tests/features/test_operators_suite.zc
index cf0f4c2..f4d18d8 100644
--- a/tests/features/test_operators_suite.zc
+++ b/tests/features/test_operators_suite.zc
@@ -54,10 +54,10 @@ fn make_err(e: int) -> Result {
}
fn process_result(fail: int) -> Result {
- var val = make_ok(10)?;
+ let val = make_ok(10)?;
if (fail) {
- var v2 = make_err(500)?;
+ let v2 = make_err(500)?;
return Result_Ok(v2 + 1000);
}
@@ -74,8 +74,8 @@ fn twice(x: int) -> int {
test "test_operator_overloading" {
"=> Bitwise Primitives";
- var a = 0b1100;
- var b = 0b1010;
+ let a = 0b1100;
+ let b = 0b1010;
"{a} | {b} = {a | b} (Expected 14)";
"{a} & {b} = {a & b} (Expected 8)";
@@ -83,13 +83,13 @@ test "test_operator_overloading" {
"{a} << 1 = {a << 1} (Expected 24)";
"=> Compound Assignment Desugaring";
- var x = 10;
+ let x = 10;
x += 5; // 15
x <<= 1; // 30
"=> Struct Overloading + Compound (|=)";
- var f1 = Flags::new(1);
- var f2 = Flags::new(4);
+ let f1 = Flags::new(1);
+ let f2 = Flags::new(4);
f1 |= f2;
"Result bits: {f1.bits} (Expected 5)";
@@ -97,7 +97,7 @@ test "test_operator_overloading" {
}
test "test_extended_overloading" {
- var c = Container::new(10);
+ let c = Container::new(10);
// Index Get
assert(c[5] == 15, "Get Failed");
@@ -111,34 +111,34 @@ test "test_extended_overloading" {
assert(c.val == 27, "Compound Set Failed");
// Unary Neg
- var n = -c;
+ let n = -c;
assert(n.val == -27, "Neg Failed");
// Unary Not
assert(!c == false, "Not Operator Failed");
// Unary Bitnot
- var b = ~c;
+ let b = ~c;
assert(b.val == ~27, "Bitnot Failed");
}
test "test_pipe_operator" {
- var res = 5 |> twice;
+ let res = 5 |> twice;
assert(res == 10, "Pipe twice failed");
- var res2 = 10 |> add(20);
+ let res2 = 10 |> add(20);
assert(res2 == 30, "Pipe add failed");
- var res3 = 5 |> twice |> add(10); // 20
+ let res3 = 5 |> twice |> add(10); // 20
assert(res3 == 20, "Multi-pipe failed");
}
test "test_try_operator" {
- var res_ok = process_result(0);
+ let res_ok = process_result(0);
assert(res_ok.tag == Result_Ok_Tag, "Expected Ok");
assert(res_ok.data.Ok == 30, "Expected 30");
- var res_err = process_result(1);
+ let res_err = process_result(1);
assert(res_err.tag == Result_Err_Tag, "Expected Err");
assert(res_err.data.Err == 500, "Expected Err(500)");
}
diff --git a/tests/features/test_smart_derive.zc b/tests/features/test_smart_derive.zc
index 705a12f..b005080 100644
--- a/tests/features/test_smart_derive.zc
+++ b/tests/features/test_smart_derive.zc
@@ -6,8 +6,8 @@ struct Container {
// Ensure derived eq uses pointers by trying to use 'c2' after comparison
test "eq_moves" {
- var c1 = Container { val: 10 };
- var c2 = Container { val: 10 };
+ let c1 = Container { val: 10 };
+ let c2 = Container { val: 10 };
// This should call Container__eq(&c1, &c2)
// If it passed by value, c2 would be moved here
diff --git a/tests/features/test_traits_suite.zc b/tests/features/test_traits_suite.zc
index 8410de8..205bdf6 100644
--- a/tests/features/test_traits_suite.zc
+++ b/tests/features/test_traits_suite.zc
@@ -61,19 +61,19 @@ fn print_shape_info(s: Shape) {
}
test "basic_traits" {
- var r: Robot = Robot { id: 42 };
- var g: Greeter = &r;
+ let r: Robot = Robot { id: 42 };
+ let g: Greeter = &r;
g.greet("Hello World");
g.shout();
}
test "advanced_traits" {
- var c = Circle { radius: 5.0 };
- var r = Rectangle { width: 4.0, height: 6.0 };
+ let c = Circle { radius: 5.0 };
+ let r = Rectangle { width: 4.0, height: 6.0 };
- var s_c: Shape = &c;
- var s_r: Shape = &r;
+ let s_c: Shape = &c;
+ let s_r: Shape = &r;
print_shape_info(s_c);
print_shape_info(s_r);
@@ -86,33 +86,33 @@ test "advanced_traits" {
}
test "test_derive" {
- var p1 = Point{x: 10, y: 20};
+ let p1 = Point{x: 10, y: 20};
// Debug
- var s = p1.to_string();
+ let s = p1.to_string();
assert(strcmp(s, "Point { ... }") == 0, "Debug string matches");
// Clone
- var p2 = p1.clone();
+ let p2 = p1.clone();
assert(p2.x == 10, "Clone x matches");
// Eq
assert(p1.eq(&p2) == true, "Eq works (true)");
- var p3 = Point{x: 10, y: 21};
+ let p3 = Point{x: 10, y: 21};
assert(p1.eq(&p3) == false, "Eq works (false)");
}
test "implicit_trait_cast" {
- var c = Circle { radius: 10.0 };
+ let c = Circle { radius: 10.0 };
// This previously required explicit casting: print_shape_info((Shape)(&c));
print_shape_info(&c);
- var r = Rectangle { width: 5.0, height: 5.0 };
+ let r = Rectangle { width: 5.0, height: 5.0 };
print_shape_info(&r);
}
-var g_def_circle = Circle { radius: 2.0 };
+let g_def_circle = Circle { radius: 2.0 };
fn print_default_shape(s: Shape = &g_def_circle) {
println "Default Shape: {s.name()}";
@@ -137,8 +137,8 @@ impl UnderscoreTest for UnderscoreStruct {
}
test "trait_underscores" {
- var u = UnderscoreStruct { val: 100 };
- var t: UnderscoreTest = &u;
+ let u = UnderscoreStruct { val: 100 };
+ let t: UnderscoreTest = &u;
assert(t.method_with_underscores_123() == 100, "Method with underscores call failed");
}
diff --git a/tests/features/test_tuples.zc b/tests/features/test_tuples.zc
index bc8b8d8..4bab25d 100644
--- a/tests/features/test_tuples.zc
+++ b/tests/features/test_tuples.zc
@@ -4,31 +4,31 @@ fn get_pair() -> (int, int) {
fn main() {
// Inferred type tuple literal
- var p = (1, 2);
+ let p = (1, 2);
assert(p.0 == 1, "Tuple access 0");
assert(p.1 == 2, "Tuple access 1");
// Function returning tuple
- var p2 = get_pair();
+ let p2 = get_pair();
assert(p2.0 == 10, "Tuple return 0");
assert(p2.1 == 20, "Tuple return 1");
// Explicit type tuple
- var p3: (int, int) = (5, 6);
+ let p3: (int, int) = (5, 6);
assert(p3.0 == 5, "Explicit tuple 0");
assert(p3.1 == 6, "Explicit tuple 1");
// Different types
- var mixed: (int, string) = (10, "Hello");
+ let mixed: (int, string) = (10, "Hello");
assert(mixed.0 == 10, "Mixed 0");
assert(strcmp(mixed.1, "Hello") == 0, "Mixed 1 (String)");
// Regression for segfault (inferred tuple with string)
- var p_str = (1, "World");
+ let p_str = (1, "World");
assert(strcmp(p_str.1, "World") == 0, "Inferred tuple string");
// Tuple destructuring
- var (a, b) = get_pair();
+ let (a, b) = get_pair();
assert(a == 10, "Destructured a");
assert(b == 20, "Destructured b");
}
diff --git a/tests/features/test_unions.zc b/tests/features/test_unions.zc
index ee9848b..11ee1a6 100644
--- a/tests/features/test_unions.zc
+++ b/tests/features/test_unions.zc
@@ -14,11 +14,11 @@ union Shape {
}
test "union_init" {
- var c = Circle{ radius: 10.0 };
- var s = Shape{ circle: c };
+ let c = Circle{ radius: 10.0 };
+ let s = Shape{ circle: c };
assert(s.circle.radius == 10.0, "s.circle.radius != 10.0");
- var s2 = Shape{};
+ let s2 = Shape{};
s2.rect = Rect{ width: 5.0, height: 5.0 };
assert(s2.rect.width == 5.0, "s2.rect.width != 5.0");
}
diff --git a/tests/features/test_varargs.zc b/tests/features/test_varargs.zc
index b06f66e..376a825 100644
--- a/tests/features/test_varargs.zc
+++ b/tests/features/test_varargs.zc
@@ -9,11 +9,11 @@ test "Variadic Sum" {
}
fn sum_all(count: int, ...) -> int {
- var total = 0;
- var ap: va_list;
+ let total = 0;
+ let ap: va_list;
va_start(ap, count);
- for (var i = 0; i < count; i = i + 1) {
+ for (let i = 0; i < count; i = i + 1) {
total = total + va_arg(ap, int);
}
diff --git a/tests/features/test_vec_iter.zc b/tests/features/test_vec_iter.zc
index b7e8dcb..5877c40 100644
--- a/tests/features/test_vec_iter.zc
+++ b/tests/features/test_vec_iter.zc
@@ -1,12 +1,12 @@
import "../../std/vec.zc"
test "vec_int_iteration" {
- var v = Vec<int>::new();
+ let v = Vec<int>::new();
v.push(10);
v.push(20);
v.push(30);
- var sum = 0;
+ let sum = 0;
for x in v {
sum = sum + x;
}