Skip to content

Commit

Permalink
Add a test for Rust issue #56639
Browse files Browse the repository at this point in the history
Technically we don't need this right now, but it's good to have
just in case we decide go to back to using custom sections some
time in the future.
  • Loading branch information
koute committed Dec 13, 2018
1 parent 5f5e8ed commit 9a69be9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions standalone-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ stdweb-derive = { path = "../stdweb-derive" }

serde = "1"
serde_derive = "1"

dependency = { path = "dependency" }
7 changes: 7 additions & 0 deletions standalone-tests/dependency/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "dependency"
version = "0.1.0"
authors = ["Jan Bujak <[email protected]>"]

[dependencies]
stdweb = { path = "../.." }
14 changes: 14 additions & 0 deletions standalone-tests/dependency/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#[macro_use]
extern crate stdweb;

pub fn call() {
submodule::call();
}

mod submodule {
pub(crate) fn call() {
js!( @(no_return)
Module.test_value = 123;
);
}
}
2 changes: 2 additions & 0 deletions standalone-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ extern crate serde;
#[macro_use]
extern crate serde_derive;

extern crate dependency;

use std::panic;

#[macro_use]
Expand Down
2 changes: 2 additions & 0 deletions standalone-tests/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
mod test_js_export;
mod test_derive_reference_type;
mod test_misc;

pub mod exports {
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
Expand All @@ -11,4 +12,5 @@ pub fn run_all_tests() {
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
test_js_export::run();
test_derive_reference_type::run();
test_misc::run();
}
12 changes: 12 additions & 0 deletions standalone-tests/src/tests/test_misc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use utils::*;
use dependency;

pub fn run() {
// See https://github.com/rust-lang/rust/issues/56639 for more details.
test( "indirectly_call_js_snippet_from_a_submodule_in_another_crate", || {
dependency::call();
js! {
assert.strictEqual( Module.test_value, 123 );
}
});
}

0 comments on commit 9a69be9

Please sign in to comment.