⭐️ A friendly language for building type-safe, scalable systems!
at main 1.8 kB view raw
1use crate::{assert_js, assert_ts_def}; 2 3#[test] 4fn tuple() { 5 assert_js!( 6 r#" 7pub fn go() { 8 #("1", "2", "3") 9} 10"#, 11 ); 12} 13 14#[test] 15fn tuple1() { 16 assert_js!( 17 r#" 18pub fn go() { 19 #( 20 "1111111111111111111111111111111", 21 #("1111111111111111111111111111111", "2", "3"), 22 "3", 23 ) 24} 25"#, 26 ); 27} 28 29#[test] 30fn tuple_typescript() { 31 assert_ts_def!( 32 r#" 33pub fn go() { 34 #("1", "2", "3") 35} 36"#, 37 ); 38} 39 40#[test] 41fn tuple_access() { 42 assert_js!( 43 r#" 44pub fn go() { 45 #(1, 2).0 46} 47"#, 48 ) 49} 50 51#[test] 52fn tuple_with_block_element() { 53 assert_js!( 54 r#" 55pub fn go() { 56 #( 57 "1", 58 { 59 "2" 60 "3" 61 }, 62 ) 63} 64"#, 65 ); 66} 67 68#[test] 69fn tuple_with_block_element1() { 70 assert_js!( 71 r#" 72pub fn go() { 73 #( 74 "1111111111111111111111111111111", 75 #("1111111111111111111111111111111", "2", "3"), 76 "3", 77 ) 78} 79"#, 80 ); 81} 82 83#[test] 84fn constant_tuples() { 85 assert_js!( 86 r#" 87pub const a = "Hello" 88pub const b = 1 89pub const c = 2.0 90pub const e = #("bob", "dug") 91 "#, 92 ); 93} 94 95#[test] 96fn constant_tuples1() { 97 assert_js!( 98 r#" 99pub const e = #( 100 "loooooooooooooong", "loooooooooooong", "loooooooooooooong", 101 "loooooooooooooong", "loooooooooooong", "loooooooooooooong", 102) 103"# 104 ); 105} 106 107#[test] 108fn tuple_formatting_typescript() { 109 assert_ts_def!( 110 r#" 111pub const e = #( 112 "a", "a", "a", "a", "a", "a", "a", 113 "a", "a", "a", "a", "a", "a", "a", 114 "a", "a", "a", "a", "a", "a", "a", 115) 116"# 117 ); 118} 119 120#[test] 121fn case() { 122 assert_js!( 123 r#" 124pub fn go(a) { 125 case a { 126 #(2, a) -> a 127 #(1, 1) -> 1 128 #(a, b) -> a + b 129 } 130} 131"# 132 ); 133} 134 135#[test] 136fn nested_pattern() { 137 assert_js!( 138 r#" 139pub fn go(x) { 140 case x { 141 #(2, #(a, b)) -> a + b 142 _ -> 1 143 } 144} 145"# 146 ); 147}