2018-07-03 14:53:17 +03:00
|
|
|
#![allow(non_snake_case)]
|
|
|
|
|
|
|
|
use project;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn has_instance() {
|
|
|
|
project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
|
|
|
#![feature(proc_macro, wasm_custom_section)]
|
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::js;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
pub fn symbol_has_instance() -> js::Symbol {
|
|
|
|
js::Symbol::has_instance()
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"test.ts",
|
|
|
|
r#"
|
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
2018-07-03 17:06:25 +03:00
|
|
|
class Array1 {}
|
|
|
|
Object.defineProperty(Array1, wasm.symbol_has_instance(), {
|
|
|
|
value: (instance: any) => Array.isArray(instance)
|
|
|
|
});
|
2018-07-03 14:53:17 +03:00
|
|
|
|
|
|
|
export function test() {
|
2018-07-03 17:06:25 +03:00
|
|
|
assert.equal(typeof wasm.symbol_has_instance(), "symbol");
|
|
|
|
assert.ok([] instanceof Array1);
|
2018-07-03 14:53:17 +03:00
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.test()
|
|
|
|
}
|