Skip to content

Commit

Permalink
Test: Add test for #629, based on #610
Browse files Browse the repository at this point in the history
  • Loading branch information
RageKnify committed Aug 13, 2020
1 parent 24eda41 commit eb813fd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions boa/src/builtins/string/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,22 @@ fn replace() {
assert_eq!(forward(&mut engine, "a"), "\"2bc\"");
}

#[test]
fn replace_with_regex() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let init = r#"
var re = /(\w+)\s(\w+)/;
var a = "John Smith";
a = a.replace(re, '$2, $1');
a
"#;

forward(&mut engine, init);

assert_eq!(forward(&mut engine, "a"), "\"Smith, John\"");
}

#[test]
fn replace_with_function() {
let realm = Realm::create();
Expand Down

0 comments on commit eb813fd

Please sign in to comment.