wasm-bindgen/tests/headless.rs
Alex Crichton 0d18c8c397 Fix consuming a struct and returning a slice
This came up in a [recent comment][1] and it turns out we're accidentally
generating two `const ptr = ...` declarations, invalid JS! While Node doesn't
catch this it looks like firefox does.

[1]: https://github.com/rustwasm/wasm-bindgen/issues/329#issuecomment-411082013
2018-08-07 08:46:38 -07:00

28 lines
617 B
Rust

#![cfg(target_arch = "wasm32")]
#![feature(use_extern_macros)]
extern crate wasm_bindgen_test;
extern crate wasm_bindgen;
use wasm_bindgen_test::*;
use wasm_bindgen::prelude::*;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen]
pub struct ConsumeRetString;
#[wasm_bindgen]
impl ConsumeRetString {
// https://github.com/rustwasm/wasm-bindgen/issues/329#issuecomment-411082013
//
// This used to cause two `const ptr = ...` declarations, which is invalid
// JS.
pub fn consume(self) -> String { String::new() }
}
#[wasm_bindgen_test]
fn works() {
ConsumeRetString.consume();
}