From 6443aa86ec278ff05d30da7c9ea96e5a6c836a32 Mon Sep 17 00:00:00 2001 From: "lauren n. liberda" Date: Tue, 14 Mar 2023 01:25:00 +0000 Subject: [PATCH] [regexp] new tests for unicode flag (#2656) the flag got introduced in regress 0.5.0 This Pull Request fixes/closes: n/a. It changes the following: - add test for unicode flag - add test for native error on failing to parse (got removed in #2651 because the previous example parsing correctly now) Co-authored-by: Lauren N. Liberda --- boa_engine/src/builtins/regexp/tests.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/boa_engine/src/builtins/regexp/tests.rs b/boa_engine/src/builtins/regexp/tests.rs index 588cf45756..4aab948a05 100644 --- a/boa_engine/src/builtins/regexp/tests.rs +++ b/boa_engine/src/builtins/regexp/tests.rs @@ -53,6 +53,7 @@ fn flags() { TestAction::run(indoc! {r#" var re_gi = /test/gi; var re_sm = /test/sm; + var re_u = /test/u; "#}), TestAction::assert("re_gi.global"), TestAction::assert("re_gi.ignoreCase"), @@ -69,6 +70,14 @@ fn flags() { TestAction::assert("!re_sm.unicode"), TestAction::assert("!re_sm.sticky"), TestAction::assert_eq("re_sm.flags", "ms"), + // + TestAction::assert("!re_u.global"), + TestAction::assert("!re_u.ignoreCase"), + TestAction::assert("!re_u.multiline"), + TestAction::assert("!re_u.dotAll"), + TestAction::assert("re_u.unicode"), + TestAction::assert("!re_u.sticky"), + TestAction::assert_eq("re_u.flags", "u"), ]); } @@ -106,6 +115,22 @@ fn exec() { ]); } +#[test] +fn no_panic_on_parse_fail() { + run_test_actions([ + TestAction::assert_native_error( + r"var re = /]/u;", + ErrorKind::Syntax, + "Invalid regular expression literal: Unbalanced bracket at position: 1:10", + ), + TestAction::assert_native_error( + r"var re = /a{/u;", + ErrorKind::Syntax, + "Invalid regular expression literal: Invalid quantifier at position: 1:10", + ), + ]); +} + #[test] fn to_string() { run_test_actions([