mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-25 11:02:11 +03:00
Add a test for webidl
This commit is contained in:
parent
e70c9015ff
commit
3ad5493d23
@ -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 {
|
||||
get un() {
|
||||
return 1;
|
||||
|
@ -65,7 +65,17 @@ fn optional_method() {
|
||||
#[wasm_bindgen_test]
|
||||
fn global_method() {
|
||||
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]
|
||||
|
7
crates/webidl-tests/simple.webidl
vendored
7
crates/webidl-tests/simple.webidl
vendored
@ -40,6 +40,13 @@ interface GlobalMethod {
|
||||
octet m();
|
||||
};
|
||||
|
||||
[Constructor()]
|
||||
interface Indexing {
|
||||
getter short (unsigned long index);
|
||||
setter void (unsigned long index, short value);
|
||||
deleter void (unsigned long index);
|
||||
};
|
||||
|
||||
[Constructor()]
|
||||
interface Unforgeable {
|
||||
[Unforgeable] readonly attribute short uno;
|
||||
|
Loading…
Reference in New Issue
Block a user