this repo has no description
at wasm 138 lines 2.2 kB view raw
1use crate::assert_js; 2 3#[test] 4fn custom_type_constructor_imported_and_aliased() { 5 assert_js!( 6 ("package", "other_module", "pub type T { A }"), 7 r#"import other_module.{A as B} 8 9pub const local = B 10"#, 11 ); 12} 13 14#[test] 15fn imported_aliased_ok() { 16 assert_js!( 17 r#"import gleam.{Ok as Y} 18 19pub type X { 20 Ok 21} 22 23pub const y = Y 24"#, 25 ); 26} 27 28#[test] 29fn imported_ok() { 30 assert_js!( 31 r#"import gleam 32 33pub type X { 34 Ok 35} 36 37pub const y = gleam.Ok 38"#, 39 ); 40} 41 42#[test] 43fn constant_constructor_gets_pure_annotation() { 44 assert_js!( 45 r#" 46pub type X { 47 X(Int, List(String)) 48} 49 50pub const x = X(1, ["1"]) 51pub const y = X(1, []) 52 "# 53 ); 54} 55 56#[test] 57fn constant_list_with_constructors_gets_pure_annotation() { 58 assert_js!( 59 r#" 60pub type X { 61 X(Int, List(String)) 62} 63 64pub const x = [X(1, ["1"])] 65pub const y = [X(1, ["1"])] 66 "# 67 ); 68} 69 70#[test] 71fn constant_tuple_with_constructors_gets_pure_annotation() { 72 assert_js!( 73 r#" 74pub type X { 75 X(Int, List(String)) 76} 77 78pub const x = #(X(1, ["1"])) 79pub const y = #(X(1, ["1"])) 80 "# 81 ); 82} 83 84#[test] 85fn literal_int_does_not_get_constant_annotation() { 86 assert_js!("pub const a = 1"); 87} 88 89#[test] 90fn literal_float_does_not_get_constant_annotation() { 91 assert_js!("pub const a = 1.1"); 92} 93 94#[test] 95fn literal_string_does_not_get_constant_annotation() { 96 assert_js!("pub const a = \"1\""); 97} 98 99#[test] 100fn literal_bool_does_not_get_constant_annotation() { 101 assert_js!( 102 " 103 pub const a = True 104 pub const b = False 105 " 106 ); 107} 108 109#[test] 110fn literal_list_does_not_get_constant_annotation() { 111 assert_js!("pub const a = [1, 2, 3]"); 112} 113 114#[test] 115fn literal_tuple_does_not_get_constant_annotation() { 116 assert_js!("pub const a = #(1, 2, 3)"); 117} 118 119#[test] 120fn literal_nil_does_not_get_constant_annotation() { 121 assert_js!("pub const a = Nil"); 122} 123 124// https://github.com/lpil/decode/pull/6 125#[test] 126fn constructor_function_in_constant() { 127 assert_js!("pub const a = Ok"); 128} 129 130#[test] 131fn constants_get_their_own_jsdoc_comment() { 132 assert_js!( 133 " 134/// 11 is clearly the best number! 135pub const jaks_favourite_number = 11 136" 137 ); 138}