Skip to content
Snippets Groups Projects
Commit 46f125d3 authored by Per Lindgren's avatar Per Lindgren
Browse files

all tests pass

parent 6bf8c803
No related branches found
No related tags found
No related merge requests found
fn main() {
let mut a = 7;
let mut b;
{
a = 5;
b = false;
let mut a = false;
a = true;
};
a = 0;
b = true;
}
fn main() {
let mut a = 7;
let mut b;
{
a = 5;
b = false;
let mut a = false;
a = true;
};
a = false;
b = true;
}
...@@ -286,7 +286,7 @@ fn eval_stmts(stmts: &Stmts, m: &mut Mem, fn_env: &FnEnv) -> Val { ...@@ -286,7 +286,7 @@ fn eval_stmts(stmts: &Stmts, m: &mut Mem, fn_env: &FnEnv) -> Val {
println!("block"); println!("block");
eval_stmts(block, m, fn_env) eval_stmts(block, m, fn_env)
} }
Stmt::Semi => panic!("ICE"), Stmt::Semi => Val::Unit,
} }
} }
m.pop_scope(); m.pop_scope();
......
...@@ -56,36 +56,37 @@ fn test_exprs() { ...@@ -56,36 +56,37 @@ fn test_exprs() {
#[test] #[test]
fn test_stmts() { fn test_stmts() {
// test empty sequence // test empty sequence
assert!(BlockParser::new().parse("").is_ok()); assert!(BlockParser::new().parse("{}").is_ok());
// test let with no assignment and inferred type // test let with no assignment and inferred type
assert!(BlockParser::new().parse("let a").is_ok()); assert!(BlockParser::new().parse("{ let a }").is_ok());
// test let with no assignment and excplicit type // test let with no assignment and excplicit type
assert!(BlockParser::new().parse("let a : u32").is_ok()); assert!(BlockParser::new().parse("{ let a : u32 }").is_ok());
// test let with inferred type // test let with inferred type
assert!(BlockParser::new().parse("let a = 0").is_ok()); assert!(BlockParser::new().parse("{ let a = 0 }").is_ok());
// test let with explicit type // test let with explicit type
assert!(BlockParser::new().parse("let a : u16 = 1 + 2").is_ok()); assert!(BlockParser::new().parse("{ let a : u16 = 1 + 2 }").is_ok());
// test assignment // test assignment
assert!(BlockParser::new().parse("a = 1 + 2").is_ok()); assert!(BlockParser::new().parse("{ a = 1 + 2 }").is_ok());
// test assignment // test assignment
assert!(BlockParser::new().parse("*a = 1 + 2").is_ok()); assert!(BlockParser::new().parse("{ *a = 1 + 2}").is_ok());
// test if then // test if then
assert!(BlockParser::new().parse("if a { b = 5 }").is_ok()); assert!(BlockParser::new().parse("{ if a { b = 5 } }").is_ok());
// test if then else // test if then else
assert!(BlockParser::new() assert!(BlockParser::new()
.parse("if a { b = 5 } else { b = 7 }") .parse("{ if a { b = 5 } else { b = 7 } }")
.is_ok()); .is_ok());
// test hello
assert!(BlockParser::new() assert!(BlockParser::new()
.parse("while hello(b) { b = b - 5 }") .parse("{ while hello(b) { b = b - 5 } }")
.is_ok()); .is_ok());
} }
......
...@@ -55,13 +55,13 @@ fn while_test() { ...@@ -55,13 +55,13 @@ fn while_test() {
} }
#[test] #[test]
fn mut_test() { fn let_test() {
eval_prog("examples/mut.rs"); eval_prog("examples/let.rs");
} }
#[test] #[test]
fn mut2_test() { fn let2_test() {
eval_prog("examples/mut2.rs"); eval_prog("examples/let2.rs");
} }
#[test] #[test]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment