⭐️ A friendly language for building type-safe, scalable systems!
at main 828 B view raw
1use crate::assert_ts_def; 2 3#[test] 4fn fn_generics_typescript() { 5 assert_ts_def!( 6 r#"pub fn identity(a) -> a { 7 a 8} 9"#, 10 ); 11} 12 13#[test] 14fn record_generics_typescript() { 15 assert_ts_def!( 16 r#"pub type Animal(t) { 17 Cat(type_: t) 18 Dog(type_: t) 19} 20 21pub fn main() { 22 Cat(type_: 6) 23} 24"#, 25 ); 26} 27 28#[test] 29fn tuple_generics_typescript() { 30 assert_ts_def!( 31 r#"pub fn make_tuple(x: t) -> #(Int, t, Int) { 32 #(0, x, 1) 33} 34"#, 35 ); 36} 37 38#[test] 39fn result_typescript() { 40 assert_ts_def!( 41 r#"pub fn map(result, fun) { 42 case result { 43 Ok(a) -> Ok(fun(a)) 44 Error(e) -> Error(e) 45 } 46 }"#, 47 ); 48} 49 50#[test] 51fn task_typescript() { 52 assert_ts_def!( 53 r#"pub type Promise(value) 54 pub type Task(a) = fn() -> Promise(a)"#, 55 ); 56}