Fork of daniellemaywood.uk/gleam — Wasm codegen work
1.1 kB
57 lines
1use crate::assert_js;
2
3#[test]
4fn type_() {
5 assert_js!(r#"pub external type Thing"#,);
6}
7
8#[test]
9fn module_fn() {
10 assert_js!(r#"external fn show(anything) -> Nil = "utils" "inspect""#,);
11}
12
13#[test]
14fn pub_module_fn() {
15 assert_js!(r#"pub external fn show(anything) -> Nil = "utils" "inspect""#,);
16}
17
18#[test]
19fn global_fn() {
20 assert_js!(r#"external fn down(Float) -> Float = "" "Math.floor""#,);
21}
22
23#[test]
24fn pub_global_fn() {
25 assert_js!(r#"pub external fn down(Float) -> Float = "" "Math.floor""#,);
26}
27
28#[test]
29fn same_name_global_external() {
30 assert_js!(r#"pub external fn fetch(Nil) -> Nil = "" "fetch""#,);
31}
32
33#[test]
34fn same_module_multiple_imports() {
35 assert_js!(
36 r#"pub external fn one() -> Nil = "./the/module.mjs" "one"
37pub external fn two() -> Nil = "./the/module.mjs" "two"
38"#,
39 );
40}
41
42#[test]
43fn duplicate_import() {
44 assert_js!(
45 r#"pub external fn one() -> Nil = "./the/module.mjs" "dup"
46pub external fn two() -> Nil = "./the/module.mjs" "dup"
47"#,
48 );
49}
50
51#[test]
52fn name_to_escape() {
53 assert_js!(
54 r#"pub external fn class() -> Nil = "./the/module.mjs" "one"
55"#,
56 );
57}