summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-25 15:12:12 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-25 15:12:12 +0000
commit7d1944ab9d2307f2736afe8520436872db1c7617 (patch)
tree7380a4f148f9ce0b70ed9f02cfa5e8561c783a7a /tests
parent8b720543f538862796fec0ff6b7ea12cb140bf0f (diff)
'let' it be
Diffstat (limited to 'tests')
-rw-r--r--tests/basic/test_basics.zc10
-rw-r--r--tests/codegen/dedup_typedefs.zc4
-rw-r--r--tests/collections/test_string_suite.zc42
-rw-r--r--tests/control_flow/test_computed_goto.zc4
-rw-r--r--tests/control_flow/test_goto.zc4
-rw-r--r--tests/control_flow/test_guard_unless.zc12
-rw-r--r--tests/control_flow/test_if.zc6
-rw-r--r--tests/control_flow/test_labeled_break.zc4
-rw-r--r--tests/control_flow/test_loop_edge_cases.zc16
-rw-r--r--tests/control_flow/test_loops.zc46
-rw-r--r--tests/control_flow/test_match.zc34
-rw-r--r--tests/control_flow/test_ternary.zc8
-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
-rw-r--r--tests/functions/test_attributes.zc10
-rw-r--r--tests/functions/test_implicit_return.zc2
-rw-r--r--tests/functions/test_lambda_arrow.zc14
-rw-r--r--tests/functions/test_lambdas.zc32
-rw-r--r--tests/functions/test_must_use.zc6
-rw-r--r--tests/functions/test_raw_func_ptr.zc6
-rw-r--r--tests/functions/test_varargs.zc2
-rw-r--r--tests/generics/test_generic_empty_struct.zc6
-rw-r--r--tests/generics/test_generic_operators.zc6
-rw-r--r--tests/generics/test_generic_ptr.zc16
-rw-r--r--tests/generics/test_generic_traits.zc8
-rw-r--r--tests/generics/test_generics_fn.zc6
-rw-r--r--tests/generics/test_generics_struct.zc2
-rw-r--r--tests/generics/test_multi_generics.zc6
-rw-r--r--tests/generics/test_sizeof_template.zc14
-rw-r--r--tests/interop/test_c_import.zc6
-rw-r--r--tests/interop/test_c_macros.zc2
-rw-r--r--tests/memory/test_copy_trait.zc10
-rw-r--r--tests/memory/test_drop.zc4
-rw-r--r--tests/memory/test_drop_flags.zc6
-rw-r--r--tests/memory/test_memory_safety.zc70
-rw-r--r--tests/memory/test_move_double_free.zc16
-rw-r--r--tests/memory/test_move_semantics.zc22
-rw-r--r--tests/memory/test_resources.zc16
-rw-r--r--tests/memory/test_unsafe.zc22
-rw-r--r--tests/misc/test_advanced.zc50
-rw-r--r--tests/misc/test_chained.zc4
-rw-r--r--tests/misc/test_edge_cases.zc32
-rw-r--r--tests/misc/test_mix.zc16
-rw-r--r--tests/modules/test_aliasing.zc4
-rw-r--r--tests/modules/test_namespaced.zc8
-rw-r--r--tests/std/test_env.zc28
-rw-r--r--tests/std/test_fs.zc40
-rw-r--r--tests/std/test_map_iter.zc6
-rw-r--r--tests/std/test_net.zc24
-rw-r--r--tests/std/test_queue.zc18
-rw-r--r--tests/std/test_readln_scan.zc10
-rw-r--r--tests/std/test_stack.zc12
-rw-r--r--tests/std/test_std_expansion.zc10
-rw-r--r--tests/std/test_string_split.zc28
-rw-r--r--tests/std/test_string_utf8.zc20
-rw-r--r--tests/std/test_string_utils.zc40
-rw-r--r--tests/std/test_vec.zc30
82 files changed, 594 insertions, 594 deletions
diff --git a/tests/basic/test_basics.zc b/tests/basic/test_basics.zc
index 57dbb4e..8cc2e6b 100644
--- a/tests/basic/test_basics.zc
+++ b/tests/basic/test_basics.zc
@@ -4,8 +4,8 @@ test "test_hello" {
}
test "test_vars" {
- var x = 10;
- var y: int = 20;
+ let x = 10;
+ let y: int = 20;
println "Sum: {x + y}";
}
@@ -14,11 +14,11 @@ fn take_const_arg(x: const int) -> int {
}
test "test_const_args" {
- var x = take_const_arg(10);
+ let x = take_const_arg(10);
assert(x == 10, "Failed const arg");
- var y: const int = 20;
- assert(y == 20, "Failed const var");
+ let y: const int = 20;
+ assert(y == 20, "Failed const let");
println "Const args work!";
}
diff --git a/tests/codegen/dedup_typedefs.zc b/tests/codegen/dedup_typedefs.zc
index c6e8099..6e32346 100644
--- a/tests/codegen/dedup_typedefs.zc
+++ b/tests/codegen/dedup_typedefs.zc
@@ -9,10 +9,10 @@ struct Node {
}
fn main() {
- var v: Vec2f;
+ let v: Vec2f;
v.x = 1.0;
v.y = 2.0;
- var n: Node;
+ let n: Node;
n.val = 1;
}
diff --git a/tests/collections/test_string_suite.zc b/tests/collections/test_string_suite.zc
index a3f608d..afe08af 100644
--- a/tests/collections/test_string_suite.zc
+++ b/tests/collections/test_string_suite.zc
@@ -7,9 +7,9 @@ test "test_string_methods" {
println "Testing String methods...";
// Substring
- var s1: String = String::from("Hello World");
- var sub: String = s1.substring(0, 5);
- var expected1: String = String::from("Hello");
+ let s1: String = String::from("Hello World");
+ let sub: String = s1.substring(0, 5);
+ let expected1: String = String::from("Hello");
if (sub.eq(&expected1)) {
println " -> substring(0, 5): Passed";
} else {
@@ -17,8 +17,8 @@ test "test_string_methods" {
}
// Substring middle
- var sub2: String = s1.substring(6, 5);
- var expected2: String = String::from("World");
+ let sub2: String = s1.substring(6, 5);
+ let expected2: String = String::from("World");
if (sub2.eq(&expected2)) {
println " -> substring(6, 5): Passed";
} else {
@@ -26,9 +26,9 @@ test "test_string_methods" {
}
// Find character - found
- var pos: Option<usize> = s1.find('W');
+ let pos: Option<usize> = s1.find('W');
if (pos.is_some()) {
- var idx: usize = pos.unwrap();
+ let idx: usize = pos.unwrap();
assert(idx == (usize)6, "find('W') index mismatch");
println " -> find('W'): Passed (found at index 6)";
} else {
@@ -36,7 +36,7 @@ test "test_string_methods" {
}
// Find character - not found
- var pos2: Option<usize> = s1.find('Z');
+ let pos2: Option<usize> = s1.find('Z');
if (pos2.is_none()) {
println " -> find('Z'): Passed (not found)";
} else {
@@ -44,7 +44,7 @@ test "test_string_methods" {
}
// Length
- var len: usize = s1.length();
+ let len: usize = s1.length();
if (len == (usize)11) {
println " -> length(): Passed (11)";
} else {
@@ -65,10 +65,10 @@ test "test_string_methods" {
}
// Append
- var s2: String = String::from("Hello");
- var s3: String = String::from(" World");
+ let s2: String = String::from("Hello");
+ let s3: String = String::from(" World");
s2.append(&s3);
- var expected6: String = String::from("Hello World");
+ let expected6: String = String::from("Hello World");
if (s2.eq(&expected6)) {
println " -> append(): Passed";
} else {
@@ -80,33 +80,33 @@ test "test_string_methods" {
test "test_fstrings_return" {
println "Testing F-Strings and Returns...";
- var x = 100;
- var y = 50;
+ let x = 100;
+ let y = 50;
println "Direct F-String: x={x}";
- var nested = f"y is {y}";
+ let nested = f"y is {y}";
println "Argument F-String: {nested}";
println "Math inside: 100 + 50 = {x + y}";
- var inner = f"Inner({x})";
- var outer = f"Outer({inner})";
+ let inner = f"Inner({x})";
+ let outer = f"Outer({inner})";
println "Composed: {outer}";
assert(strcmp(outer, "Outer(Inner(100))") == 0, "Composed f-string failed");
}
test "test_string_std_ops" {
println "Testing String Std Ops...";
- var s1 = String::from("Hello");
- var s2 = String::from(" World");
+ let s1 = String::from("Hello");
+ let s2 = String::from(" World");
- var s3 = s1.add(&s2);
+ let s3 = s1.add(&s2);
print "Concatenated: ";
s3.println();
assert(s3.length() == 11, "Length mismatch");
- var s4 = String::from("Hello World");
+ let s4 = String::from("Hello World");
if (s3.eq(&s4)) {
println "Equality check passed: Strings are identical.";
} else {
diff --git a/tests/control_flow/test_computed_goto.zc b/tests/control_flow/test_computed_goto.zc
index 12b484c..7144132 100644
--- a/tests/control_flow/test_computed_goto.zc
+++ b/tests/control_flow/test_computed_goto.zc
@@ -1,9 +1,9 @@
test "test_computed_goto" -> int {
- var x = 0;
+ let x = 0;
// Get address of label using && unary operator
- var target = &&label_B;
+ let target = &&label_B;
// Jump to label A first
goto label_A;
diff --git a/tests/control_flow/test_goto.zc b/tests/control_flow/test_goto.zc
index 9a90139..dc6ab98 100644
--- a/tests/control_flow/test_goto.zc
+++ b/tests/control_flow/test_goto.zc
@@ -1,6 +1,6 @@
test "test_goto" -> int {
- var x = 0;
+ let x = 0;
goto skip;
x = 100;
@@ -8,7 +8,7 @@ test "test_goto" -> int {
skip:
assert x == 0;
- var resource = 1;
+ let resource = 1;
if resource == 1 {
goto cleanup;
diff --git a/tests/control_flow/test_guard_unless.zc b/tests/control_flow/test_guard_unless.zc
index d759551..5d58c82 100644
--- a/tests/control_flow/test_guard_unless.zc
+++ b/tests/control_flow/test_guard_unless.zc
@@ -17,7 +17,7 @@ test "test_guard_unless" {
println "Testing guard and unless...";
// Unless with true condition (should NOT enter block)
- var res1 = check_positive(10);
+ let res1 = check_positive(10);
if (res1 == 20) {
println " -> unless (pass condition): Passed";
} else {
@@ -26,7 +26,7 @@ test "test_guard_unless" {
}
// Unless with false condition (should enter block)
- var res2 = check_positive(-5);
+ let res2 = check_positive(-5);
if (res2 == -1) {
println " -> unless (fail condition): Passed";
} else {
@@ -35,9 +35,9 @@ test "test_guard_unless" {
}
// Guard with valid pointer
- var val = 42;
- var p = &val;
- var res3 = safe_access(p);
+ let val = 42;
+ let p = &val;
+ let res3 = safe_access(p);
if (res3 == 42) {
println " -> guard (valid ptr): Passed";
} else {
@@ -46,7 +46,7 @@ test "test_guard_unless" {
}
// Guard with null pointer
- var res4 = safe_access(NULL);
+ let res4 = safe_access(NULL);
if (res4 == -999) {
println " -> guard (null ptr): Passed";
} else {
diff --git a/tests/control_flow/test_if.zc b/tests/control_flow/test_if.zc
index 463405a..ed0f43d 100644
--- a/tests/control_flow/test_if.zc
+++ b/tests/control_flow/test_if.zc
@@ -1,10 +1,10 @@
test "test_if" {
- var x = 10;
+ let x = 10;
if (x > 5) {
printf("X is big\n");
- var y = x * 2;
+ let y = x * 2;
if (y > 15) {
printf("Y is very big\n");
}
@@ -12,7 +12,7 @@ test "test_if" {
printf("X is small\n");
}
- var i = 0;
+ let i = 0;
while (i < 3) {
println "Loop {i}";
i++;
diff --git a/tests/control_flow/test_labeled_break.zc b/tests/control_flow/test_labeled_break.zc
index 1900a99..f5ae5c0 100644
--- a/tests/control_flow/test_labeled_break.zc
+++ b/tests/control_flow/test_labeled_break.zc
@@ -1,7 +1,7 @@
test "test_labeled_break" -> int {
// Test basic goto-based loop exit
- var result = 0;
+ let result = 0;
for i in 0..10 {
for j in 0..10 {
@@ -16,7 +16,7 @@ done_search:
assert result == 3;
// Test do-while
- var x = 0;
+ let x = 0;
do {
x++;
} while x < 3;
diff --git a/tests/control_flow/test_loop_edge_cases.zc b/tests/control_flow/test_loop_edge_cases.zc
index b5ab0ce..5bd8b07 100644
--- a/tests/control_flow/test_loop_edge_cases.zc
+++ b/tests/control_flow/test_loop_edge_cases.zc
@@ -3,7 +3,7 @@ test "test_loop_edge_cases" {
println "Testing loop edge cases...";
// Empty range (0..0 should not iterate)
- var count1 = 0;
+ let count1 = 0;
for i in 0..0 {
count1++;
}
@@ -15,7 +15,7 @@ test "test_loop_edge_cases" {
}
// Single iteration range (0..1)
- var count2 = 0;
+ let count2 = 0;
for i in 0..1 {
count2++;
}
@@ -27,7 +27,7 @@ test "test_loop_edge_cases" {
}
// Repeat 0 times (should not execute)
- var count3 = 0;
+ let count3 = 0;
repeat 0 {
count3++;
}
@@ -39,7 +39,7 @@ test "test_loop_edge_cases" {
}
// Repeat 1 time
- var count4 = 0;
+ let count4 = 0;
repeat 1 {
count4++;
}
@@ -51,7 +51,7 @@ test "test_loop_edge_cases" {
}
// Nested loops
- var total = 0;
+ let total = 0;
for i in 0..3 {
for j in 0..2 {
total = total + 1;
@@ -65,10 +65,10 @@ test "test_loop_edge_cases" {
}
// Break in nested loop
- var outer_count = 0;
+ let outer_count = 0;
for i in 0..3 {
outer_count = outer_count + 1;
- var inner_done = 0;
+ let inner_done = 0;
loop {
inner_done = inner_done + 1;
if (inner_done >= 2) {
@@ -84,7 +84,7 @@ test "test_loop_edge_cases" {
}
// Large step value
- var count7 = 0;
+ let count7 = 0;
for i in 0..100 step 25 {
count7++;
}
diff --git a/tests/control_flow/test_loops.zc b/tests/control_flow/test_loops.zc
index 60ccc50..64579d3 100644
--- a/tests/control_flow/test_loops.zc
+++ b/tests/control_flow/test_loops.zc
@@ -3,7 +3,7 @@ test "test_loops" {
println "Testing loop constructs...";
// for-in range
- var sum1 = 0;
+ let sum1 = 0;
for i in 0..5 {
sum1 += i;
}
@@ -11,7 +11,7 @@ test "test_loops" {
println " -> for-in range (0..5): Passed";
// for-in with step
- var sum2 = 0;
+ let sum2 = 0;
for i in 0..10 step 2 {
sum2 += i;
}
@@ -19,7 +19,7 @@ test "test_loops" {
println " -> for-in with step: Passed";
// Repeat n times
- var count = 0;
+ let count = 0;
repeat 7 {
count++;
}
@@ -27,7 +27,7 @@ test "test_loops" {
println " -> repeat 7: Passed";
// loop with break
- var i = 0;
+ let i = 0;
loop {
i++;
if (i >= 5) {
@@ -38,7 +38,7 @@ test "test_loops" {
println " -> loop with break: Passed";
// While loop
- var j = 0;
+ let j = 0;
while j < 3 {
j++;
}
@@ -46,16 +46,16 @@ test "test_loops" {
println " -> while loop: Passed";
// C-style for loop
- var sum3 = 0;
- for (var k = 0; k < 4; k = k + 1) {
+ let sum3 = 0;
+ for (let k = 0; k < 4; k = k + 1) {
sum3 += k;
}
assert(sum3 == 6, "C-style for loop failed");
println " -> C-style for loop: Passed";
// loop with continue
- var sum4 = 0;
- var m = 0;
+ let sum4 = 0;
+ let m = 0;
loop {
m++;
if (m == 3) {
@@ -76,7 +76,7 @@ test "test_loops" {
}
fn print_nums(list: [int]) {
- var i = 0;
+ let i = 0;
while (i < list.len) {
println "Num: {list.data[i]}";
i++;
@@ -85,12 +85,12 @@ fn print_nums(list: [int]) {
test "test_arrays_loop" {
// Array literal transformation
- var nums: [int] = [10, 20, 30];
+ let nums: [int] = [10, 20, 30];
print_nums(nums);
}
test "test_do_while" {
- var x = 0;
+ let x = 0;
// Basic do-while (runs at least once)
do {
@@ -100,7 +100,7 @@ test "test_do_while" {
assert(x == 5, "do-while x expected 5");
// Do-while with false condition (still runs once)
- var y = 0;
+ let y = 0;
do {
y = 100;
} while false;
@@ -112,17 +112,17 @@ test "test_range_loops_generic" {
println "Testing range loops with different types...";
// Test with isize variables
- var sum_isize: isize = 0;
- var start: isize = 0;
- var end: isize = 5;
- for var i: isize = start; i < end; i++ {
+ let sum_isize: isize = 0;
+ let start: isize = 0;
+ let end: isize = 5;
+ for let i: isize = start; i < end; i++ {
sum_isize += i;
}
println "isize range (0..5): sum = {sum_isize}";
assert(sum_isize == 10, "isize range failed");
// Test with regular int
- var sum_int = 0;
+ let sum_int = 0;
for i in 0..5 {
sum_int += i;
}
@@ -133,7 +133,7 @@ test "test_range_loops_generic" {
}
test "inclusive range basic" {
- var count1 = 0
+ let count1 = 0
for i in 0..=5 {
count1 += 1
}
@@ -141,7 +141,7 @@ test "inclusive range basic" {
}
test "inclusive range single" {
- var count2 = 0
+ let count2 = 0
for i in 0..=0 {
count2 += 1
}
@@ -149,7 +149,7 @@ test "inclusive range single" {
}
test "inclusive range with step" {
- var sum = 0
+ let sum = 0
for i in 0..=10 step 2 {
sum += i
}
@@ -158,7 +158,7 @@ test "inclusive range with step" {
}
test "exclusive range regression check" {
- var count3 = 0
+ let count3 = 0
for i in 0..5 {
count3 += 1
}
@@ -166,7 +166,7 @@ test "exclusive range regression check" {
}
test "explicit exclusive range (..<)" {
- var count4 = 0
+ let count4 = 0
for i in 0..<5 {
count4 += 1
}
diff --git a/tests/control_flow/test_match.zc b/tests/control_flow/test_match.zc
index ca185ae..00c62e3 100644
--- a/tests/control_flow/test_match.zc
+++ b/tests/control_flow/test_match.zc
@@ -35,7 +35,7 @@ test "test_match" {
println "Testing match expressions...";
// Match with exact value (0)
- var res1 = classify_number(0);
+ let res1 = classify_number(0);
if (res1 == 100) {
println " -> match 0: Passed";
} else {
@@ -44,7 +44,7 @@ test "test_match" {
}
// Match with exact value (1)
- var res2 = classify_number(1);
+ let res2 = classify_number(1);
if (res2 == 200) {
println " -> match 1: Passed";
} else {
@@ -53,7 +53,7 @@ test "test_match" {
}
// Match with exact value (2)
- var res3 = classify_number(2);
+ let res3 = classify_number(2);
if (res3 == 300) {
println " -> match 2: Passed";
} else {
@@ -62,7 +62,7 @@ test "test_match" {
}
// Match with default case
- var res4 = classify_number(99);
+ let res4 = classify_number(99);
if (res4 == -1) {
println " -> match default: Passed";
} else {
@@ -71,7 +71,7 @@ test "test_match" {
}
// Match with complex body (zero)
- var sign1 = get_sign(0);
+ let sign1 = get_sign(0);
if (strcmp(sign1, "zero") == 0) {
println " -> match complex (zero): Passed";
} else {
@@ -80,7 +80,7 @@ test "test_match" {
}
// Match with complex body (positive)
- var sign2 = get_sign(42);
+ let sign2 = get_sign(42);
if (strcmp(sign2, "positive") == 0) {
println " -> match complex (positive): Passed";
} else {
@@ -89,7 +89,7 @@ test "test_match" {
}
// Match with complex body (negative)
- var sign3 = get_sign(-10);
+ let sign3 = get_sign(-10);
if (strcmp(sign3, "negative") == 0) {
println " -> match complex (negative): Passed";
} else {
@@ -98,8 +98,8 @@ test "test_match" {
}
// OR pattern with ||
- var or1 = classify_extended(1);
- var or2 = classify_extended(2);
+ let or1 = classify_extended(1);
+ let or2 = classify_extended(2);
if (or1 == 100 && or2 == 100) {
println " -> match OR (||): Passed";
} else {
@@ -108,8 +108,8 @@ test "test_match" {
}
// OR pattern with 'or'
- var or3 = classify_extended(3);
- var or4 = classify_extended(4);
+ let or3 = classify_extended(3);
+ let or4 = classify_extended(4);
if (or3 == 200 && or4 == 200) {
println " -> match OR (or): Passed";
} else {
@@ -118,9 +118,9 @@ test "test_match" {
}
// Range exclusive (5..8 matches 5, 6, 7)
- var r5 = classify_extended(5);
- var r7 = classify_extended(7);
- var r8 = classify_extended(8); // Should NOT match
+ let r5 = classify_extended(5);
+ let r7 = classify_extended(7);
+ let r8 = classify_extended(8); // Should NOT match
if (r5 == 300 && r7 == 300 && r8 == -1) {
println " -> match range exclusive: Passed";
} else {
@@ -129,9 +129,9 @@ test "test_match" {
}
// Range inclusive (10..=15 matches 10-15)
- var r10 = classify_extended(10);
- var r15 = classify_extended(15);
- var r16 = classify_extended(16); // Should NOT match
+ let r10 = classify_extended(10);
+ let r15 = classify_extended(15);
+ let r16 = classify_extended(16); // Should NOT match
if (r10 == 400 && r15 == 400 && r16 == -1) {
println " -> match range inclusive: Passed";
} else {
diff --git a/tests/control_flow/test_ternary.zc b/tests/control_flow/test_ternary.zc
index cfac28b..39f066f 100644
--- a/tests/control_flow/test_ternary.zc
+++ b/tests/control_flow/test_ternary.zc
@@ -5,8 +5,8 @@ enum Result {
}
fn test_unwrap() -> Result {
- var res = Result_Ok(42);
- var val = res?;
+ let res = Result_Ok(42);
+ let val = res?;
if (val == 42) println " Unwrap: Success";
else println " Unwrap: Failed";
return res;
@@ -16,7 +16,7 @@ test "test_ternary" {
println "Testing Ternary...";
// Simple Ternary
- var x = 1 ? 10 : 20;
+ let x = 1 ? 10 : 20;
if (x == 10) println " Simple Ternary: Success";
else println " Simple Ternary: Failed";
@@ -25,6 +25,6 @@ test "test_ternary" {
// Ambiguity / Precredence
// 1 ? 2 : 3
- var y = 0 ? 100 : 200;
+ let y = 0 ? 100 : 200;
if (y == 200) println " False Branch: Success";
}
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;
}
diff --git a/tests/functions/test_attributes.zc b/tests/functions/test_attributes.zc
index 6e52372..36ca3ad 100644
--- a/tests/functions/test_attributes.zc
+++ b/tests/functions/test_attributes.zc
@@ -50,8 +50,8 @@ struct NormalStruct {
b: U32;
}
-var init_called = 0;
-var cleanup_called = 0;
+let init_called = 0;
+let cleanup_called = 0;
@constructor
fn my_init() {
@@ -79,18 +79,18 @@ fn unused_func() {}
test "function attributes" {
// @must_use: result used - no warning
- var x = compute();
+ let x = compute();
assert(x == 42, "compute() failed");
// No must_use - can discard
optional_result();
// @inline works
- var sum = fast_add(1, 2);
+ let sum = fast_add(1, 2);
assert(sum == 3, "inline add failed");
// Combined attributes
- var c = combined();
+ let c = combined();
assert(c == 100, "combined failed");
// @must_use: result verified
diff --git a/tests/functions/test_implicit_return.zc b/tests/functions/test_implicit_return.zc
index bb35134..e82e286 100644
--- a/tests/functions/test_implicit_return.zc
+++ b/tests/functions/test_implicit_return.zc
@@ -12,7 +12,7 @@ test "test_implicit_return" {
println " Done!";
// With variables
- var x = 42;
+ let x = 42;
print "Value is: ";
println "{x}";
}
diff --git a/tests/functions/test_lambda_arrow.zc b/tests/functions/test_lambda_arrow.zc
index 111487d..b4c8edc 100644
--- a/tests/functions/test_lambda_arrow.zc
+++ b/tests/functions/test_lambda_arrow.zc
@@ -4,24 +4,24 @@ fn compute(op: fn(I32, I32) -> I32, a: I32, b: I32) -> I32 {
}
test "test_lambda_arrow" {
- var doubler = x -> x * 2;
- var res1 = doubler(5);
+ let doubler = x -> x * 2;
+ let res1 = doubler(5);
"doubler(5) = {res1}";
if res1 != 10 { exit(1); }
- var add = (x, y) -> x + y;
- var res2 = add(10, 20);
+ let add = (x, y) -> x + y;
+ let res2 = add(10, 20);
"add(10, 20) = {res2}";
if res2 != 30 { exit(1); }
- var res3 = compute((a, b) -> a * b, 3, 4);
+ let res3 = compute((a, b) -> a * b, 3, 4);
"compute((a, b) -> a * b, 3, 4) = {res3}";
if res3 != 12 { exit(1); }
}
test "lambda_inference_repro" {
- var dble = x -> x * 2.0;
- var res = dble(9.0);
+ let dble = x -> x * 2.0;
+ let res = dble(9.0);
if res != 18.0 {
exit(1);
}
diff --git a/tests/functions/test_lambdas.zc b/tests/functions/test_lambdas.zc
index a0daaf1..24cb65b 100644
--- a/tests/functions/test_lambdas.zc
+++ b/tests/functions/test_lambdas.zc
@@ -12,8 +12,8 @@ test "test_complex_lambdas" {
println "Testing complex lambda scenarios...";
// Lambda with multiple parameters
- var add_three = (a, b, c) -> a + b + c;
- var res1 = add_three(1, 2, 3);
+ let add_three = (a, b, c) -> a + b + c;
+ let res1 = add_three(1, 2, 3);
if (res1 == 6) {
println " -> Multi-param lambda: Passed";
} else {
@@ -22,7 +22,7 @@ test "test_complex_lambdas" {
}
// Higher-order function
- var res2 = apply_twice(x -> x * 2, 5);
+ let res2 = apply_twice(x -> x * 2, 5);
if (res2 == 20) {
println " -> Higher-order function: Passed";
} else {
@@ -31,8 +31,8 @@ test "test_complex_lambdas" {
}
// Returning a lambda (closure)
- var add10 = make_adder(10);
- var res3 = add10(5);
+ let add10 = make_adder(10);
+ let res3 = add10(5);
if (res3 == 15) {
println " -> Returned lambda: Passed";
} else {
@@ -41,9 +41,9 @@ test "test_complex_lambdas" {
}
// Lambda composition
- var doubler = x -> x * 2;
- var add5 = x -> x + 5;
- var res4 = add5(doubler(10));
+ let doubler = x -> x * 2;
+ let add5 = x -> x + 5;
+ let res4 = add5(doubler(10));
if (res4 == 25) {
println " -> Lambda composition: Passed";
} else {
@@ -52,7 +52,7 @@ test "test_complex_lambdas" {
}
// Nested application
- var res5 = apply_twice(x -> x + 1, apply_twice(x -> x * 2, 3));
+ let res5 = apply_twice(x -> x + 1, apply_twice(x -> x * 2, 3));
// (3 * 2) * 2 = 12, then (12 + 1) + 1 = 14
if (res5 == 14) {
println " -> Nested application: Passed";
@@ -62,8 +62,8 @@ test "test_complex_lambdas" {
}
// Lambda with "fn" syntax (eg. block lambda)
- var factor = 2;
- var full = fn(x: int) -> int { return x * factor };
+ let factor = 2;
+ let full = fn(x: int) -> int { return x * factor };
if (full(3) == 6) {
println " -> Lambda fn syntax: Passed";
@@ -73,7 +73,7 @@ test "test_complex_lambdas" {
}
// Lambda with "fn" syntax (eg. block lambda) + multiple params
- var addition = fn(sum1: int, sum2: int) -> int { return sum1 + sum2 };
+ let addition = fn(sum1: int, sum2: int) -> int { return sum1 + sum2 };
if (addition(100, 505) == 605) {
println " -> Lambda fn syntax: Passed";
@@ -83,7 +83,7 @@ test "test_complex_lambdas" {
}
// Lambda with "fn" syntax (eg. block lambda) + named args
- var substract = fn(arg1: int, arg2: int) -> int { return arg1 - arg2 };
+ let substract = fn(arg1: int, arg2: int) -> int { return arg1 - arg2 };
if (substract(arg1: 500, arg2: 100) == 400) {
println " -> Lambda fn syntax: Passed";
@@ -98,9 +98,9 @@ test "test_complex_lambdas" {
}
test "test_basic_closure" {
- var whatever = 10;
- var closure: fn(I32) -> I32 = x -> x + whatever;
- var res = closure(5);
+ let whatever = 10;
+ let closure: fn(I32) -> I32 = x -> x + whatever;
+ let res = closure(5);
// "Result: {res}";
if (res != 15) {
println "Closure failed: expected 15, got {res}";
diff --git a/tests/functions/test_must_use.zc b/tests/functions/test_must_use.zc
index a42b341..98936ea 100644
--- a/tests/functions/test_must_use.zc
+++ b/tests/functions/test_must_use.zc
@@ -26,7 +26,7 @@ fn optional_result() -> int {
test "attributes" {
// This should NOT warn (result used)
- var x = compute();
+ let x = compute();
assert(x == 42, "compute() should return 42");
// This should NOT warn (no must_use attribute)
@@ -36,11 +36,11 @@ test "attributes" {
compute();
// Test inline works
- var sum = fast_add(1, 2);
+ let sum = fast_add(1, 2);
assert(sum == 3, "inline add failed");
// Combined attributes
- var c = combined();
+ let c = combined();
assert(c == 100, "combined failed");
"Attributes test completed";
diff --git a/tests/functions/test_raw_func_ptr.zc b/tests/functions/test_raw_func_ptr.zc
index 16ec7df..115e421 100644
--- a/tests/functions/test_raw_func_ptr.zc
+++ b/tests/functions/test_raw_func_ptr.zc
@@ -16,12 +16,12 @@ test "raw_func_ptr_basic" {
}
test "raw_func_ptr_return_explicit" {
- var p: fn*(char*) = get_printer();
+ let p: fn*(char*) = get_printer();
p("Returned Ptr Explicit works");
}
test "fn_ptr_ptr" {
- var p: fn*(char*) = print_msg;
- var pp: fn**(char*) = &p;
+ let p: fn*(char*) = print_msg;
+ let pp: fn**(char*) = &p;
(*pp)("Double Pointer works");
}
diff --git a/tests/functions/test_varargs.zc b/tests/functions/test_varargs.zc
index b05e168..9b004db 100644
--- a/tests/functions/test_varargs.zc
+++ b/tests/functions/test_varargs.zc
@@ -4,7 +4,7 @@ test "test_varargs" {
println "Testing Varargs...";
printf(" Direct Printf: %d, %f, %s\n", 42, 3.14, "Hello");
- var buf = malloc(100);
+ let buf = malloc(100);
sprintf(buf, "Formatted: %d", 123);
println " {buf}";
}
diff --git a/tests/generics/test_generic_empty_struct.zc b/tests/generics/test_generic_empty_struct.zc
index f3e3c39..40a691a 100644
--- a/tests/generics/test_generic_empty_struct.zc
+++ b/tests/generics/test_generic_empty_struct.zc
@@ -65,7 +65,7 @@ impl Stack<T> {
fn pop(self) -> Optional<T> {
if (self.len > 0) {
- var result = Optional<T>{};
+ let result = Optional<T>{};
result.emplace(self.data[self.len - 1]);
self.len = self.len - 1;
return result;
@@ -75,10 +75,10 @@ impl Stack<T> {
}
test "Generic Empty Struct Init" {
- var s = Stack<i32>{};
+ let s = Stack<i32>{};
defer s.free();
s.push(123);
- var result = s.pop();
+ let result = s.pop();
assert(result.has_value(), "Result should have value");
assert(result.get() == 123, "Result value should be 123");
diff --git a/tests/generics/test_generic_operators.zc b/tests/generics/test_generic_operators.zc
index 8578d50..cd73999 100644
--- a/tests/generics/test_generic_operators.zc
+++ b/tests/generics/test_generic_operators.zc
@@ -13,9 +13,9 @@ impl Foo<T> {
}
test "generic neq" {
- var f1 = Foo<i32>{value: 10};
- var f2 = Foo<i32>{value: 20};
- var f3 = Foo<i32>{value: 10};
+ let f1 = Foo<i32>{value: 10};
+ let f2 = Foo<i32>{value: 20};
+ let f3 = Foo<i32>{value: 10};
assert(f1 != f2, "f1 should not equal f2");
assert(f1 == f3, "f1 should equal f3");
diff --git a/tests/generics/test_generic_ptr.zc b/tests/generics/test_generic_ptr.zc
index e08caba..fdcb9db 100644
--- a/tests/generics/test_generic_ptr.zc
+++ b/tests/generics/test_generic_ptr.zc
@@ -4,15 +4,15 @@ import "std/result.zc"
test "generic pointer instantiation" {
// Vector of ints (internally int*) nested in Result
- var v = Vec<int>::new();
+ let v = Vec<int>::new();
v.push(10);
v.push(20);
v.push(30);
- var res = Result<Vec<int>>::Ok(v);
+ let res = Result<Vec<int>>::Ok(v);
// Test unwrapping (signatures involving int*)
- var unwrapped = res.unwrap_ref();
+ let unwrapped = res.unwrap_ref();
assert(unwrapped.get(0) == 10);
assert(unwrapped.get(1) == 20);
assert(unwrapped.get(2) == 30);
@@ -23,15 +23,15 @@ test "generic pointer instantiation" {
test "generic pointer double nesting" {
// Double nesting - Result<Vec<int*>>
- var v_ptr = Vec<int*>::new();
- var a: int = 100;
- var b: int = 200;
+ let v_ptr = Vec<int*>::new();
+ let a: int = 100;
+ let b: int = 200;
v_ptr.push(&a);
v_ptr.push(&b);
- var res_ptr = Result<Vec<int*>>::Ok(v_ptr);
- var unwrapped_ptr = res_ptr.unwrap();
+ let res_ptr = Result<Vec<int*>>::Ok(v_ptr);
+ let unwrapped_ptr = res_ptr.unwrap();
assert(*unwrapped_ptr.get(0) == 100);
assert(*unwrapped_ptr.get(1) == 200);
diff --git a/tests/generics/test_generic_traits.zc b/tests/generics/test_generic_traits.zc
index 8458ba0..5e83f25 100644
--- a/tests/generics/test_generic_traits.zc
+++ b/tests/generics/test_generic_traits.zc
@@ -14,8 +14,8 @@ impl MyClone for GBox<T> {
}
test "generic_trait_method_resolution" {
- var b = GBox<int>{ val: 10 };
- var res = b.my_clone();
+ let b = GBox<int>{ val: 10 };
+ let res = b.my_clone();
assert(res == 1, "Generic trait method call failed");
}
@@ -34,9 +34,9 @@ impl ValueProvider for Wrapper<T> {
}
test "generic_trait_resolution_complex" {
- var w = Wrapper<bool>{ inner: true };
+ let w = Wrapper<bool>{ inner: true };
assert(w.get_value() == 42, "Wrapper<bool> trait call failed");
- var w2 = Wrapper<int>{ inner: 100 };
+ let w2 = Wrapper<int>{ inner: 100 };
assert(w2.get_value() == 42, "Wrapper<int> trait call failed");
}
diff --git a/tests/generics/test_generics_fn.zc b/tests/generics/test_generics_fn.zc
index 03f751a..9343004 100644
--- a/tests/generics/test_generics_fn.zc
+++ b/tests/generics/test_generics_fn.zc
@@ -16,11 +16,11 @@ impl Box<T> {
test "Generics" {
// Generic Function
- var i = identity<int>(42);
+ let i = identity<int>(42);
assert(i == 42, "Generic function failed");
// Generic Struct & Impl
- var b = Box<int> { val: 100 };
+ let b = Box<int> { val: 100 };
assert(b.get() == 100, "Generic impl failed");
}
@@ -33,7 +33,7 @@ impl Container {
}
test "Generic Method in Regular Impl" {
- var c = Container{};
+ let c = Container{};
assert(c.check_size<int>(10) == sizeof(int), "Generic method int size");
assert(c.check_size<double>(3.14) == sizeof(double), "Generic method double size");
}
diff --git a/tests/generics/test_generics_struct.zc b/tests/generics/test_generics_struct.zc
index ae61e4c..cefe79c 100644
--- a/tests/generics/test_generics_struct.zc
+++ b/tests/generics/test_generics_struct.zc
@@ -6,7 +6,7 @@ struct Wrapper<T> {
test "test_generics_struct" {
// Instantiate with int
- var w1: Wrapper<int>;
+ let w1: Wrapper<int>;
w1.id = 1;
w1.item = 500;
diff --git a/tests/generics/test_multi_generics.zc b/tests/generics/test_multi_generics.zc
index 00d735e..d29556c 100644
--- a/tests/generics/test_multi_generics.zc
+++ b/tests/generics/test_multi_generics.zc
@@ -21,7 +21,7 @@ fn make_triple<X, Y, Z>(x: X, y: Y, z: Z) -> Triple<X, Y, Z> {
}
test "multi-type generics basic" {
- var p: Pair<int, float>;
+ let p: Pair<int, float>;
p.first = 42;
p.second = 3.14;
assert(p.first == 42, "First field failed");
@@ -29,13 +29,13 @@ test "multi-type generics basic" {
}
test "generic function with 2 params" {
- var p = make_pair<int, float>(100, 2.5);
+ let p = make_pair<int, float>(100, 2.5);
assert(p.first == 100, "Pair first failed");
println "2-param generic function passed!";
}
test "generic function with 3 params" {
- var t = make_triple<int, float, bool>(42, 3.14, true);
+ let t = make_triple<int, float, bool>(42, 3.14, true);
assert(t.first == 42, "Triple first failed");
assert(t.third == true, "Triple third failed");
println "3-param generic function passed!";
diff --git a/tests/generics/test_sizeof_template.zc b/tests/generics/test_sizeof_template.zc
index 8390512..bf4dd51 100644
--- a/tests/generics/test_sizeof_template.zc
+++ b/tests/generics/test_sizeof_template.zc
@@ -3,14 +3,14 @@ struct Struct<T> {
}
fn hello<T>() {
- var s = sizeof(Struct<T>);
+ let s = sizeof(Struct<T>);
println "size: {s}";
}
test "sizeof template" {
- var _first: Struct<i32>;
+ let _first: Struct<i32>;
hello<i32>();
- var _second: Struct<f64>;
+ let _second: Struct<f64>;
hello<f64>();
}
@@ -20,9 +20,9 @@ struct Mixed<T> {
}
test "sizeof mixed" {
- var s1 = sizeof(Mixed<i32>);
+ let s1 = sizeof(Mixed<i32>);
println "i32 mixed: {s1}";
- var s2 = sizeof(Mixed<f64>);
+ let s2 = sizeof(Mixed<f64>);
println "f64 mixed: {s2}";
}
@@ -33,8 +33,8 @@ struct PackedMixed<T> {
}
test "sizeof packed mixed" {
- var s1 = sizeof(PackedMixed<i32>);
+ let s1 = sizeof(PackedMixed<i32>);
println "i32 packed mixed: {s1}";
- var s2 = sizeof(PackedMixed<f64>);
+ let s2 = sizeof(PackedMixed<f64>);
println "f64 packed mixed: {s2}";
} \ No newline at end of file
diff --git a/tests/interop/test_c_import.zc b/tests/interop/test_c_import.zc
index ed95bc1..207aff0 100644
--- a/tests/interop/test_c_import.zc
+++ b/tests/interop/test_c_import.zc
@@ -2,7 +2,7 @@
import "math.h" as m;
test "test_c_import" {
- var x = m::sin(0.0);
+ let x = m::sin(0.0);
if x == 0.0 {
println "Success: m::sin(0.0) == 0.0";
@@ -16,8 +16,8 @@ test "test_c_import" {
extern fn abs(x: int) -> int;
test "test_interop_abs" {
- var x = -10;
- var y = abs(x);
+ let x = -10;
+ let y = abs(x);
if (y == 10) println "Abs works";
else {
println "Abs failed";
diff --git a/tests/interop/test_c_macros.zc b/tests/interop/test_c_macros.zc
index 0b1fc64..b1b9b68 100644
--- a/tests/interop/test_c_macros.zc
+++ b/tests/interop/test_c_macros.zc
@@ -3,7 +3,7 @@
#define DEBUG_MODE 1
test "test_c_macros" {
- var x = MAX(10, 20);
+ let x = MAX(10, 20);
if x == 20 {
println "MAX macro worked";
diff --git a/tests/memory/test_copy_trait.zc b/tests/memory/test_copy_trait.zc
index 994ccee..c31119c 100644
--- a/tests/memory/test_copy_trait.zc
+++ b/tests/memory/test_copy_trait.zc
@@ -13,8 +13,8 @@ struct Mover {
}
test "copy_trait" {
- var p1 = Point { x: 10, y: 20 };
- var p2 = p1; // Copy, not move
+ let p1 = Point { x: 10, y: 20 };
+ let p2 = p1; // Copy, not move
// Both should be valid
assert(p1.x == 10, "p1 invalid after copy");
@@ -29,9 +29,9 @@ test "copy_trait" {
}
test "move_default" {
- var m1 = Mover { val: 1 };
- var m2 = m1; // Moved
+ let m1 = Mover { val: 1 };
+ let m2 = m1; // Moved
// Uncommenting this should cause compile error
- // var m3 = m1;
+ // let m3 = m1;
}
diff --git a/tests/memory/test_drop.zc b/tests/memory/test_drop.zc
index 8b34efe..6b1ccdf 100644
--- a/tests/memory/test_drop.zc
+++ b/tests/memory/test_drop.zc
@@ -1,6 +1,6 @@
import "../../std/mem.zc"
-var DROP_CALLED = 0;
+let DROP_CALLED = 0;
struct MyResource {
id: int;
@@ -15,7 +15,7 @@ impl Drop for MyResource {
test "drop_trait" {
{
- var res = MyResource { id: 1 };
+ let res = MyResource { id: 1 };
// Scope ends here, drop should be called
}
diff --git a/tests/memory/test_drop_flags.zc b/tests/memory/test_drop_flags.zc
index 753fc83..8a25d8d 100644
--- a/tests/memory/test_drop_flags.zc
+++ b/tests/memory/test_drop_flags.zc
@@ -1,7 +1,7 @@
import "../../std/mem.zc"
// Global to track destructor calls
-var DTOR_COUNT = 0;
+let DTOR_COUNT = 0;
struct Buffer {
data: int*;
@@ -23,9 +23,9 @@ test "drop_flags_variable_move" {
DTOR_COUNT = 0;
{
println "Init";
- var buffer = Buffer { data: malloc(100) };
+ let buffer = Buffer { data: malloc(100) };
println "Moved";
- var buf = buffer; // Move occurs
+ let buf = buffer; // Move occurs
// buffer is moved-from. Flag should prevent destructor.
// buf owns data.
}
diff --git a/tests/memory/test_memory_safety.zc b/tests/memory/test_memory_safety.zc
index c7ba01d..a5cc960 100644
--- a/tests/memory/test_memory_safety.zc
+++ b/tests/memory/test_memory_safety.zc
@@ -2,7 +2,7 @@
import "std/mem.zc"
// ** Globals **
-var DROP_COUNT = 0;
+let DROP_COUNT = 0;
// ** Structs & Helpers **
@@ -20,7 +20,7 @@ impl Drop for Resource {
}
fn create_resource(id: int) {
- var r = Resource{id: id};
+ let r = Resource{id: id};
println "Created Resource {r.id}";
}
@@ -30,14 +30,14 @@ struct Point {
}
fn distance(p1: Point, p2: Point) -> int {
- var dx = p2.x - p1.x;
- var dy = p2.y - p1.y;
+ let dx = p2.x - p1.x;
+ let dy = p2.y - p1.y;
return dx * dx + dy * dy;
}
fn accumulate(start: int, count: int) -> int {
- var sum = start;
- var i = 0;
+ let sum = start;
+ let i = 0;
while (i < count) {
sum += i;
i++;
@@ -46,14 +46,14 @@ fn accumulate(start: int, count: int) -> int {
}
fn process_point(p: Point) -> Point {
- var result = Point { x: p.x * 2, y: p.y * 2 };
+ let result = Point { x: p.x * 2, y: p.y * 2 };
return result;
}
fn counter_immut() {
- var count = 0;
+ let count = 0;
{
- var inner = 10;
+ let inner = 10;
inner = inner + 5;
count = count + inner;
}
@@ -87,7 +87,7 @@ fn release_resource(id: int) {
fn test_defer_logic() {
println "start test";
- var x = get_resource() defer release_resource(it);
+ let x = get_resource() defer release_resource(it);
println "using resource {x}";
}
@@ -95,14 +95,14 @@ fn test_defer_logic() {
test "test_alloc" {
"Testing alloc<T>...";
- var p = alloc<int>();
+ let p = alloc<int>();
*p = 42;
f" alloc<int>(): {*p}";
assert(*p == 42, "alloc failed");
free(p);
- var arr = alloc_n<int>(5);
- for var i = 0; i < 5; i++ {
+ let arr = alloc_n<int>(5);
+ for let i = 0; i < 5; i++ {
arr[i] = i * 10;
}
f" alloc_n<int>(5): [{arr[0]}, {arr[1]}, {arr[2]}, {arr[3]}, {arr[4]}]";
@@ -113,9 +113,9 @@ test "test_alloc" {
test "test_box" {
"Testing Box<T>...";
- var b = Box<int>::new();
+ let b = Box<int>::new();
*b.get() = 100;
- var val = *b.get();
+ let val = *b.get();
f" Box value: {val}";
assert(val == 100, "Box failed");
b.free();
@@ -124,14 +124,14 @@ test "test_box" {
test "test_slice" {
"Testing Slice<T>...";
- var data: int[5] = [1, 2, 3, 4, 5];
- var s = Slice<int>::new(&data[0], 5);
+ let data: int[5] = [1, 2, 3, 4, 5];
+ let s = Slice<int>::new(&data[0], 5);
f" Slice len: {(int)s.len}";
- var v2 = s.get(2);
+ let v2 = s.get(2);
f" Slice[2]: {v2}";
assert(v2 == 3, "Slice get failed");
s.set(0, 99);
- var v0 = s.get(0);
+ let v0 = s.get(0);
f" After set: Slice[0] = {v0}";
assert(v0 == 99, "Slice set failed");
" ✓ Slice works!";
@@ -139,8 +139,8 @@ test "test_slice" {
test "test_swap" {
"Testing swap<T>...";
- var a = 10;
- var b = 20;
+ let a = 10;
+ let b = 20;
f" Before: a={a}, b={b}";
swap<int>(&a, &b);
f" After: a={a}, b={b}";
@@ -151,15 +151,15 @@ test "test_swap" {
test "test_autofree" {
println "Testing autofree...";
{
- autofree var p = malloc(1024);
+ autofree let p = malloc(1024);
if (p == NULL) { eprintln "Malloc failed!"; }
strcpy(p, "Auto-freed string");
print f"Allocated: {p}"; println "";
}
println "Exited block successfully (hopefully freed)";
{
- autofree var p1 = malloc(10);
- autofree var p2 = malloc(20);
+ autofree let p1 = malloc(10);
+ autofree let p2 = malloc(20);
}
}
@@ -170,20 +170,20 @@ test "test_raii_drop" {
"Exited scope.";
assert(DROP_COUNT == 1, "Expected Drop to be called once");
{
- var r2 = Resource{id: 2};
- var r3 = Resource{id: 3};
+ let r2 = Resource{id: 2};
+ let r3 = Resource{id: 3};
}
assert(DROP_COUNT == 3, "Expected 3 total drops");
}
test "test_immutable" {
- var p1 = Point { x: 0, y: 0 };
- var p2 = Point { x: 3, y: 4 };
- var dist = distance(p1, p2);
+ let p1 = Point { x: 0, y: 0 };
+ let p2 = Point { x: 3, y: 4 };
+ let dist = distance(p1, p2);
"Distance: {dist}";
- var sum = accumulate(10, 5);
+ let sum = accumulate(10, 5);
"Accumulate: {sum}";
- var p3 = process_point(Point { x: 0, y: 0 });
+ let p3 = process_point(Point { x: 0, y: 0 });
"Processed: ({p3.x}, {p3.y})";
counter_immut();
}
@@ -193,11 +193,11 @@ test "test_permissions" {
def WRITE : U8 = 0b010;
def EXEC : U8 = 0b001;
- var p1 = Permissions::new(READ);
+ let p1 = Permissions::new(READ);
"Start: {p1.mask} (Read)";
- var p2 = Permissions::new(WRITE);
- var p_rw = p1 | p2;
+ let p2 = Permissions::new(WRITE);
+ let p_rw = p1 | p2;
"Combined: {p_rw.mask} (Read + Write)";
if (p_rw.has(EXEC)) { " > Has Execute access"; }
@@ -205,7 +205,7 @@ test "test_permissions" {
if (p_rw.has(READ)) { " > Has Read access"; }
- var p_all = p_rw | Permissions::new(EXEC);
+ let p_all = p_rw | Permissions::new(EXEC);
"Final: {p_all.mask} (All)";
}
diff --git a/tests/memory/test_move_double_free.zc b/tests/memory/test_move_double_free.zc
index 8322bcd..74a794c 100644
--- a/tests/memory/test_move_double_free.zc
+++ b/tests/memory/test_move_double_free.zc
@@ -1,8 +1,8 @@
import "../../std/mem.zc"
// Global counters to track drop calls
-var DROP_COUNT = 0;
-var DROP_NULL_COUNT = 0;
+let DROP_COUNT = 0;
+let DROP_NULL_COUNT = 0;
struct Resource {
data: int*;
@@ -32,8 +32,8 @@ test "move_variable" {
DROP_NULL_COUNT = 0;
{
- var r1 = Resource { data: malloc(10), id: 1 };
- var r2 = r1; // Move
+ let r1 = Resource { data: malloc(10), id: 1 };
+ let r2 = r1; // Move
// r1 should be nullified
// r2 owns data
@@ -52,8 +52,8 @@ test "move_function" {
DROP_NULL_COUNT = 0;
{
- var r1 = Resource { data: malloc(10), id: 2 };
- var r2 = pass_through(r1);
+ let r1 = Resource { data: malloc(10), id: 2 };
+ let r2 = pass_through(r1);
// r1 moved to arg -> moved to return -> moved to r2
}
@@ -73,8 +73,8 @@ test "partial_move_member" {
DROP_NULL_COUNT = 0;
{
- var c = Container { res: Resource { data: malloc(10), id: 3 } };
- var r = c.res; // Partial move
+ let c = Container { res: Resource { data: malloc(10), id: 3 } };
+ let r = c.res; // Partial move
// c.res should be nullified
// r owns data
diff --git a/tests/memory/test_move_semantics.zc b/tests/memory/test_move_semantics.zc
index bf0d717..0ccd822 100644
--- a/tests/memory/test_move_semantics.zc
+++ b/tests/memory/test_move_semantics.zc
@@ -8,29 +8,29 @@ struct Mover {
}
test "basic_move" {
- var p1 = Mover { val: 10 };
- var p2 = p1; // p1 moved to p2
+ let p1 = Mover { val: 10 };
+ let p2 = p1; // p1 moved to p2
// Valid usage of p2
assert(p2.val == 10, "p2 should be valid");
// Invalid usage of p1 (Uncomment to test compiler error)
- // var p3 = p1;
+ // let p3 = p1;
}
test "primitive_copy" {
- var i = 10;
- var j = i; // Copy
- var k = i; // Copy again - should be valid
+ let i = 10;
+ let j = i; // Copy
+ let k = i; // Copy again - should be valid
assert(k == 10, "Primitive copy failed");
}
test "reassignment" {
- var m1 = Mover { val: 1 };
- var m2 = m1; // m1 moved
+ let m1 = Mover { val: 1 };
+ let m2 = m1; // m1 moved
m1 = Mover { val: 2 }; // Resurrect m1
- var m3 = m1; // Valid now
+ let m3 = m1; // Valid now
assert(m3.val == 2, "Resurrection failed");
}
@@ -39,7 +39,7 @@ fn consume(m: Mover) {
}
test "func_arg" {
- var m = Mover { val: 10 };
+ let m = Mover { val: 10 };
consume(m); // m moved
// 2. Use after move (Call - Negative Test)
@@ -49,7 +49,7 @@ test "func_arg" {
/*
// 3. Use after return (Negative Test)
fn fail_return(m: Mover) -> Mover {
- var m2 = m;
+ let m2 = m;
return m; // Should fail: Use of moved value 'm'
}
*/
diff --git a/tests/memory/test_resources.zc b/tests/memory/test_resources.zc
index dc7b9f9..e21653d 100644
--- a/tests/memory/test_resources.zc
+++ b/tests/memory/test_resources.zc
@@ -29,12 +29,12 @@ fn take_point(p: Point) {
test "Resource Semantics" {
"Testing Resource Semantics...";
- var p1 = Point{x: 10, y: 20};
- var p2 = p1; // Copied
+ let p1 = Point{x: 10, y: 20};
+ let p2 = p1; // Copied
- var b1 = Box{val: 99};
- var b2 = b1.clone();
- // var b3 = b1; // This would move if uncommented.
+ let b1 = Box{val: 99};
+ let b2 = b1.clone();
+ // let b3 = b1; // This would move if uncommented.
if b2.val != 99 {
!"Clone failed";
@@ -44,11 +44,11 @@ test "Resource Semantics" {
// Re-initialization
// struct Resource (Global)
- var r1 = Resource{ptr: NULL};
- var r2 = r1; // Moved
+ let r1 = Resource{ptr: NULL};
+ let r2 = r1; // Moved
r1 = Resource{ptr: NULL}; // Re-init
- var r3 = r1; // Valid again
+ let r3 = r1; // Valid again
// Function Param Move (Simulated)
take_point(p1);
diff --git a/tests/memory/test_unsafe.zc b/tests/memory/test_unsafe.zc
index 126404a..fe1150f 100644
--- a/tests/memory/test_unsafe.zc
+++ b/tests/memory/test_unsafe.zc
@@ -9,46 +9,46 @@ raw {
extern fn legacy_add(a: int, b: int) -> int;
fn process_arrays(n: int, a: restrict int*, b: restrict int*, out: restrict int*) {
- for (var i = 0; i < n; i = i + 1) {
+ for (let i = 0; i < n; i = i + 1) {
out[i] = a[i] + b[i];
}
}
fn counter() -> int {
- static var count = 0;
+ static let count = 0;
count = count + 1;
return count;
}
test "test_raw" {
println "Testing Raw C Embedding...";
- var res = legacy_add(10, 20);
+ let res = legacy_add(10, 20);
// Expected: 10 + 20 + 12345 = 12375
assert(res == 12375, "Raw C Code failed");
println " Raw C Code: Success (Result: {res})";
}
test "test_restrict" {
- var a: int[10];
- var b: int[10];
- var c: int[10];
+ let a: int[10];
+ let b: int[10];
+ let c: int[10];
- for (var i = 0; i < 10; i = i + 1) {
+ for (let i = 0; i < 10; i = i + 1) {
a[i] = i;
b[i] = i * 2;
}
process_arrays(10, a, b, c);
- for (var i = 0; i < 10; i = i + 1) {
+ for (let i = 0; i < 10; i = i + 1) {
assert(c[i] == i * 3, "Restrict test failed");
}
}
test "test_static_local" {
- var a = counter(); // 1
- var b = counter(); // 2
- var c = counter(); // 3
+ let a = counter(); // 1
+ let b = counter(); // 2
+ let c = counter(); // 3
assert a == 1;
assert b == 2;
diff --git a/tests/misc/test_advanced.zc b/tests/misc/test_advanced.zc
index 8b5b466..e985758 100644
--- a/tests/misc/test_advanced.zc
+++ b/tests/misc/test_advanced.zc
@@ -8,7 +8,7 @@ fn fibonacci(n: int) -> int {
}
fn test_recursion() {
- var fib10 = fibonacci(10);
+ let fib10 = fibonacci(10);
if (fib10 != 55) {
println "FAIL: fibonacci(10) should be 55";
@@ -23,7 +23,7 @@ fn add_three(a: int, b: int, c: int) -> int {
}
fn test_multi_params() {
- var result = add_three(1, 2, 3);
+ let result = add_three(1, 2, 3);
if (result != 6) {
println "FAIL: add_three(1,2,3) should be 6";
@@ -38,7 +38,7 @@ fn double_val(x: int) -> int {
}
fn test_nested_calls() {
- var result = double_val(double_val(double_val(2)));
+ let result = double_val(double_val(double_val(2)));
if (result != 16) {
println "FAIL: nested calls failed";
@@ -67,7 +67,7 @@ impl Counter {
}
fn test_struct_methods() {
- var c = Counter::new();
+ let c = Counter::new();
c.increment();
c.increment();
c.increment();
@@ -81,16 +81,16 @@ fn test_struct_methods() {
}
fn test_casting() {
- var f: float = 3.7;
- var i: int = (int)f;
+ let f: float = 3.7;
+ let i: int = (int)f;
if (i != 3) {
println "FAIL: float to int cast failed";
exit(1);
}
- var i2: int = 42;
- var f2: float = (float)i2;
+ let i2: int = 42;
+ let f2: float = (float)i2;
if (f2 < 41.9 || f2 > 42.1) {
println "FAIL: int to float cast failed";
@@ -101,12 +101,12 @@ fn test_casting() {
}
fn test_bitwise() {
- var a = 0b1010; // 10
- var b = 0b1100; // 12
+ let a = 0b1010; // 10
+ let b = 0b1100; // 12
- var and_result = a & b; // 0b1000 = 8
- var or_result = a | b; // 0b1110 = 14
- var xor_result = a ^ b; // 0b0110 = 6
+ let and_result = a & b; // 0b1000 = 8
+ let or_result = a | b; // 0b1110 = 14
+ let xor_result = a ^ b; // 0b0110 = 6
if (and_result != 8) {
println "FAIL: bitwise AND failed";
@@ -127,16 +127,16 @@ fn test_bitwise() {
}
fn test_shift() {
- var x = 1;
- var left = x << 4; // 16
+ let x = 1;
+ let left = x << 4; // 16
if (left != 16) {
println "FAIL: left shift failed";
exit(1);
}
- var y = 32;
- var right = y >> 2; // 8
+ let y = 32;
+ let right = y >> 2; // 8
if (right != 8) {
println "FAIL: right shift failed";
@@ -147,9 +147,9 @@ fn test_shift() {
}
fn test_modulo() {
- var a = 17;
- var b = 5;
- var result = a % b;
+ let a = 17;
+ let b = 5;
+ let result = a % b;
if (result != 2) {
println "FAIL: modulo operation failed";
@@ -160,11 +160,11 @@ fn test_modulo() {
}
fn test_compound_expr() {
- var x = 5;
- var y = 10;
- var z = 3;
+ let x = 5;
+ let y = 10;
+ let z = 3;
- var result = (x + y) * z - (y / 2);
+ let result = (x + y) * z - (y / 2);
// (5 + 10) * 3 - (10 / 2) = 15 * 3 - 5 = 45 - 5 = 40
if (result != 40) {
@@ -176,7 +176,7 @@ fn test_compound_expr() {
}
fn test_increment_style() {
- var x = 5;
+ let x = 5;
x = x + 1;
if (x != 6) {
diff --git a/tests/misc/test_chained.zc b/tests/misc/test_chained.zc
index e758db7..a92ae18 100644
--- a/tests/misc/test_chained.zc
+++ b/tests/misc/test_chained.zc
@@ -2,8 +2,8 @@
import "std/string.zc"
test "test_chained" {
- var s = String::from("hello");
- var opt = s.find('e');
+ let s = String::from("hello");
+ let opt = s.find('e');
if opt.is_some() {
"Found at index: {opt.unwrap()}";
}
diff --git a/tests/misc/test_edge_cases.zc b/tests/misc/test_edge_cases.zc
index 0d50744..79a927f 100644
--- a/tests/misc/test_edge_cases.zc
+++ b/tests/misc/test_edge_cases.zc
@@ -6,8 +6,8 @@ import "std.zc"
struct Empty {}
fn test_empty_struct() {
- var e1 = Empty {};
- var e2 = Empty {};
+ let e1 = Empty {};
+ let e2 = Empty {};
if (!e1.eq(&e2)) {
println "FAIL: Empty struct eq failed";
@@ -31,9 +31,9 @@ struct ManyFields {
}
fn test_many_fields() {
- var m1 = ManyFields { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8 };
- var m2 = ManyFields { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8 };
- var m3 = ManyFields { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 9 }; // h differs
+ let m1 = ManyFields { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8 };
+ let m2 = ManyFields { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8 };
+ let m3 = ManyFields { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 9 }; // h differs
if (!m1.eq(&m2)) {
println "FAIL: equal structs not detected as equal";
@@ -55,11 +55,11 @@ struct Point {
}
fn test_pointer_equality() {
- var p1 = Point { x: 1, y: 2 };
- var ptr1: Point* = &p1;
- var ptr2: Point* = &p1;
- var p2 = Point { x: 1, y: 2 };
- var ptr3: Point* = &p2;
+ let p1 = Point { x: 1, y: 2 };
+ let ptr1: Point* = &p1;
+ let ptr2: Point* = &p1;
+ let p2 = Point { x: 1, y: 2 };
+ let ptr3: Point* = &p2;
// Same pointer should be equal
if (ptr1 != ptr2) {
@@ -78,7 +78,7 @@ fn test_pointer_equality() {
// Very long string
fn test_long_string() {
- var s = String::from("This is a very long string that should test the string handling capabilities of the compiler and make sure that buffer allocations are correct and that there are no overflow issues with long strings.");
+ let s = String::from("This is a very long string that should test the string handling capabilities of the compiler and make sure that buffer allocations are correct and that there are no overflow issues with long strings.");
if (s.length() < 100) {
println "FAIL: long string length incorrect";
@@ -90,7 +90,7 @@ fn test_long_string() {
// Null pointer handling
fn test_null_pointer() {
- var ptr: int* = NULL;
+ let ptr: int* = NULL;
if (ptr != NULL) {
println "FAIL: NULL pointer check failed";
@@ -102,8 +102,8 @@ fn test_null_pointer() {
// Numeric edge cases
fn test_numeric_edges() {
- var max_int: int = 2147483647;
- var min_int: int = -1000000000;
+ let max_int: int = 2147483647;
+ let min_int: int = -1000000000;
if (max_int <= 0) {
println "FAIL: max_int is wrong";
@@ -120,8 +120,8 @@ fn test_numeric_edges() {
// Boolean operations
fn test_boolean_ops() {
- var a = true;
- var b = false;
+ let a = true;
+ let b = false;
if (!(a && !b)) {
println "FAIL: boolean AND failed";
diff --git a/tests/misc/test_mix.zc b/tests/misc/test_mix.zc
index b4edca4..f2880e9 100644
--- a/tests/misc/test_mix.zc
+++ b/tests/misc/test_mix.zc
@@ -13,12 +13,12 @@ fn square(x: int) -> int {
}
test "test_result_constructors" {
- var res = Result_Ok(42);
+ let res = Result_Ok(42);
assert(res.tag == Result_Ok_Tag, "Expected Ok tag");
assert(res.data.Ok == 42, "Data mismatch");
- var err = Result_Err(500);
+ let err = Result_Err(500);
assert(err.tag == Result_Err_Tag, "Expected Err tag");
}
@@ -26,17 +26,17 @@ test "test_pipelines" {
// Logic: ((5 + 5) * (5 + 5))
// 5 |> add(5) -> 10
// 10 |> square() -> 100
- var val = 5 |> add(5) |> square();
+ let val = 5 |> add(5) |> square();
println "Pipeline result: {val}";
assert(val == 100, "Pipeline calculation failed");
}
test "test_fstrings" {
- var x = 10;
- var name = "ZPrep";
+ let x = 10;
+ let name = "ZPrep";
- var s = f"Hello {name}, x = {x}, x * 2 = {x * 2}";
+ let s = f"Hello {name}, x = {x}, x * 2 = {x * 2}";
println "F-String: {s}";
assert(x == 10, "Sanity check");
@@ -52,8 +52,8 @@ test "test_defer" {
}
test "test_hex_binary" {
- var h = 0xFF; // 255
- var b = 0b1010; // 10
+ let h = 0xFF; // 255
+ let b = 0b1010; // 10
assert(h == 255, "Hex parsing failed");
assert(b == 10, "Binary parsing failed");
}
diff --git a/tests/modules/test_aliasing.zc b/tests/modules/test_aliasing.zc
index 468e558..ba8f759 100644
--- a/tests/modules/test_aliasing.zc
+++ b/tests/modules/test_aliasing.zc
@@ -3,8 +3,8 @@ import { Vector as MathVec } from "./test_modules/_math.zc";
import { Vector as PhysicsVec } from "./test_modules/_physics.zc";
test "test_selective_aliasing" {
- var mv = MathVec::new(3, 4);
- var pv = PhysicsVec::new(5.0, 12.0);
+ let mv = MathVec::new(3, 4);
+ let pv = PhysicsVec::new(5.0, 12.0);
assert(mv.x == 3 && mv.y == 4, "MathVec initialization failed");
assert(pv.vx == 5.0 && pv.vy == 12.0, "PhysicsVec initialization failed");
diff --git a/tests/modules/test_namespaced.zc b/tests/modules/test_namespaced.zc
index afc1d6c..67db941 100644
--- a/tests/modules/test_namespaced.zc
+++ b/tests/modules/test_namespaced.zc
@@ -3,11 +3,11 @@ import "./test_modules/_math.zc" as math;
import "./test_modules/_physics.zc" as physics;
test "test_namespaced_imports" {
- var mv = math::Vector::new(3, 4);
- var pv = physics::Vector::new(5.0, 12.0);
+ let mv = math::Vector::new(3, 4);
+ let pv = physics::Vector::new(5.0, 12.0);
- var len1 = math::Vector::length(&mv);
- var len2 = physics::Vector::magnitude(&pv);
+ let len1 = math::Vector::length(&mv);
+ let len2 = physics::Vector::magnitude(&pv);
assert(len1 == 5, "Math vector length failed");
assert(len2 == 13.0, "Physics vector magnitude failed");
diff --git a/tests/std/test_env.zc b/tests/std/test_env.zc
index 75bba3b..25d5bc1 100644
--- a/tests/std/test_env.zc
+++ b/tests/std/test_env.zc
@@ -2,34 +2,34 @@ import "std.zc"
import "std/env.zc"
test "test_std_env_set_and_get" {
- var res = Env::set("TEST1", "ok1");
+ let res = Env::set("TEST1", "ok1");
assert(res == EnvRes::OK(), "result should be EnvRes::OK()");
- var env_var = Env::get("TEST1");
+ let env_var = Env::get("TEST1");
assert(env_var.is_some(), "env_var should have a value");
assert(env_var.unwrap() == "ok1", "env_var should be ok1");
}
test "test_std_env_set_with_overwrite" {
- var res = Env::set("TEST2", "ok2");
+ let res = Env::set("TEST2", "ok2");
assert(res == EnvRes::OK(), "res should be EnvRes::OK()");
- var res2 = Env::set("TEST2", "ok2-ovwr");
+ let res2 = Env::set("TEST2", "ok2-ovwr");
assert(res2 == EnvRes::OK(), "res2 should be EnvRes::OK()");
- var env_var = Env::get("TEST2");
+ let env_var = Env::get("TEST2");
assert(env_var.is_some(), "env_var should have a value");
assert(env_var.unwrap() == "ok2-ovwr", "env_var should be ok2-ovwr");
}
test "test_std_env_get_dup" {
- var res = Env::set("TEST3", "ok3");
+ let res = Env::set("TEST3", "ok3");
assert(res == EnvRes::OK(), "result should be EnvRes::OK()");
- var env_var = Env::get_dup("TEST3");
+ let env_var = Env::get_dup("TEST3");
assert(env_var.is_some(), "env_var should have a value");
- var value = env_var.unwrap();
+ let value = env_var.unwrap();
assert(value.c_str() == "ok3", "value should be ok3");
value.free();
@@ -38,24 +38,24 @@ test "test_std_env_get_dup" {
}
test "test_std_env_get_and_get_dup_with_invalid" {
- var env_var = Env::get("TEST4");
+ let env_var = Env::get("TEST4");
assert(env_var.is_none(), "env_var should not have a value");
- var env_var2 = Env::get_dup("TEST4");
+ let env_var2 = Env::get_dup("TEST4");
assert(env_var2.is_none(), "env_var2 should not have a value");
}
test "test_std_env_unset" {
- var res = Env::set("TEST5", "ok5");
+ let res = Env::set("TEST5", "ok5");
assert(res == EnvRes::OK(), "res should be EnvRes::OK()");
- var env_var = Env::get("TEST5");
+ let env_var = Env::get("TEST5");
assert(env_var.is_some(), "env_var should have a value");
assert(env_var.unwrap() == "ok5", "env_var should be ok5");
- var res2 = Env::unset("TEST5");
+ let res2 = Env::unset("TEST5");
assert(res2 == EnvRes::OK(), "res2 should be EnvRes::OK()");
- var env_var2 = Env::get("TEST5");
+ let env_var2 = Env::get("TEST5");
assert(env_var2.is_none(), "env_var2 should not have a value");
}
diff --git a/tests/std/test_fs.zc b/tests/std/test_fs.zc
index 1b6eb56..8a2c5f5 100644
--- a/tests/std/test_fs.zc
+++ b/tests/std/test_fs.zc
@@ -6,64 +6,64 @@ test "test_std_fs_extended" {
"Testing FS Extension...";
"Testing Path...";
- var p = Path::new("/var/log");
- var p2 = p.join("syslog");
- assert(strcmp(p2.c_str(), "/var/log/syslog") == 0, "Join failed");
+ let p = Path::new("/let/log");
+ let p2 = p.join("syslog");
+ assert(strcmp(p2.c_str(), "/let/log/syslog") == 0, "Join failed");
- var p3 = Path::new("file.txt");
- var ext = p3.extension();
+ let p3 = Path::new("file.txt");
+ let ext = p3.extension();
assert(ext.is_some(), "Extension missed");
assert(strcmp(ext.unwrap_ref().c_str(), "txt") == 0, "Wrong extension");
- var p4 = Path::new("/usr/bin/gcc");
- var parent = p4.parent();
+ let p4 = Path::new("/usr/bin/gcc");
+ let parent = p4.parent();
assert(parent.is_some(), "Parent missed");
assert(strcmp(parent.unwrap_ref().c_str(), "/usr/bin") == 0, "Wrong parent");
- var fname = p4.file_name();
+ let fname = p4.file_name();
assert(fname.is_some(), "Filename missed");
assert(strcmp(fname.unwrap_ref().c_str(), "gcc") == 0, "Wrong filename");
"Testing FS...";
- var test_dir = "tests/test_fs_sandbox";
+ let test_dir = "tests/test_fs_sandbox";
if (File::exists(test_dir)) {
File::remove_dir(test_dir);
}
"Create Dir";
- var res = File::create_dir(test_dir);
+ let res = File::create_dir(test_dir);
if (res.is_err()) {
"Dir create failed";
}
assert(File::exists(test_dir), "Dir create failed");
"Write File";
- var tmp_path = Path::new(test_dir);
- var p_file = tmp_path.join("hello.txt");
- var fpath = p_file.c_str();
- var f_res = File::open(fpath, "w");
+ let tmp_path = Path::new(test_dir);
+ let p_file = tmp_path.join("hello.txt");
+ let fpath = p_file.c_str();
+ let f_res = File::open(fpath, "w");
assert(f_res.is_ok(), "File create failed");
- var f = f_res.unwrap();
+ let f = f_res.unwrap();
f.write_string("Hello World");
f.close();
assert(File::exists(fpath), "File exists check failed");
"Metadata";
- var meta_res = File::metadata(fpath);
+ let meta_res = File::metadata(fpath);
assert(meta_res.is_ok(), "Metadata failed");
- var meta = meta_res.unwrap();
+ let meta = meta_res.unwrap();
assert(meta.is_file, "Is file check failed");
assert(!meta.is_dir, "Is dir check failed");
assert(meta.size == 11, "Size check failed");
"Read Dir";
- var list_res = File::read_dir(test_dir);
+ let list_res = File::read_dir(test_dir);
assert(list_res.is_ok(), "Read dir failed");
- var entries = list_res.unwrap();
- var found_idx = -1;
+ let entries = list_res.unwrap();
+ let found_idx = -1;
for entry in &entries {
if (strcmp((*entry).name.c_str(), "hello.txt") == 0) {
found_idx = 1;
diff --git a/tests/std/test_map_iter.zc b/tests/std/test_map_iter.zc
index efce356..a366854 100644
--- a/tests/std/test_map_iter.zc
+++ b/tests/std/test_map_iter.zc
@@ -2,14 +2,14 @@ import "std/map.zc"
import "std/string.zc"
test "map_iterator" {
- var m = Map<int>::new();
+ let m = Map<int>::new();
m.put("one", 1);
m.put("two", 2);
m.put("three", 3);
- var count = 0;
- var sum = 0;
+ let count = 0;
+ let sum = 0;
for entry in m {
count = count + 1;
diff --git a/tests/std/test_net.zc b/tests/std/test_net.zc
index 98ba32f..638bace 100644
--- a/tests/std/test_net.zc
+++ b/tests/std/test_net.zc
@@ -9,29 +9,29 @@ import "std/result.zc"
test "test_net" {
"Testing Networking...";
- var t = Thread::spawn(fn() {
- var listener = TcpListener::bind("127.0.0.1", 9090);
+ let t = Thread::spawn(fn() {
+ let listener = TcpListener::bind("127.0.0.1", 9090);
if (listener.is_err()) {
!"Server bind failed";
return;
}
- var l = listener.unwrap();
+ let l = listener.unwrap();
- var client_res = l.accept();
+ let client_res = l.accept();
if (client_res.is_err()) {
!"Accept failed";
l.close();
return;
}
- var client = client_res.unwrap();
+ let client = client_res.unwrap();
- var buf: char* = malloc(100);
- var n_res = client.read(buf, 100);
+ let buf: char* = malloc(100);
+ let n_res = client.read(buf, 100);
if (n_res.is_ok()) {
- var n = n_res.unwrap();
+ let n = n_res.unwrap();
buf[n] = 0;
if (strcmp(buf, "Ping") == 0) {
client.write("Pong", 4);
@@ -50,17 +50,17 @@ test "test_net" {
sleep_ms(100);
- var stream_res = TcpStream::connect("127.0.0.1", 9090);
+ let stream_res = TcpStream::connect("127.0.0.1", 9090);
if (stream_res.is_err()) {
!"Client connect failed";
exit(1);
}
- var stream = stream_res.unwrap();
+ let stream = stream_res.unwrap();
stream.write("Ping", 4);
- var buf2: char* = malloc(100);
- var n2_res = stream.read(buf2, 100);
+ let buf2: char* = malloc(100);
+ let n2_res = stream.read(buf2, 100);
if (n2_res.is_ok()) {
buf2[n2_res.unwrap()] = 0;
diff --git a/tests/std/test_queue.zc b/tests/std/test_queue.zc
index d8895b8..3316323 100644
--- a/tests/std/test_queue.zc
+++ b/tests/std/test_queue.zc
@@ -2,11 +2,11 @@ import "std/queue.zc"
test "Queue Push/Pop" {
println "Testing Queue Push/Pop";
- var queue = Queue<i32>::new();
+ let queue = Queue<i32>::new();
defer queue.free();
println "Popping on an empty queue without pushing anything prior"
- var v = queue.pop();
+ let v = queue.pop();
assert(v.is_none(), "v should not have a valid value");
println "Pushing in three values..."
@@ -30,7 +30,7 @@ test "Queue Push/Pop" {
test "Queue Length and Clear" {
println "Testing Queue clear";
- var queue = Queue<i32>::new();
+ let queue = Queue<i32>::new();
defer queue.free();
assert(queue.is_empty() && queue.length() == 0, "queue should be empty");
@@ -44,13 +44,13 @@ test "Queue Length and Clear" {
test "Queue Clone" {
println "Testing Queue Cloning";
- var queue = Queue<i32>::new();
+ let queue = Queue<i32>::new();
defer queue.free();
queue.push(123);
- var queue2 = queue.clone();
+ let queue2 = queue.clone();
defer queue2.free();
- var v = queue2.pop();
+ let v = queue2.pop();
assert(v.is_some() && v.unwrap() == 123, "v's value should be 123");
v = queue2.pop();
assert(v.is_none(), "v should not have a valid value");
@@ -62,7 +62,7 @@ test "Queue Clone" {
}
test "Queue Ring Buffer (Advanced)" {
- var q = Queue<int>::new();
+ let q = Queue<int>::new();
println "Fill slightly"
q.push(1);
@@ -91,10 +91,10 @@ test "Queue Ring Buffer (Advanced)" {
assert(q.is_empty());
println "Large scale test"
- for (var i = 0; i < 100; i=i+1) {
+ for (let i = 0; i < 100; i=i+1) {
q.push(i);
}
- for (var i = 0; i < 100; i=i+1) {
+ for (let i = 0; i < 100; i=i+1) {
assert(*q.pop().unwrap_ref() == i);
}
diff --git a/tests/std/test_readln_scan.zc b/tests/std/test_readln_scan.zc
index 5ea196d..f138c2c 100644
--- a/tests/std/test_readln_scan.zc
+++ b/tests/std/test_readln_scan.zc
@@ -2,18 +2,18 @@
test "test_readln_scan" {
"Testing readln compilation...";
- var x: int = 0;
- var f: float = 0.0;
+ let x: int = 0;
+ let f: float = 0.0;
if (1 == 0) {
- var s = readln();
+ let s = readln();
- var count = readln(x);
+ let count = readln(x);
readln(f);
readln(x, f);
- var count2 = ?"Age? "(x);
+ let count2 = ?"Age? "(x);
?"Coords? "(x, f);
}
diff --git a/tests/std/test_stack.zc b/tests/std/test_stack.zc
index 03e51a4..1116f8d 100644
--- a/tests/std/test_stack.zc
+++ b/tests/std/test_stack.zc
@@ -2,11 +2,11 @@ import "std/stack.zc"
test "Stack Push/Pop" {
print "Testing Stack Push/Pop";
- var stack = Stack<i32>::new();
+ let stack = Stack<i32>::new();
defer stack.free();
print "Popping on an empty stack without pushing anything prior"
- var v = stack.pop();
+ let v = stack.pop();
assert(v.is_none(), "v should not have a valid value");
print "Pushing in three values..."
@@ -30,7 +30,7 @@ test "Stack Push/Pop" {
test "Stack Length and Clear" {
print "Testing Stack clear";
- var stack = Stack<i32>::new();
+ let stack = Stack<i32>::new();
defer stack.free();
assert(stack.is_empty() && stack.length() == 0, "Stack should be empty");
@@ -44,13 +44,13 @@ test "Stack Length and Clear" {
test "Stack Clone" {
print "Testing Stack Cloning";
- var stack = Stack<i32>::new();
+ let stack = Stack<i32>::new();
defer stack.free();
stack.push(123);
- var stack2 = stack.clone();
+ let stack2 = stack.clone();
defer stack2.free();
- var v = stack2.pop();
+ let v = stack2.pop();
assert(v.is_some() && v.unwrap() == 123, "v's value should be 123");
v = stack2.pop();
assert(v.is_none(), "v should not have a valid value");
diff --git a/tests/std/test_std_expansion.zc b/tests/std/test_std_expansion.zc
index 764e0ac..fbb6d6b 100644
--- a/tests/std/test_std_expansion.zc
+++ b/tests/std/test_std_expansion.zc
@@ -4,7 +4,7 @@ test "test_std_expansion" {
"Testing Standard Library Expansion...";
"Testing Map...";
- var m = Map<int>::new();
+ let m = Map<int>::new();
m.put("one", 1);
m.put("two", 2);
@@ -17,14 +17,14 @@ test "test_std_expansion" {
assert(!m.contains("one"), "Map remove failed");
"Testing Time...";
- var t1 = Time::now();
+ let t1 = Time::now();
Time::sleep_ms(10);
- var t2 = Time::now();
+ let t2 = Time::now();
assert(t2 >= t1, "Time went backwards!");
"Time passed: {t2 - t1} ms";
"Testing FS...";
- var content_res = File::read_all("tests/test_0.zc");
+ let content_res = File::read_all("tests/test_0.zc");
if (content_res.is_ok()) {
"Read file successfully.";
} else {
@@ -32,7 +32,7 @@ test "test_std_expansion" {
}
"Testing JSON...";
- var j = JsonValue::string("hello");
+ let j = JsonValue::string("hello");
assert(j.kind == JsonType::JSON_STRING(), "Json string kind failed");
"All expansion tests passed!";
diff --git a/tests/std/test_string_split.zc b/tests/std/test_string_split.zc
index 496dbd1..74bc624 100644
--- a/tests/std/test_string_split.zc
+++ b/tests/std/test_string_split.zc
@@ -1,24 +1,24 @@
import "std/string.zc"
test "string_split_basic" {
- var s = String::from("a,b,c");
- var parts = s.split(',');
+ let s = String::from("a,b,c");
+ let parts = s.split(',');
if (parts.length() != 3) {
println "Split length fail: {parts.length()}";
exit(1);
}
- var p0 = parts.get(0);
- var t0 = String::from("a");
+ let p0 = parts.get(0);
+ let t0 = String::from("a");
if (!p0.eq(&t0)) exit(1);
- var p1 = parts.get(1);
- var t1 = String::from("b");
+ let p1 = parts.get(1);
+ let t1 = String::from("b");
if (!p1.eq(&t1)) exit(1);
- var p2 = parts.get(2);
- var t2 = String::from("c");
+ let p2 = parts.get(2);
+ let t2 = String::from("c");
if (!p2.eq(&t2)) exit(1);
for p in &parts {
@@ -28,28 +28,28 @@ test "string_split_basic" {
}
test "string_split_edge" {
- var s = String::from("hello");
- var parts = s.split(' '); // Not found
+ let s = String::from("hello");
+ let parts = s.split(' '); // Not found
if (parts.length() != 1) {
println "Split edge 1 failed";
exit(1);
}
- var p0 = parts.get(0);
+ let p0 = parts.get(0);
if (!p0.eq(&s)) exit(1);
p0.free();
parts.free();
- var s2 = String::from("a,,b");
- var parts2 = s2.split(',');
+ let s2 = String::from("a,,b");
+ let parts2 = s2.split(',');
if (parts2.length() != 3) {
println "Split edge 2 failed: {parts2.length()}";
exit(1);
}
- var empty = parts2.get(1);
+ let empty = parts2.get(1);
if (!empty.is_empty()) exit(1);
for p in &parts2 { p.free(); }
diff --git a/tests/std/test_string_utf8.zc b/tests/std/test_string_utf8.zc
index a4d2095..a8f6272 100644
--- a/tests/std/test_string_utf8.zc
+++ b/tests/std/test_string_utf8.zc
@@ -1,22 +1,22 @@
import "std/string.zc"
test "utf8_basic_ascii" {
- var s = String::from("Hello");
+ let s = String::from("Hello");
if (s.utf8_len() != 5) {
println "ASCII Len failed";
exit(1);
}
- var h = s.utf8_at(0);
- var t1 = String::from("H");
+ let h = s.utf8_at(0);
+ let t1 = String::from("H");
if (!h.eq(&t1)) {
println "ASCII At failed";
exit(1);
}
- var sub = s.utf8_substr(1, 4);
- var t2 = String::from("ello");
+ let sub = s.utf8_substr(1, 4);
+ let t2 = String::from("ello");
if (!sub.eq(&t2)) {
println "ASCII Substr failed";
exit(1);
@@ -28,7 +28,7 @@ test "utf8_multibyte" {
// Bytes: H(1) e(1) y(1) (1) 🌎(4) !(1) = 9 bytes?
// 🌎 is approx F0 9F 8C 8D (4 bytes)
- var s = String::from("Hey 🌎!");
+ let s = String::from("Hey 🌎!");
if (s.length() != 9) {
println "Byte length unexpected: {s.length()}";
@@ -40,15 +40,15 @@ test "utf8_multibyte" {
exit(1);
}
- var globe = s.utf8_at(4);
- var t3 = String::from("🌎");
+ let globe = s.utf8_at(4);
+ let t3 = String::from("🌎");
if (!globe.eq(&t3)) {
println "UTF8 At failed";
exit(1);
}
- var sub = s.utf8_substr(4, 2); // "🌎!"
- var t4 = String::from("🌎!");
+ let sub = s.utf8_substr(4, 2); // "🌎!"
+ let t4 = String::from("🌎!");
if (!sub.eq(&t4)) {
println "UTF8 Substr failed";
exit(1);
diff --git a/tests/std/test_string_utils.zc b/tests/std/test_string_utils.zc
index 212bac1..c001ef4 100644
--- a/tests/std/test_string_utils.zc
+++ b/tests/std/test_string_utils.zc
@@ -1,46 +1,46 @@
import "std/string.zc"
test "string trim" {
- var s1 = String::from(" hello ");
- var t1 = s1.trim();
- var e1 = String::from("hello");
+ let s1 = String::from(" hello ");
+ let t1 = s1.trim();
+ let e1 = String::from("hello");
assert(t1.eq(&e1));
t1.free(); s1.free(); e1.free();
- var s2 = String::from("\n\t world \r ");
- var t2 = s2.trim();
- var e2 = String::from("world");
+ let s2 = String::from("\n\t world \r ");
+ let t2 = s2.trim();
+ let e2 = String::from("world");
assert(t2.eq(&e2));
t2.free(); s2.free(); e2.free();
- var s3 = String::from("no_trim");
- var t3 = s3.trim();
- var e3 = String::from("no_trim");
+ let s3 = String::from("no_trim");
+ let t3 = s3.trim();
+ let e3 = String::from("no_trim");
assert(t3.eq(&e3));
t3.free(); s3.free(); e3.free();
- var s4 = String::from(" ");
- var t4 = s4.trim();
+ let s4 = String::from(" ");
+ let t4 = s4.trim();
assert(t4.is_empty());
t4.free(); s4.free();
}
test "string replace" {
- var s1 = String::from("foo bar foo");
- var r1 = s1.replace("foo", "baz");
- var e1 = String::from("baz bar baz");
+ let s1 = String::from("foo bar foo");
+ let r1 = s1.replace("foo", "baz");
+ let e1 = String::from("baz bar baz");
assert(r1.eq(&e1));
r1.free(); s1.free(); e1.free();
- var s2 = String::from("hello world");
- var r2 = s2.replace("world", "ZenC");
- var e2 = String::from("hello ZenC");
+ let s2 = String::from("hello world");
+ let r2 = s2.replace("world", "ZenC");
+ let e2 = String::from("hello ZenC");
assert(r2.eq(&e2));
r2.free(); s2.free(); e2.free();
- var s3 = String::from("aaaa");
- var r3 = s3.replace("aa", "b");
- var e3 = String::from("bb");
+ let s3 = String::from("aaaa");
+ let r3 = s3.replace("aa", "b");
+ let e3 = String::from("bb");
assert(r3.eq(&e3));
r3.free(); s3.free(); e3.free();
}
diff --git a/tests/std/test_vec.zc b/tests/std/test_vec.zc
index 5e3dddf..89086f6 100644
--- a/tests/std/test_vec.zc
+++ b/tests/std/test_vec.zc
@@ -24,7 +24,7 @@ struct Point {
test "Vec Basics (Construction, Push, Pop, Access)" {
print "Testing Vec basics...\n";
- var v = Vec<int>::new();
+ let v = Vec<int>::new();
assert_eq(v.len, 0, "Initial len");
assert_eq(v.cap, 0, "Initial cap");
@@ -53,16 +53,16 @@ test "Vec Basics (Construction, Push, Pop, Access)" {
test "Vec Capacity and Allocation" {
print "Testing Vec capacity...\n";
// with_capacity
- var v1 = Vec<int>::with_capacity(10);
+ let v1 = Vec<int>::with_capacity(10);
assert_eq(v1.len, 0, "with_capacity len");
assert_eq(v1.cap, 10, "with_capacity cap");
v1.push(1);
assert_eq(v1.cap, 10, "Cap should not change yet");
// Implicit grow
- var v2 = Vec<int>::new();
+ let v2 = Vec<int>::new();
// Force grow logic: 0 -> 8 -> 16...
- var i = 0;
+ let i = 0;
while i < 9 {
v2.push(i);
i = i + 1;
@@ -74,7 +74,7 @@ test "Vec Capacity and Allocation" {
test "Vec Modification (Insert, Append, Remove, Clear)" {
print "Testing Vec modification...\n";
- var v = Vec<int>::new();
+ let v = Vec<int>::new();
v.push(1);
v.push(3);
@@ -82,7 +82,7 @@ test "Vec Modification (Insert, Append, Remove, Clear)" {
assert_eq(v.get(1), 2, "insert middle");
assert_eq(v.len, 3, "insert len");
- var v2 = Vec<int>::new();
+ let v2 = Vec<int>::new();
v2.push(4);
v2.push(5);
v.append(v2);
@@ -91,7 +91,7 @@ test "Vec Modification (Insert, Append, Remove, Clear)" {
assert_eq(v.get(i), i + 1, "append value");
}
- var val = v.remove(0); // [2, 3, 4, 5]
+ let val = v.remove(0); // [2, 3, 4, 5]
assert_eq(val, 1, "remove return");
assert_eq(v.get(0), 2, "remove shift");
assert_eq(v.len, 4, "remove len");
@@ -103,25 +103,25 @@ test "Vec Modification (Insert, Append, Remove, Clear)" {
test "Vec Extensions (pop_opt)" {
print "Testing Vec extensions...\n";
- var v = Vec<int>::new();
+ let v = Vec<int>::new();
v.push(42);
- var opt = v.pop_opt();
+ let opt = v.pop_opt();
assert_true(!opt.is_none(), "pop_opt some");
assert_eq(opt.unwrap(), 42, "pop_opt val");
- var empty = v.pop_opt();
+ let empty = v.pop_opt();
assert_true(empty.is_none(), "pop_opt none");
}
test "Vec Iteration (Reference and Value)" {
print "Testing Vec iteration...\n";
- var v = Vec<Point>::new();
+ let v = Vec<Point>::new();
v.push(Point { x: 10, y: 10 });
v.push(Point { x: 20, y: 20 });
// 1. Value Iteration
- var sum_val = 0;
+ let sum_val = 0;
for p in v {
sum_val = sum_val + p.x;
}
@@ -144,11 +144,11 @@ test "Vec Iteration (Reference and Value)" {
test "Vec Clone and Drop" {
print "Testing Vec clone and drop...\n";
- var v = Vec<int>::new();
+ let v = Vec<int>::new();
v.push(100);
v.push(200);
- var v2 = v.clone();
+ let v2 = v.clone();
assert_eq(v2.len, 2, "Clone len");
assert_eq(v2.get(0), 100, "Clone val 0");
@@ -163,7 +163,7 @@ test "Vec Clone and Drop" {
test "Vec Utils (Reverse, Contains)" {
print "Testing Vec utils...\n";
- var v = Vec<int>::new();
+ let v = Vec<int>::new();
v.push(1);
v.push(2);
v.push(3);