Fix webidl-tests fallout

This commit is contained in:
Alex Crichton 2018-09-17 14:51:25 -07:00
parent f24828a16b
commit fe31615ca1
4 changed files with 32 additions and 10 deletions

View File

@ -1,4 +1,8 @@
global.global_no_args = () => 3;
global.global_with_args = (a, b) => a + b;
global.global_attribute = 'x';
const map = {
global_no_args: () => 3,
global_with_args: (a, b) => a + b,
global_attribute: 'x',
};
global.get_global = () => map;

View File

@ -1,13 +1,20 @@
use js_sys::Object;
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
include!(concat!(env!("OUT_DIR"), "/global.rs"));
#[wasm_bindgen]
extern {
fn get_global() -> Global;
}
#[wasm_bindgen_test]
fn works() {
assert_eq!(Global::global_no_args(), 3);
assert_eq!(Global::global_with_args("a", "b"), "ab");
assert_eq!(Global::global_attribute(), "x");
Global::set_global_attribute("y");
assert_eq!(Global::global_attribute(), "y");
let x = get_global();
assert_eq!(x.global_no_args(), 3);
assert_eq!(x.global_with_args("a", "b"), "ab");
assert_eq!(x.global_attribute(), "x");
x.set_global_attribute("y");
assert_eq!(x.global_attribute(), "y");
}

View File

@ -87,7 +87,11 @@ global.Unforgeable = class Unforgeable {
}
};
global.m = () => 123;
global.GlobalMethod = class {
m() { return 123; }
};
global.get_global_method = () => new GlobalMethod();
global.Indexing = function () {
return new Proxy({}, {

View File

@ -72,9 +72,16 @@ fn nullable_method() {
assert!(f.opt(None) == None);
}
#[wasm_bindgen]
extern {
fn get_global_method() -> GlobalMethod;
}
#[wasm_bindgen_test]
fn global_method() {
assert_eq!(GlobalMethod::m(), 123);
let x = get_global_method();
assert_eq!(x.m(), 123);
}
#[wasm_bindgen_test]