mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-14 21:41:23 +00:00
Add a test for webidl
This commit is contained in:
@ -93,6 +93,20 @@ global.GlobalMethod = class GlobalMethod {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
global.Indexing = function () {
|
||||||
|
return new Proxy({}, {
|
||||||
|
get(obj, prop) {
|
||||||
|
return obj.hasOwnProperty(prop) ? obj[prop] : -1;
|
||||||
|
},
|
||||||
|
set(obj, prop, value) {
|
||||||
|
obj[prop] = value;
|
||||||
|
},
|
||||||
|
deleteProperty(obj, prop) {
|
||||||
|
delete obj[prop];
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
global.PartialInterface = class PartialInterface {
|
global.PartialInterface = class PartialInterface {
|
||||||
get un() {
|
get un() {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -65,7 +65,17 @@ fn optional_method() {
|
|||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
fn global_method() {
|
fn global_method() {
|
||||||
let f = GlobalMethod::new().unwrap();
|
let f = GlobalMethod::new().unwrap();
|
||||||
assert!(f.m() == 123);
|
assert_eq!(f.m(), 123);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn indexing() {
|
||||||
|
let f = Indexing::new().unwrap();
|
||||||
|
assert_eq!(f.get(123), -1);
|
||||||
|
f.set(123, 456);
|
||||||
|
assert_eq!(f.get(123), 456);
|
||||||
|
f.delete(123);
|
||||||
|
assert_eq!(f.get(123), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
|
7
crates/webidl-tests/simple.webidl
vendored
7
crates/webidl-tests/simple.webidl
vendored
@ -40,6 +40,13 @@ interface GlobalMethod {
|
|||||||
octet m();
|
octet m();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[Constructor()]
|
||||||
|
interface Indexing {
|
||||||
|
getter short (unsigned long index);
|
||||||
|
setter void (unsigned long index, short value);
|
||||||
|
deleter void (unsigned long index);
|
||||||
|
};
|
||||||
|
|
||||||
[Constructor()]
|
[Constructor()]
|
||||||
interface Unforgeable {
|
interface Unforgeable {
|
||||||
[Unforgeable] readonly attribute short uno;
|
[Unforgeable] readonly attribute short uno;
|
||||||
|
Reference in New Issue
Block a user