Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tofpie committed Dec 31, 2020
1 parent 430411f commit d3d4acb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
19 changes: 19 additions & 0 deletions boa/src/syntax/ast/node/operator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,22 @@ fn instanceofoperator_rhs_not_callable() {
"\"TypeError: right-hand side of 'instanceof' is not callable\""
);
}

#[test]
fn logical_nullish_assignment() {
let scenario = r#"
let a = undefined;
a ??= 10;
a;
"#;

assert_eq!(&exec(scenario), "10");

let scenario = r#"
let a = 20;
a ??= 10;
a;
"#;

assert_eq!(&exec(scenario), "20");
}
9 changes: 9 additions & 0 deletions boa/src/syntax/parser/expression/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ fn check_assign_operations() {
)
.into()],
);
check_parser(
"a ??= b",
vec![BinOp::new(
AssignOp::Coalesce,
Identifier::from("a"),
Identifier::from("b"),
)
.into()],
);
}

#[test]
Expand Down

0 comments on commit d3d4acb

Please sign in to comment.