Add a test for webidl

This commit is contained in:
Anton Danilkin 2018-08-07 00:42:47 +03:00
parent e70c9015ff
commit 3ad5493d23
3 changed files with 32 additions and 1 deletions

View File

@ -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;

View File

@ -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]

View File

@ -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;