From a201cafdeaafe03cdb732cf07e6edbb4a6e38c7b Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 19 Jun 2018 10:15:09 -0700 Subject: [PATCH] test: Move `Object`-related js_globals tests to submodule file --- tests/all/js_globals/Object.rs | 56 +++++++++++++++++ .../all/{js_globals.rs => js_globals/mod.rs} | 60 +------------------ 2 files changed, 58 insertions(+), 58 deletions(-) create mode 100755 tests/all/js_globals/Object.rs rename tests/all/{js_globals.rs => js_globals/mod.rs} (62%) diff --git a/tests/all/js_globals/Object.rs b/tests/all/js_globals/Object.rs new file mode 100755 index 00000000..0c2f8311 --- /dev/null +++ b/tests/all/js_globals/Object.rs @@ -0,0 +1,56 @@ +#![allow(non_snake_case)] + +use project; + +#[test] +fn new() { + 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_object() -> js::Object { + js::Object::new() + } + "#) + .file("test.ts", r#" + import * as assert from "assert"; + import * as wasm from "./out"; + + export function test() { + assert.equal(typeof wasm.new_object(), "object"); + } + "#) + .test() +} + +#[test] +fn has_own_property() { + 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 has_own_foo_property(obj: &js::Object) -> bool { + obj.has_own_property("foo") + } + "#) + .file("test.ts", r#" + import * as assert from "assert"; + import * as wasm from "./out"; + + export function test() { + assert.ok(wasm.has_own_foo_property({ foo: 42 })); + assert.ok(!wasm.has_own_foo_property({})); + } + "#) + .test() +} diff --git a/tests/all/js_globals.rs b/tests/all/js_globals/mod.rs similarity index 62% rename from tests/all/js_globals.rs rename to tests/all/js_globals/mod.rs index 1fc65992..5c41ea6c 100644 --- a/tests/all/js_globals.rs +++ b/tests/all/js_globals/mod.rs @@ -2,6 +2,8 @@ use super::project; +mod Object; + #[test] #[cfg(feature = "std")] fn decode_uri() { @@ -90,61 +92,3 @@ fn eval() { "#) .test(); } - -#[allow(non_snake_case)] -mod Object { - use project; - - #[test] - fn new() { - 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_object() -> js::Object { - js::Object::new() - } - "#) - .file("test.ts", r#" - import * as assert from "assert"; - import * as wasm from "./out"; - - export function test() { - assert.equal(typeof wasm.new_object(), "object"); - } - "#) - .test() - } - - #[test] - fn has_own_property() { - 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 has_own_foo_property(obj: &js::Object) -> bool { - obj.has_own_property("foo") - } - "#) - .file("test.ts", r#" - import * as assert from "assert"; - import * as wasm from "./out"; - - export function test() { - assert.ok(wasm.has_own_foo_property({ foo: 42 })); - assert.ok(!wasm.has_own_foo_property({})); - } - "#) - .test() - } -}