This commit is contained in:
2026-06-05 12:32:12 +02:00
parent 0955bca5bc
commit d5501ef25e
14 changed files with 821 additions and 11 deletions
+81
View File
@@ -0,0 +1,81 @@
pub void test_let_basic() {
let x = 42;
assert_eq!(x, 42);
}
pub void test_let_typed() {
Int x = 42;
assert_eq!(x, 42);
String s = "hello";
assert_eq!(s, "hello");
Bool b = true;
assert_eq!(b, true);
Float f = 3.14;
assert_eq!(f, 3.14);
}
pub void test_let_mut() {
let mut x = 42;
x = 100;
assert_eq!(x, 100);
}
pub void test_let_tuple_destructure() {
let [a, b] = (10, "hello");
assert_eq!(a, 10);
assert_eq!(b, "hello");
}
pub void test_let_nested_tuple() {
let [a, [b, c]] = (1, (2, 3));
assert_eq!(a, 1);
assert_eq!(b, 2);
assert_eq!(c, 3);
}
pub void test_let_pattern_irrefutable() {
let x = 5;
let [y, z] = (1, 2);
assert_eq!(x, 5);
assert_eq!(y, 1);
assert_eq!(z, 2);
}
pub void test_multiple_decls() {
let a = 1;
let b = 2;
let c = 3;
assert_eq!(a + b + c, 6);
}
pub void test_let_with_type_and_init() {
Int x = 10;
assert_eq!(x, 10);
}
pub void test_string_literal() {
let s = "hello, world!";
assert_eq!(s.len(), 13);
}
pub void test_let_bool() {
let t = true;
let f = false;
assert_eq!(t, !f);
}
pub void run_tests() {
test_let_basic();
test_let_typed();
test_let_mut();
test_let_tuple_destructure();
test_let_nested_tuple();
test_let_pattern_irrefutable();
test_multiple_decls();
test_let_with_type_and_init();
test_string_literal();
test_let_bool();
}