Fork of daniellemaywood.uk/gleam — Wasm codegen work
Something went wrong. Try again.
2.7 kB · 172 lines
Rust
at wasm
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173// SPDX-License-Identifier: Apache-2.0// SPDX-FileCopyrightText: 2024 The Gleam contributors
use crate::assert_js;
#[test]fn custom_type_constructor_imported_and_aliased() { assert_js!( ("package", "other_module", "pub type T { A }"), r#"import other_module.{A as B}
pub const local = B"#, );}
#[test]fn imported_aliased_ok() { assert_js!( r#"import gleam.{Ok as Y}
pub type X { Ok}
pub const y = Y"#, );}
#[test]fn imported_ok() { assert_js!( r#"import gleam
pub type X { Ok}
pub const y = gleam.Ok"#, );}
#[test]fn constant_constructor_gets_pure_annotation() { assert_js!( r#"pub type X { X(Int, List(String))}
pub const x = X(1, ["1"])pub const y = X(1, []) "# );}
#[test]fn constant_list_with_constructors_gets_pure_annotation() { assert_js!( r#"pub type X { X(Int, List(String))}
pub const x = [X(1, ["1"])]pub const y = [X(1, ["1"])] "# );}
#[test]fn constant_tuple_with_constructors_gets_pure_annotation() { assert_js!( r#"pub type X { X(Int, List(String))}
pub const x = #(X(1, ["1"]))pub const y = #(X(1, ["1"])) "# );}
#[test]fn literal_int_does_not_get_constant_annotation() { assert_js!("pub const a = 1");}
#[test]fn literal_float_does_not_get_constant_annotation() { assert_js!("pub const a = 1.1");}
#[test]fn literal_string_does_not_get_constant_annotation() { assert_js!("pub const a = \"1\"");}
#[test]fn literal_bool_does_not_get_constant_annotation() { assert_js!( " pub const a = True pub const b = False " );}
#[test]fn literal_list_does_not_get_constant_annotation() { assert_js!("pub const a = [1, 2, 3]");}
#[test]fn literal_tuple_does_not_get_constant_annotation() { assert_js!("pub const a = #(1, 2, 3)");}
#[test]fn literal_nil_does_not_get_constant_annotation() { assert_js!("pub const a = Nil");}
// https://github.com/lpil/decode/pull/6#[test]fn constructor_function_in_constant() { assert_js!("pub const a = Ok");}
#[test]fn constants_get_their_own_jsdoc_comment() { assert_js!( "/// 11 is clearly the best number!pub const jaks_favourite_number = 11" );}
#[test]fn list_prepend() { assert_js!( "const wibble = [2, 3, 4]pub const wobble = [0, 1, ..wibble]" );}
#[test]fn list_prepend_from_other_module() { assert_js!( ("mod", "pub const wibble = [2, 3, 4]"), "import mod
pub const wobble = [0, 1, ..mod.wibble]" );}
#[test]fn list_prepend_literal() { assert_js!( "pub const wibble = [0, 1, ..[2, 3, 4]]" );}