this repo has no description
at wasm 102 lines 1.4 kB view raw
1use crate::{assert_js, assert_ts_def}; 2 3#[test] 4fn qualified_ok() { 5 assert_js!( 6 r#"import gleam 7pub fn go() { gleam.Ok(1) } 8"#, 9 ); 10} 11 12#[test] 13fn qualified_ok_typescript() { 14 assert_ts_def!( 15 r#"import gleam 16pub fn go() { gleam.Ok(1) } 17"#, 18 ); 19} 20 21#[test] 22fn qualified_error() { 23 assert_js!( 24 r#"import gleam 25pub fn go() { gleam.Error(1) } 26"#, 27 ); 28} 29 30#[test] 31fn qualified_nil() { 32 assert_js!( 33 r#"import gleam 34pub fn go() { gleam.Nil } 35"#, 36 ); 37} 38 39#[test] 40fn qualified_nil_typescript() { 41 assert_ts_def!( 42 r#"import gleam 43pub fn go() { gleam.Nil } 44"#, 45 ); 46} 47 48// https://github.com/gleam-lang/gleam/issues/4756 49#[test] 50fn qualified_prelude_value_does_not_conflict_with_local_value() { 51 assert_js!( 52 " 53import gleam 54 55pub type Result(a, e) { 56 Ok(a) 57 Error(e) 58} 59 60pub fn main() { 61 gleam.Ok(10) 62} 63", 64 ); 65} 66 67#[test] 68fn qualified_prelude_value_does_not_conflict_with_local_value_constant() { 69 assert_js!( 70 r#" 71import gleam 72 73pub type Result(a, e) { 74 Ok(a) 75 Error(e) 76} 77 78pub const error = gleam.Error("Bad") 79"#, 80 ); 81} 82 83#[test] 84fn qualified_prelude_value_does_not_conflict_with_local_value_pattern() { 85 assert_js!( 86 r#" 87import gleam 88 89pub type Result(a, e) { 90 Ok(a) 91 Error(e) 92} 93 94pub fn go(x) { 95 case x { 96 gleam.Ok(x) -> x 97 gleam.Error(_) -> 0 98 } 99} 100"#, 101 ); 102}