Fork of daniellemaywood.uk/gleam — Wasm codegen work
1.1 kB
88 lines
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2021 The Gleam contributors
3
4use crate::{assert_js, assert_ts_def};
5
6#[test]
7fn without_message() {
8 assert_js!(
9 r#"
10pub fn go() {
11 todo
12}
13"#,
14 );
15}
16
17#[test]
18fn without_message_typescript() {
19 assert_ts_def!(
20 r#"
21pub fn go() {
22 todo
23}
24"#,
25 );
26}
27
28#[test]
29fn with_message() {
30 assert_js!(
31 r#"
32pub fn go() {
33 todo as "I should do this"
34}
35"#,
36 );
37}
38
39#[test]
40fn with_message_expr() {
41 assert_js!(
42 r#"
43pub fn go() {
44 let x = "I should " <> "do this"
45 todo as x
46}
47"#,
48 );
49}
50
51// https://github.com/gleam-lang/gleam/issues/1238
52#[test]
53fn as_expression() {
54 assert_js!(
55 r#"
56pub fn go(f) {
57 let boop = todo as "I should do this"
58 f(todo as "Boom")
59}
60"#,
61 );
62}
63
64// https://github.com/gleam-lang/gleam/issues/4471
65#[test]
66fn case_message() {
67 assert_js!(
68 r#"
69pub fn unimplemented(message) {
70 panic as case message {
71 Ok(message) -> message
72 Error(_) -> "No message provided"
73 }
74}
75"#
76 );
77}
78
79#[test]
80fn inside_fn() {
81 assert_js!(
82 r#"
83pub fn main() {
84 fn() { todo }
85}
86"#
87 );
88}