mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-22 17:21:35 +00:00
Add bindings for RegExp.$1-$9
This commit is contained in:
committed by
Alex Crichton
parent
e35295d376
commit
73e89fc59b
@ -3,7 +3,6 @@ use js_sys::*;
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn exec() {
|
||||
|
||||
let re = RegExp::new("quick\\s(brown).+?(jumps)", "ig");
|
||||
let result = re.exec("The Quick Brown Fox Jumps Over The Lazy Dog");
|
||||
|
||||
@ -76,6 +75,21 @@ fn multiline() {
|
||||
assert!(re.multiline());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn n1_to_n9() {
|
||||
let re = RegExp::new(r"(\w+)\s(\w+)\s(\w+)\s(\w+)\s(\w+)\s(\w+)\s(\w+)\s(\w+)\s(\w+)", "");
|
||||
re.test("The Quick Brown Fox Jumps Over The Lazy Dog");
|
||||
assert_eq!(RegExp::n1(), "The");
|
||||
assert_eq!(RegExp::n2(), "Quick");
|
||||
assert_eq!(RegExp::n3(), "Brown");
|
||||
assert_eq!(RegExp::n4(), "Fox");
|
||||
assert_eq!(RegExp::n5(), "Jumps");
|
||||
assert_eq!(RegExp::n6(), "Over");
|
||||
assert_eq!(RegExp::n7(), "The");
|
||||
assert_eq!(RegExp::n8(), "Lazy");
|
||||
assert_eq!(RegExp::n9(), "Dog");
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn new() {
|
||||
let re = RegExp::new("foo", "");
|
||||
|
Reference in New Issue
Block a user