mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-27 03:55:20 +03:00
Fix webidl-tests fallout
This commit is contained in:
parent
f24828a16b
commit
fe31615ca1
@ -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;
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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({}, {
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user