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

test: Ensure that wasm-bindgen will generate move assertions #683

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions tests/all/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,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);
}
"#,
)
Expand All @@ -192,10 +196,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,
);
}
}
Expand Down