wasm-bindgen/tests/all/js_globals/Boolean.rs

68 lines
1.5 KiB
Rust
Raw Normal View History

#![allow(non_snake_case)]
use project;
#[test]
fn new_undefined() {
project()
2018-06-28 08:42:34 +03:00
.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())
}
2018-06-28 08:42:34 +03:00
"#,
)
.file(
"test.ts",
r#"
import * as assert from "assert";
import * as wasm from "./out";
export function test() {
assert.equal(wasm.new_boolean().valueOf(), false);
}
2018-06-28 08:42:34 +03:00
"#,
)
.test()
}
#[test]
fn new_truely() {
project()
2018-06-28 08:42:34 +03:00
.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"))
}
2018-06-28 08:42:34 +03:00
"#,
)
.file(
"test.ts",
r#"
import * as assert from "assert";
import * as wasm from "./out";
export function test() {
assert.equal(wasm.new_boolean().valueOf(), true);
}
2018-06-28 08:42:34 +03:00
"#,
)
.test()
}