Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jun 18, 2020
1 parent 7760f38 commit 2f76edf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions boa/src/exec/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,3 +912,23 @@ fn to_string() {
assert_eq!(engine.to_string(&Value::rational(55.0)).unwrap(), "55");
assert_eq!(engine.to_string(&Value::string("hello")).unwrap(), "hello");
}

#[test]
fn calling_function_with_unspecified_arguments() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let scenario = r#"
function fibonacci(num, memo) {
memo = memo || {};
if (memo[num]) return memo[num];
if (num <= 1) return 1;
return memo[num] = fibonacci(num - 1, memo) + fibonacci(num - 2, memo);
}
fibonacci(1)
"#;

assert_eq!(forward(&mut engine, scenario), "1");
}

0 comments on commit 2f76edf

Please sign in to comment.