Fork of daniellemaywood.uk/gleam — Wasm codegen work
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2025 The Gleam contributors
3
4use crate::assert_format;
5
6// https://github.com/gleam-lang/gleam/issues/5143
7#[test]
8pub fn constant_with_deprecated_attribute() {
9 assert_format!(
10 r#"@deprecated("Use tau instead")
11pub const pi = 3.14
12"#
13 );
14}
15
16#[test]
17fn const_record_update_simple() {
18 assert_format!(
19 r#"pub type Counter {
20 Counter(a: Int, b: Int)
21}
22
23pub const c = Counter(0, 0)
24
25pub const c2 = Counter(..c, a: 1, b: 2)
26"#
27 );
28}
29
30#[test]
31fn const_record_update_long() {
32 assert_format!(
33 r#"pub type Counter {
34 Counter(loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong: Int)
35}
36
37pub const c = Counter(0)
38
39pub const c2 = Counter(
40 ..c,
41 loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong: 1,
42)
43"#
44 );
45}
46
47#[test]
48fn const_record_update_with_module() {
49 assert_format!(
50 r#"pub type Counter {
51 Counter(a: Int, b: Int)
52}
53
54pub const c = Counter(0, 0)
55
56pub const c2 = mod.Counter(..c, a: 1)
57"#
58 );
59}
60
61#[test]
62fn const_list_prepend() {
63 assert_format!(
64 "pub const wibble = [2, 3, 4]
65
66pub const wobble = [0, 1, ..wibble]
67"
68 );
69}
70
71#[test]
72fn const_list_prepend_multiline() {
73 assert_format!(
74 r#"pub const wibble = ["Hello", "world"]
75
76pub const wobble = [
77 "Some really long message that causes the line to wrap",
78 "Something else",
79 ..wibble
80]
81"#
82 );
83}
84
85#[test]
86fn const_list_prepend_multiline_with_comments() {
87 assert_format!(
88 r#"pub const wibble = ["Hello", "world"]
89
90pub const wobble = [
91 "Some really long message that causes the line to wrap",
92 // Some comment
93 "Something else",
94 // Prepend the values to `wibble`
95 ..wibble
96 // End of list
97]
98"#
99 );
100}
101
102#[test]
103fn constant_todo_message() {
104 assert_format!(
105 r#"pub const wibble = todo as "message"
106"#
107 );
108}
109
110#[test]
111fn constant_todo_commented_message() {
112 assert_format!(
113 r#"pub const wibble = todo as
114 // some comment
115 "message"
116"#
117 );
118}