Fork of daniellemaywood.uk/gleam — Wasm codegen work
1.1 kB
94 lines
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2021 The Gleam contributors
3
4use crate::assert_erl;
5
6#[test]
7fn numbers_with_underscores() {
8 assert_erl!(
9 r#"
10pub fn main() {
11 100_000
12 100_000.00101
13}
14"#
15 );
16}
17
18#[test]
19fn numbers_with_underscores1() {
20 assert_erl!(
21 r#"
22const i = 100_000
23const f = 100_000.00101
24pub fn main() {
25 i
26 f
27}
28"#
29 );
30}
31
32#[test]
33fn numbers_with_underscores2() {
34 assert_erl!(
35 r#"
36pub fn main() {
37 let assert 100_000 = 1
38 let assert 100_000.00101 = 1.
39 1
40}
41"#
42 );
43}
44
45#[test]
46fn numbers_with_scientific_notation() {
47 assert_erl!(
48 r#"
49const i = 100.001e223
50const j = -100.001e-223
51
52pub fn main() {
53 i
54 j
55}
56"#
57 );
58}
59
60#[test]
61fn int_negation() {
62 assert_erl!(
63 r#"
64pub fn main() {
65 let a = 3
66 let b = -a
67}
68"#
69 );
70}
71
72#[test]
73fn repeated_int_negation() {
74 assert_erl!(
75 r#"
76pub fn main() {
77 let a = 3
78 let b = --a
79}
80"#
81 );
82}
83
84// https://github.com/gleam-lang/gleam/issues/2356
85#[test]
86fn zero_b_in_hex() {
87 assert_erl!(
88 r#"
89pub fn main() {
90 0xffe0bb
91}
92"#
93 );
94}