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