Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

gleam / format / src / tests / tuple.rs
1.9 kB 131 lines
1// SPDX-License-Identifier: Apache-2.0 2// SPDX-FileCopyrightText: 2023 The Gleam contributors 3 4use crate::{assert_format, assert_format_rewrite}; 5 6// https://github.com/gleam-lang/gleam/issues/2083 7#[test] 8fn nested_index_block() { 9 assert_format!( 10 r#"pub fn main() { 11 { #(1, 2).1 }.1 12} 13"# 14 ); 15} 16 17// https://github.com/gleam-lang/gleam/issues/2083 18#[test] 19fn index_block() { 20 assert_format!( 21 r#"pub fn main() { 22 { 23 1 24 #(1, 2) 25 }.1 26} 27"# 28 ); 29} 30 31#[test] 32fn tuple_with_last_splittable_arg() { 33 assert_format!( 34 r#"fn on_attribute_change() -> Dict(String, Decoder(Msg)) { 35 dict.from_list([ 36 #("value", fn(attr) { 37 attr 38 |> dynamic.int 39 |> result.map(Value) 40 |> result.map(AttributeChanged) 41 }), 42 ]) 43} 44"# 45 ); 46 47 assert_format!( 48 r#"pub fn main() { 49 #("value", [ 50 "a long list that needs to be split on multiple lines", 51 "another long string", 52 ]) 53} 54"# 55 ); 56} 57 58// https://github.com/gleam-lang/gleam/issues/3070 59#[test] 60fn constant_long_list_of_tuples() { 61 assert_format!( 62 r#"const wibble = [ 63 #(1, 2), 64 #(3, 4), 65 #(5, 6), 66 #(7, 8), 67 #(9, 10), 68 #(11, 12), 69 #(1, 2), 70 #(3, 4), 71 #(5, 6), 72 #(7, 8), 73 #(9, 10), 74 #(11, 12), 75] 76 77pub fn main() { 78 todo 79} 80"# 81 ); 82} 83 84#[test] 85fn nested_tuple_access() { 86 assert_format!( 87 r#"pub fn main() { 88 wibble.1.0 89} 90"# 91 ); 92} 93 94#[test] 95fn nested_tuple_with_needless_block() { 96 assert_format_rewrite!( 97 r#"pub fn main() { 98 { wibble.1 }.0 99} 100"#, 101 r#"pub fn main() { 102 wibble.1.0 103} 104"# 105 ); 106} 107 108#[test] 109fn nested_literal_tuple_with_needless_block_is_not_changed() { 110 assert_format!( 111 r#"pub fn main() { 112 { #(wibble, wobble).1 }.0 113} 114"# 115 ); 116} 117 118#[test] 119fn multi_line_tuple_trailing_comment() { 120 assert_format!( 121 "const tuple = #( 122 1, 123 2, 124 3, 125 // 4, 126 // 5, 127 // 6, 128) 129" 130 ); 131}