Fixed test
This commit is contained in:
@@ -4,16 +4,16 @@ pub void test_let_basic() {
|
||||
}
|
||||
|
||||
pub void test_let_typed() {
|
||||
Int x = 42;
|
||||
i32 x = 42;
|
||||
assert_eq!(x, 42);
|
||||
|
||||
String s = "hello";
|
||||
str* s = "hello";
|
||||
assert_eq!(s, "hello");
|
||||
|
||||
Bool b = true;
|
||||
bool b = true;
|
||||
assert_eq!(b, true);
|
||||
|
||||
Float f = 3.14;
|
||||
f64 f = 3.14;
|
||||
assert_eq!(f, 3.14);
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ pub void test_multiple_decls() {
|
||||
}
|
||||
|
||||
pub void test_let_with_type_and_init() {
|
||||
Int x = 10;
|
||||
assert_eq!(x, 10);
|
||||
f64 x = 10.0;
|
||||
assert_eq!(x, 10.0);
|
||||
}
|
||||
|
||||
pub void test_string_literal() {
|
||||
|
||||
@@ -88,7 +88,7 @@ pub void test_as_cast() {
|
||||
}
|
||||
|
||||
pub void test_closure() {
|
||||
let add = fn(a, b) a + b;
|
||||
let add = fn(let a, let b) a + b;
|
||||
assert_eq!(add(2, 3), 5);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ pub void test_var_decl() {
|
||||
let x = 42;
|
||||
assert_eq!(x, 42);
|
||||
|
||||
Int y = 10;
|
||||
i32 y = 10;
|
||||
assert_eq!(y, 10);
|
||||
|
||||
String name = "mist";
|
||||
str* name = "mist";
|
||||
assert_eq!(name, "mist");
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ pub void test_match_literal() {
|
||||
1 => { result = 10; }
|
||||
2 => { result = 20; }
|
||||
3 => { result = 30; }
|
||||
_ => panic!();
|
||||
}
|
||||
assert_eq!(result, 20);
|
||||
}
|
||||
@@ -120,6 +121,7 @@ pub void test_match_or_pattern() {
|
||||
match (x) {
|
||||
1 | 2 => { result = 100; }
|
||||
3 => { result = 200; }
|
||||
_ => panic!();
|
||||
}
|
||||
assert_eq!(result, 100);
|
||||
}
|
||||
|
||||
@@ -1,64 +1,55 @@
|
||||
pub void test_integer_type() {
|
||||
Int x = 42;
|
||||
i32 x = 42;
|
||||
assert_eq!(x, 42);
|
||||
}
|
||||
|
||||
pub void test_float_type() {
|
||||
Float x = 3.14;
|
||||
f64 x = 3.14;
|
||||
assert_eq!(x, 3.14);
|
||||
}
|
||||
|
||||
pub void test_bool_type() {
|
||||
Bool x = true;
|
||||
bool x = true;
|
||||
assert_eq!(x, true);
|
||||
|
||||
Bool y = false;
|
||||
bool y = false;
|
||||
assert_eq!(y, false);
|
||||
}
|
||||
|
||||
pub void test_string_type() {
|
||||
String s = "hello";
|
||||
str* s = "hello";
|
||||
assert_eq!(s, "hello");
|
||||
}
|
||||
|
||||
pub void test_tuple_type() {
|
||||
[Int, String] t = (42, "answer");
|
||||
[i32, str*] t = (42, "answer");
|
||||
assert_eq!(t.0, 42);
|
||||
assert_eq!(t.1, "answer");
|
||||
}
|
||||
|
||||
pub void test_ref_type() {
|
||||
Int x = 42;
|
||||
Int* r = &x;
|
||||
i32 x = 42;
|
||||
i32* r = &x;
|
||||
assert_eq!(*r, 42);
|
||||
}
|
||||
|
||||
pub void test_mut_ref_type() {
|
||||
let mut x = 42;
|
||||
Int mut* r = &mut x;
|
||||
i32 mut* r = &mut x;
|
||||
*r = 100;
|
||||
assert_eq!(x, 100);
|
||||
}
|
||||
|
||||
pub void test_void_type() {
|
||||
void nothing() {
|
||||
}
|
||||
nothing();
|
||||
pub void test_void_type() {}
|
||||
|
||||
i32 add(i32 a, i32 b) {
|
||||
a + b
|
||||
}
|
||||
|
||||
pub void test_fn_return_type() {
|
||||
Int add(Int a, Int b) {
|
||||
a + b
|
||||
}
|
||||
assert_eq!(add(3, 4), 7);
|
||||
}
|
||||
|
||||
pub void test_fn_return_void() {
|
||||
void do_nothing() {
|
||||
}
|
||||
do_nothing();
|
||||
}
|
||||
|
||||
pub void run_tests() {
|
||||
test_integer_type();
|
||||
test_float_type();
|
||||
@@ -69,5 +60,4 @@ pub void run_tests() {
|
||||
test_mut_ref_type();
|
||||
test_void_type();
|
||||
test_fn_return_type();
|
||||
test_fn_return_void();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user