Skip to content

Commit

Permalink
Re-add wasm-bindgen-test tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gridbugs committed Jan 18, 2019
1 parent a2ffbf5 commit 13dafd9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ matrix:
- cargo web -V
- cargo list | grep install-update || cargo install -f cargo-update
- cargo install-update -i cargo-update wasm-bindgen-cli
- cargo install-update -i cargo-update wasm-pack
addons:
chrome: stable
script:
Expand All @@ -159,6 +160,7 @@ matrix:
- cargo build --manifest-path tests/wasm_bindgen/Cargo.toml --target wasm32-unknown-unknown
- wasm-bindgen --nodejs target/wasm32-unknown-unknown/debug/rand_wasm_bindgen_test.wasm --out-dir tests/wasm_bindgen/js
- node tests/wasm_bindgen/js/index.js
- wasm-pack test --node tests/wasm_bindgen

- rust: nightly
env: DESCRIPTION="cross-platform builder (doesn't run tests)"
Expand Down
1 change: 1 addition & 0 deletions tests/wasm_bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ crate-type = ["cdylib"]
[dependencies]
rand = { path = "../..", features = ["wasm-bindgen"] }
wasm-bindgen = "0.2"
wasm-bindgen-test = "0.2"
20 changes: 20 additions & 0 deletions tests/wasm_bindgen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extern crate rand;
extern crate wasm_bindgen;
extern crate wasm_bindgen_test;

use rand::rngs::{OsRng, StdRng};
use rand::FromEntropy;
Expand All @@ -20,3 +21,22 @@ pub fn generate_from_os_rand() -> i32 {
pub fn generate_from_entropy() -> i32 {
StdRng::from_entropy().gen()
}

pub mod tests {
use wasm_bindgen_test::*;

#[wasm_bindgen_test]
fn generate_from_seed() {
let _ = super::generate_from_seed(42);
}

#[wasm_bindgen_test]
fn generate_from_os_rand() {
let _ = super::generate_from_os_rand();
}

#[wasm_bindgen_test]
fn generate_from_entropy() {
let _ = super::generate_from_entropy();
}
}

0 comments on commit 13dafd9

Please sign in to comment.