mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-14 13:31:22 +00:00
js-sys: Add bindings for SyntaxError
This commit is contained in:
@ -2496,6 +2496,27 @@ extern {
|
|||||||
pub fn values(set: &Set) -> Iterator;
|
pub fn values(set: &Set) -> Iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SyntaxError
|
||||||
|
#[wasm_bindgen]
|
||||||
|
extern {
|
||||||
|
/// A SyntaxError is thrown when the JavaScript engine encounters tokens or
|
||||||
|
/// token order that does not conform to the syntax of the language when
|
||||||
|
/// parsing code.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError
|
||||||
|
#[wasm_bindgen(extends = Error)]
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub type SyntaxError;
|
||||||
|
|
||||||
|
/// A SyntaxError is thrown when the JavaScript engine encounters tokens or
|
||||||
|
/// token order that does not conform to the syntax of the language when
|
||||||
|
/// parsing code.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError
|
||||||
|
#[wasm_bindgen(constructor)]
|
||||||
|
pub fn new(message: &str) -> SyntaxError;
|
||||||
|
}
|
||||||
|
|
||||||
// Uint8Array
|
// Uint8Array
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
14
crates/js-sys/tests/wasm/SyntaxError.rs
Normal file
14
crates/js-sys/tests/wasm/SyntaxError.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
use wasm_bindgen::JsValue;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
|
use js_sys::*;
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn syntax_error() {
|
||||||
|
let error = SyntaxError::new("msg");
|
||||||
|
assert!(error.is_instance_of::<SyntaxError>());
|
||||||
|
assert!(error.is_instance_of::<Error>());
|
||||||
|
|
||||||
|
let base: &Error = error.as_ref();
|
||||||
|
assert_eq!(JsValue::from(base.message()), "msg");
|
||||||
|
}
|
@ -32,6 +32,7 @@ pub mod RegExp;
|
|||||||
pub mod Set;
|
pub mod Set;
|
||||||
pub mod SetIterator;
|
pub mod SetIterator;
|
||||||
pub mod Symbol;
|
pub mod Symbol;
|
||||||
|
pub mod SyntaxError;
|
||||||
pub mod TypedArray;
|
pub mod TypedArray;
|
||||||
pub mod UriError;
|
pub mod UriError;
|
||||||
pub mod WeakMap;
|
pub mod WeakMap;
|
||||||
|
Reference in New Issue
Block a user