mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-08 21:28:07 +00:00
test(js) New WebAssembly.validate_with_invalid_input
test case.
This commit is contained in:
parent
d1955c91b7
commit
b4bf8fbfba
@ -31,3 +31,38 @@ fn validate() {
|
|||||||
"#)
|
"#)
|
||||||
.test()
|
.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn validate_with_invalid_input() {
|
||||||
|
project()
|
||||||
|
.file("src/lib.rs", r#"
|
||||||
|
#![feature(proc_macro, wasm_custom_section)]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen;
|
||||||
|
use JsValue;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
use wasm_bindgen::js::WebAssembly;
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn validate_wasm(wasm: JsValue) -> JsValue {
|
||||||
|
match WebAssembly::validate(wasm) {
|
||||||
|
Ok(value) => value.into(),
|
||||||
|
Err(err) => err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.file("test.js", r#"
|
||||||
|
import * as assert from "assert";
|
||||||
|
import * as wasm from "./out";
|
||||||
|
|
||||||
|
export function test() {
|
||||||
|
try {
|
||||||
|
wasm.validate_wasm(42);
|
||||||
|
assert.ok(false);
|
||||||
|
} catch (e) {
|
||||||
|
assert.ok(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.test()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user