Skip to content

Commit

Permalink
ci: test wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed May 30, 2020
1 parent 15b20bd commit 9254465
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,25 @@ jobs:
with:
command: test

test_wasm:
name: Run wasm tests
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- name: Checkout branch
uses: actions/checkout@master
with:
submodules: true
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Run tests
run: wasm-pack test serde_dhall --node
61 changes: 61 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions serde_dhall/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ dhall_proc_macros = { version = "= 0.5.0", path = "../dhall_proc_macros" }
doc-comment = "0.3"
url = "2.1"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.2"

[dev-dependencies]
version-sync = "0.8"
2 changes: 1 addition & 1 deletion serde_dhall/tests/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn test_de_typed() {
assert_eq!(parse::<f32>("1.0"), 1.0);

assert_eq!(parse::<String>(r#""foo""#), "foo".to_owned());
assert_eq!(parse::<Vec<u64>>("[] : List Natural"), vec![]);
assert_eq!(parse::<Vec<u64>>("[] : List Natural"), <Vec<u64>>::new());
assert_eq!(parse::<Vec<u64>>("[1, 2]"), vec![1, 2]);
assert_eq!(parse::<Option<u64>>("None Natural"), None);
assert_eq!(parse::<Option<u64>>("Some 1"), Some(1));
Expand Down
12 changes: 12 additions & 0 deletions serde_dhall/tests/wasm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;

use serde_dhall::{from_str, FromDhall, StaticType};

#[wasm_bindgen_test]
fn test() {
fn parse<T: FromDhall + StaticType>(s: &str) -> T {
from_str(s).static_type_annotation().parse().unwrap()
}
assert_eq!(parse::<Vec<u64>>("[1, 2]"), vec![1, 2]);
}

0 comments on commit 9254465

Please sign in to comment.