Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimal wasm-bindgen test crate #696

Merged
merged 17 commits into from Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
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
gridbugs marked this conversation as resolved.
Show resolved Hide resolved
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
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
@@ -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();
}
}
dhardy marked this conversation as resolved.
Show resolved Hide resolved