| 1 |
use wasm_bindgen::prelude::*; |
| 2 |
use wasm_bindgen_test::*; |
| 3 |
|
| 4 |
#[wasm_bindgen(module = "tests/wasm/char.js")] |
| 5 |
extern "C" { |
| 6 |
fn js_identity(c: char) -> char; |
| 7 |
fn js_works(); |
| 8 |
} |
| 9 |
|
| 10 |
#[wasm_bindgen] |
| 11 |
pub fn rust_identity(c: char) -> char { |
| 12 |
c |
| 13 |
} |
| 14 |
|
| 15 |
#[wasm_bindgen] |
| 16 |
pub fn rust_option_identity(c: Option<char>) -> Option<char> { |
| 17 |
c |
| 18 |
} |
| 19 |
|
| 20 |
#[wasm_bindgen] |
| 21 |
pub fn rust_js_identity(c: char) -> char { |
| 22 |
js_identity(c) |
| 23 |
} |
| 24 |
|
| 25 |
#[wasm_bindgen] |
| 26 |
pub fn letter() -> char { |
| 27 |
'a' |
| 28 |
} |
| 29 |
|
| 30 |
#[wasm_bindgen] |
| 31 |
pub fn face() -> char { |
| 32 |
'😀' |
| 33 |
} |
| 34 |
|
| 35 |
#[wasm_bindgen] |
| 36 |
pub fn rust_letter(a: char) { |
| 37 |
assert_eq!(a, 'a'); |
| 38 |
} |
| 39 |
|
| 40 |
#[wasm_bindgen] |
| 41 |
pub fn rust_face(p: char) { |
| 42 |
assert_eq!(p, '😀'); |
| 43 |
} |
| 44 |
|
| 45 |
#[wasm_bindgen_test] |
| 46 |
fn works() { |
| 47 |
js_works(); |
| 48 |
} |