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 / echo.rs
4.0 kB 302 lines
1// SPDX-License-Identifier: Apache-2.0 2// SPDX-FileCopyrightText: 2025 The Gleam contributors 3 4use crate::{assert_format, assert_format_rewrite}; 5 6#[test] 7fn echo() { 8 assert_format!( 9 "fn main() { 10 echo 11} 12" 13 ); 14} 15 16#[test] 17fn echo_with_value() { 18 assert_format!( 19 r#"fn main() { 20 echo value 21} 22"# 23 ); 24} 25 26#[test] 27fn echo_with_big_value_that_needs_to_be_split() { 28 assert_format!( 29 r#"fn main() { 30 echo [ 31 this_is_a_long_list_and_requires_splitting, 32 wibble_wobble_woo, 33 multiple_lines, 34 ] 35} 36"# 37 ); 38} 39 40#[test] 41fn echo_inside_a_pipeline() { 42 assert_format!( 43 r#"fn main() { 44 wibble 45 |> echo 46 |> wobble 47} 48"# 49 ); 50} 51 52#[test] 53fn echo_inside_a_single_line_pipeline() { 54 assert_format!( 55 r#"fn main() { 56 wibble |> echo |> wobble 57} 58"# 59 ); 60} 61 62#[test] 63fn echo_as_last_item_of_pipeline() { 64 assert_format!( 65 r#"fn main() { 66 wibble |> wobble |> echo 67} 68"# 69 ); 70} 71 72#[test] 73fn echo_as_last_item_of_multiline_pipeline() { 74 assert_format!( 75 r#"fn main() { 76 wibble 77 |> wobble 78 |> echo 79} 80"# 81 ); 82} 83 84#[test] 85fn echo_with_related_expression_on_following_line() { 86 assert_format_rewrite!( 87 r#"fn main() { 88 panic as echo 89 "wibble" 90} 91"#, 92 r#"fn main() { 93 panic as echo "wibble" 94} 95"# 96 ); 97} 98 99#[test] 100fn echo_with_following_value_in_a_pipeline() { 101 assert_format_rewrite!( 102 r#"fn main() { 103 [] 104 |> echo wibble 105 |> wobble 106} 107"#, 108 r#"fn main() { 109 [] 110 |> echo 111 wibble 112 |> wobble 113} 114"# 115 ); 116} 117 118#[test] 119fn echo_printing_multiline_pipeline() { 120 assert_format_rewrite!( 121 r#"fn main() { 122 echo first 123 |> wibble 124 |> wobble 125} 126"#, 127 r#"fn main() { 128 echo first 129 |> wibble 130 |> wobble 131} 132"# 133 ); 134} 135 136#[test] 137fn echo_printing_one_line_pipeline() { 138 assert_format!( 139 r#"fn main() { 140 echo first |> wibble |> wobble 141} 142"# 143 ); 144} 145 146#[test] 147fn echo_as() { 148 assert_format!( 149 "fn main() { 150 echo as hello 151} 152" 153 ); 154} 155 156#[test] 157fn echo_as_with_value() { 158 assert_format!( 159 r#"fn main() { 160 echo value as message 161} 162"# 163 ); 164} 165 166#[test] 167fn echo_as_with_big_value_that_needs_to_be_split() { 168 assert_format!( 169 r#"fn main() { 170 echo call([ 171 this_is_a_long_list_and_requires_splitting, 172 wibble_wobble_woo, 173 multiple_lines, 174 ]) 175 as "tag!" 176} 177"# 178 ); 179} 180 181#[test] 182fn echo_as_inside_a_pipeline() { 183 assert_format!( 184 r#"fn main() { 185 wibble 186 |> echo as "echooo o o" 187 |> wobble 188} 189"# 190 ); 191} 192 193#[test] 194fn echo_as_inside_a_single_line_pipeline() { 195 assert_format!( 196 r#"fn main() { 197 wibble |> echo as string |> wobble 198} 199"# 200 ); 201} 202 203#[test] 204fn echo_as_as_last_item_of_pipeline() { 205 assert_format!( 206 r#"fn main() { 207 wibble |> wobble |> echo as end 208} 209"# 210 ); 211} 212 213#[test] 214fn echo_as_as_last_item_of_multiline_pipeline() { 215 assert_format!( 216 r#"fn main() { 217 wibble 218 |> wobble 219 |> echo as message 220} 221"# 222 ); 223} 224 225#[test] 226fn echo_as_with_related_expression_on_following_line() { 227 assert_format_rewrite!( 228 r#"fn main() { 229 panic as echo 230 "wibble" 231 as wobble 232} 233"#, 234 r#"fn main() { 235 panic as echo "wibble" as wobble 236} 237"# 238 ); 239} 240 241#[test] 242fn echo_as_with_following_value_in_a_pipeline() { 243 assert_format_rewrite!( 244 r#"fn main() { 245 [] 246 |> echo as wibble wibble 247 |> wobble 248} 249"#, 250 r#"fn main() { 251 [] 252 |> echo as wibble 253 wibble 254 |> wobble 255} 256"# 257 ); 258} 259 260#[test] 261fn echo_as_printing_multiline_pipeline() { 262 assert_format_rewrite!( 263 r#"fn main() { 264 echo first 265 |> wibble 266 |> wobble 267 as "pipeline" 268} 269"#, 270 r#"fn main() { 271 echo first 272 |> wibble 273 |> wobble 274 as "pipeline" 275} 276"# 277 ); 278} 279 280#[test] 281fn echo_as_printing_one_line_pipeline() { 282 assert_format!( 283 r#"fn main() { 284 echo first |> wibble |> wobble as "pipeline" 285} 286"# 287 ); 288} 289 290#[test] 291fn echo_as_with_multiline_message() { 292 assert_format!( 293 r#"fn main() { 294 echo [wibble, wobble] 295 as { 296 // Force this block to split 297 "wibble" <> wobble() 298 } 299} 300"# 301 ); 302}