diff --git a/tests/all/imports.rs b/tests/all/imports.rs index 4b6c6201..0a7add00 100644 --- a/tests/all/imports.rs +++ b/tests/all/imports.rs @@ -36,91 +36,6 @@ fn unused_imports_not_generated() { assert!(!contents.contains("foo"), "found `foo` in {}", contents); } -#[test] -fn rename_with_string() { - project() - .file( - "src/lib.rs", - r#" - #![feature(use_extern_macros)] - - extern crate wasm_bindgen; - - use wasm_bindgen::prelude::*; - - #[wasm_bindgen(module = "./test")] - extern { - #[wasm_bindgen(js_name = "baz$")] - fn foo(); - } - - #[wasm_bindgen] - pub fn run() { - foo(); - } - "#, - ) - .file( - "test.js", - r#" - import * as wasm from "./out"; - import * as assert from "assert"; - - let called = false; - - export function baz$() { - called = true; - } - - export function test() { - wasm.run(); - assert.strictEqual(called, true); - } - "#, - ) - .test(); -} - -#[test] -fn rename_static_with_string() { - project() - .debug(false) - .file( - "src/lib.rs", - r#" - #![feature(use_extern_macros)] - - extern crate wasm_bindgen; - - use wasm_bindgen::prelude::*; - - #[wasm_bindgen(module = "./test")] - extern { - #[wasm_bindgen(js_name = "$foo")] - static FOO: JsValue; - } - - #[wasm_bindgen] - pub fn run() { - assert_eq!(FOO.as_f64(), Some(1.0)); - } - "#, - ) - .file( - "test.js", - r#" - import { run } from "./out"; - - export const $foo = 1.0; - - export function test() { - run(); - } - "#, - ) - .test(); -} - #[test] fn versions() { project() diff --git a/tests/wasm/imports.js b/tests/wasm/imports.js index 7351deff..57fd962c 100644 --- a/tests/wasm/imports.js +++ b/tests/wasm/imports.js @@ -90,3 +90,6 @@ exports.touch_custom_type = function() { exports.interpret_2_as_custom_type = function() { assert.throws(wasm.interpret_2_as_custom_type, /expected value of type CustomType/); }; + +exports.baz$ = function() {}; +exports.$foo = 1.0; diff --git a/tests/wasm/imports.rs b/tests/wasm/imports.rs index 2ba501fb..40f0f7ac 100644 --- a/tests/wasm/imports.rs +++ b/tests/wasm/imports.rs @@ -42,6 +42,11 @@ extern { fn custom_type_return_2() -> CustomType; #[wasm_bindgen(js_name = interpret_2_as_custom_type)] fn js_interpret_2_as_custom_type(); + + #[wasm_bindgen(js_name = "baz$")] + fn renamed_with_dollar_sign(); + #[wasm_bindgen(js_name = "$foo")] + static RENAMED: JsValue; } #[wasm_bindgen] @@ -153,3 +158,13 @@ impl CustomType { } } + +#[wasm_bindgen_test] +fn rename_with_string() { + renamed_with_dollar_sign(); +} + +#[wasm_bindgen_test] +fn rename_static_with_string() { + assert_eq!(RENAMED.as_f64(), Some(1.0)); +}