Merge pull request #683 from fitzgen/move-assertions

test: Ensure that `wasm-bindgen` will generate move assertions
master
ashley williams 6 years ago committed by GitHub
commit c2563eee0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      tests/all/build.rs

@ -175,11 +175,15 @@ fn build_with_and_without_wasm_bindgen_debug() {
#[wasm_bindgen]
impl MyThing {
#[wasm_bindgen(constructor)]
pub fn new() -> MyThing {
MyThing {}
}
}
pub fn take(self) {}
#[wasm_bindgen]
pub fn take(foo: MyThing) {
drop(foo);
}
"#,
)
@ -193,10 +197,14 @@ fn build_with_and_without_wasm_bindgen_debug() {
.success();
let contents = fs::read_to_string(fixture.path.join("pkg/whatever.js")).unwrap();
let contains_move_assertions =
contents.contains("throw new Error('Attempt to use a moved value')");
assert_eq!(
contents.contains("throw new Error('Attempt to use a moved value')"),
debug,
"Should only contain moved value assertions when debug assertions are enabled"
contains_move_assertions, debug,
"Should contain moved value assertions iff debug assertions are enabled. \
Contains move assertions? {}. \
Is a debug JS glue build? {}.",
contains_move_assertions, debug,
);
}
}

Loading…
Cancel
Save