diff options
author | Nadrieril | 2020-05-30 14:16:37 +0100 |
---|---|---|
committer | GitHub | 2020-05-30 14:16:37 +0100 |
commit | f554164014a85b8d4d7248a8bdfa6dbcd2009988 (patch) | |
tree | 160f51119db6b7a54eaf986b2f188cf6e1f74bc9 /serde_dhall | |
parent | aaba9f7a1a6119443aa6a569e451e0e549e5bb37 (diff) | |
parent | a9b0923fb7a1f3aac5d872af70c4e4a0dd80621d (diff) |
Merge pull request #167 from Nadrieril/wasm
Diffstat (limited to '')
-rw-r--r-- | serde_dhall/Cargo.toml | 4 | ||||
-rw-r--r-- | serde_dhall/tests/de.rs | 2 | ||||
-rw-r--r-- | serde_dhall/tests/wasm.rs | 12 |
3 files changed, 16 insertions, 2 deletions
diff --git a/serde_dhall/Cargo.toml b/serde_dhall/Cargo.toml index 6842209..05a7255 100644 --- a/serde_dhall/Cargo.toml +++ b/serde_dhall/Cargo.toml @@ -15,8 +15,10 @@ serde = { version = "1.0", features = ["derive"] } dhall = { version = "= 0.5.2", path = "../dhall" } dhall_proc_macros = { version = "= 0.5.0", path = "../dhall_proc_macros" } doc-comment = "0.3" -reqwest = { version = "0.10", features = ["blocking"] } url = "2.1" +[target.'cfg(target_arch = "wasm32")'.dev-dependencies] +wasm-bindgen-test = "0.2" + [dev-dependencies] version-sync = "0.8" diff --git a/serde_dhall/tests/de.rs b/serde_dhall/tests/de.rs index 1932e26..a418563 100644 --- a/serde_dhall/tests/de.rs +++ b/serde_dhall/tests/de.rs @@ -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)); diff --git a/serde_dhall/tests/wasm.rs b/serde_dhall/tests/wasm.rs new file mode 100644 index 0000000..c719d84 --- /dev/null +++ b/serde_dhall/tests/wasm.rs @@ -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]); +} |