wasm-bindgen/tests/all/js_globals/Boolean.rs
2018-06-27 22:42:34 -07:00

68 lines
1.5 KiB
Rust

#![allow(non_snake_case)]
use project;
#[test]
fn new_undefined() {
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 new_boolean() -> js::Boolean {
js::Boolean::new(JsValue::undefined())
}
"#,
)
.file(
"test.ts",
r#"
import * as assert from "assert";
import * as wasm from "./out";
export function test() {
assert.equal(wasm.new_boolean().valueOf(), false);
}
"#,
)
.test()
}
#[test]
fn new_truely() {
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 new_boolean() -> js::Boolean {
js::Boolean::new(JsValue::from("foo"))
}
"#,
)
.file(
"test.ts",
r#"
import * as assert from "assert";
import * as wasm from "./out";
export function test() {
assert.equal(wasm.new_boolean().valueOf(), true);
}
"#,
)
.test()
}