mirror of
https://github.com/penpot/penpot.git
synced 2026-03-23 02:44:04 +00:00
37 lines
601 B
Rust
37 lines
601 B
Rust
use wasm_bindgen::prelude::*;
|
|
|
|
pub fn add(left: u64, right: u64) -> u64 {
|
|
left + right
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
extern "C" {
|
|
#[wasm_bindgen(js_namespace = console)]
|
|
fn log(s: &str);
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
pub fn print(msg: &str) {
|
|
log(msg);
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use wasm_bindgen_test::*;
|
|
|
|
wasm_bindgen_test_configure!(run_in_browser);
|
|
|
|
#[test]
|
|
fn it_works() {
|
|
let result = add(2, 2);
|
|
assert_eq!(result, 4);
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
fn it_works_in_wasm() {
|
|
let result = add(2, 2);
|
|
assert_eq!(result, 4);
|
|
}
|
|
}
|