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

Configure Feed

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

JavaScript dead code elimination

+1789 -1363
+21
compiler-core/src/javascript.rs
··· 308 308 // Handled in collect_definitions 309 309 Definition::CustomType(CustomType { .. }) => None, 310 310 311 + // If a custom type is unused then we don't need to generate code for it 312 + Definition::ModuleConstant(ModuleConstant { location, .. }) 313 + | Definition::Function(Function { location, .. }) 314 + if self 315 + .module 316 + .unused_definition_positions 317 + .contains(&location.start) => 318 + { 319 + None 320 + } 321 + 311 322 Definition::ModuleConstant(ModuleConstant { 312 323 publicity, 313 324 name, ··· 413 424 .definitions 414 425 .iter() 415 426 .flat_map(|statement| match statement { 427 + // If a custom type is unused then we don't need to generate code for it 428 + Definition::CustomType(CustomType { location, .. }) 429 + if self 430 + .module 431 + .unused_definition_positions 432 + .contains(&location.start) => 433 + { 434 + vec![] 435 + } 436 + 416 437 Definition::CustomType(CustomType { 417 438 publicity, 418 439 constructors,
+13 -13
compiler-core/src/javascript/tests/assignments.rs
··· 4 4 fn tuple_matching() { 5 5 assert_js!( 6 6 r#" 7 - fn go(x) { 7 + pub fn go(x) { 8 8 let assert #(1, 2) = x 9 9 } 10 10 "#, ··· 13 13 14 14 #[test] 15 15 fn assert() { 16 - assert_js!(r#"fn go(x) { let assert 1 = x }"#,); 16 + assert_js!(r#"pub fn go(x) { let assert 1 = x }"#,); 17 17 } 18 18 19 19 #[test] 20 20 fn assert1() { 21 - assert_js!(r#"fn go(x) { let assert #(1, 2) = x }"#,); 21 + assert_js!(r#"pub fn go(x) { let assert #(1, 2) = x }"#,); 22 22 } 23 23 24 24 #[test] 25 25 fn nested_binding() { 26 26 assert_js!( 27 27 r#" 28 - fn go(x) { 28 + pub fn go(x) { 29 29 let assert #(a, #(b, c, 2) as t, _, 1) = x 30 30 } 31 31 "#, ··· 37 37 assert_js!( 38 38 r#" 39 39 40 - fn go(x, wibble) { 40 + pub fn go(x, wibble) { 41 41 let a = 1 42 42 wibble(a) 43 43 let a = 2 ··· 64 64 r#" 65 65 const a = True 66 66 67 - fn go() { 67 + pub fn go() { 68 68 a 69 69 let a = 10 70 70 a + 20 ··· 80 80 81 81 #[test] 82 82 fn returning_literal_subject() { 83 - assert_js!(r#"fn go(x) { let assert 1 = x + 1 }"#,); 83 + assert_js!(r#"pub fn go(x) { let assert 1 = x + 1 }"#,); 84 84 } 85 85 86 86 #[test] ··· 274 274 Wibble(Int) 275 275 } 276 276 277 - fn go() { 277 + pub fn go() { 278 278 let assert Wibble(n) = Wibble(1) 279 279 n 280 280 } ··· 291 291 Wobble(Int) 292 292 } 293 293 294 - fn go() { 294 + pub fn go() { 295 295 let assert Wobble(n) = Wibble(1) 296 296 n 297 297 } ··· 308 308 Wobble(Int) 309 309 } 310 310 311 - fn go() { 311 + pub fn go() { 312 312 let assert _ = Wibble(1) 313 313 1 314 314 } ··· 326 326 Woo(Int) 327 327 } 328 328 329 - fn go() { 329 + pub fn go() { 330 330 let assert Wobble(n) = todo 331 331 n 332 332 } ··· 346 346 347 347 fn fun(f) { f(Wibble(1)) } 348 348 349 - fn go() { 349 + pub fn go() { 350 350 use _ <- fun 351 351 1 352 352 } ··· 360 360 r#" 361 361 fn fun(f) { f(#(2, 4)) } 362 362 363 - fn go() { 363 + pub fn go() { 364 364 use #(_, n) <- fun 365 365 n 366 366 }
+144 -144
compiler-core/src/javascript/tests/bit_arrays.rs
··· 10 10 fn empty() { 11 11 assert_js!( 12 12 r#" 13 - fn go() { 13 + pub fn go() { 14 14 <<>> 15 15 } 16 16 "#, ··· 21 21 fn one() { 22 22 assert_js!( 23 23 r#" 24 - fn go() { 24 + pub fn go() { 25 25 <<256>> 26 26 } 27 27 "#, ··· 32 32 fn two() { 33 33 assert_js!( 34 34 r#" 35 - fn go() { 35 + pub fn go() { 36 36 <<256, 4>> 37 37 } 38 38 "#, ··· 43 43 fn integer() { 44 44 assert_js!( 45 45 r#" 46 - fn go() { 46 + pub fn go() { 47 47 <<256:int>> 48 48 } 49 49 "#, ··· 54 54 fn float() { 55 55 assert_js!( 56 56 r#" 57 - fn go() { 57 + pub fn go() { 58 58 <<1.1:float>> 59 59 } 60 60 "#, ··· 65 65 fn float_big_endian() { 66 66 assert_js!( 67 67 r#" 68 - fn go() { 68 + pub fn go() { 69 69 <<1.1:float-big>> 70 70 } 71 71 "#, ··· 76 76 fn float_little_endian() { 77 77 assert_js!( 78 78 r#" 79 - fn go() { 79 + pub fn go() { 80 80 <<1.1:float-little>> 81 81 } 82 82 "#, ··· 87 87 fn float_sized() { 88 88 assert_js!( 89 89 r#" 90 - fn go() { 90 + pub fn go() { 91 91 <<1.1:float-32>> 92 92 } 93 93 "#, ··· 98 98 fn float_sized_big_endian() { 99 99 assert_js!( 100 100 r#" 101 - fn go() { 101 + pub fn go() { 102 102 <<1.1:float-32-big>> 103 103 } 104 104 "#, ··· 109 109 fn float_sized_little_endian() { 110 110 assert_js!( 111 111 r#" 112 - fn go() { 112 + pub fn go() { 113 113 <<1.1:float-32-little>> 114 114 } 115 115 "#, ··· 120 120 fn sized_constant_value() { 121 121 assert_js!( 122 122 r#" 123 - fn go() { 123 + pub fn go() { 124 124 <<256:64>> 125 125 } 126 126 "#, ··· 131 131 fn sized_dynamic_value() { 132 132 assert_js!( 133 133 r#" 134 - fn go(i: Int) { 134 + pub fn go(i: Int) { 135 135 <<i:64>> 136 136 } 137 137 "#, ··· 142 142 fn sized_constant_value_positive_overflow() { 143 143 assert_js!( 144 144 r#" 145 - fn go() { 145 + pub fn go() { 146 146 <<80_000:16>> 147 147 } 148 148 "#, ··· 153 153 fn sized_constant_value_negative_overflow() { 154 154 assert_js!( 155 155 r#" 156 - fn go() { 156 + pub fn go() { 157 157 <<-80_000:16>> 158 158 } 159 159 "#, ··· 164 164 fn sized_constant_value_max_size_for_compile_time_evaluation() { 165 165 assert_js!( 166 166 r#" 167 - fn go() { 167 + pub fn go() { 168 168 <<-1:48>> 169 169 } 170 170 "#, ··· 175 175 fn sized_big_endian_constant_value() { 176 176 assert_js!( 177 177 r#" 178 - fn go() { 178 + pub fn go() { 179 179 <<256:16-big>> 180 180 } 181 181 "#, ··· 186 186 fn sized_big_endian_dynamic_value() { 187 187 assert_js!( 188 188 r#" 189 - fn go(i: Int) { 189 + pub fn go(i: Int) { 190 190 <<i:16-big>> 191 191 } 192 192 "#, ··· 197 197 fn sized_little_endian_constant_value() { 198 198 assert_js!( 199 199 r#" 200 - fn go() { 200 + pub fn go() { 201 201 <<256:16-little>> 202 202 } 203 203 "#, ··· 208 208 fn sized_little_endian_dynamic_value() { 209 209 assert_js!( 210 210 r#" 211 - fn go(i: Int) { 211 + pub fn go(i: Int) { 212 212 <<i:16-little>> 213 213 } 214 214 "#, ··· 219 219 fn explicit_sized_constant_value() { 220 220 assert_js!( 221 221 r#" 222 - fn go() { 222 + pub fn go() { 223 223 <<256:size(32)>> 224 224 } 225 225 "#, ··· 230 230 fn explicit_sized_dynamic_value() { 231 231 assert_js!( 232 232 r#" 233 - fn go(i: Int) { 233 + pub fn go(i: Int) { 234 234 <<i:size(32)>> 235 235 } 236 236 "#, ··· 241 241 fn variable_sized() { 242 242 assert_js!( 243 243 r#" 244 - fn go(x, y) { 244 + pub fn go(x, y) { 245 245 <<x:size(y)>> 246 246 } 247 247 "#, ··· 252 252 fn variable() { 253 253 assert_js!( 254 254 r#" 255 - fn go(x) { 255 + pub fn go(x) { 256 256 <<256, 4, x>> 257 257 } 258 258 "#, ··· 263 263 fn utf8() { 264 264 assert_js!( 265 265 r#" 266 - fn go(x) { 266 + pub fn go(x) { 267 267 <<256, 4, x, "Gleam":utf8>> 268 268 } 269 269 "#, ··· 274 274 fn match_utf8_with_escape_chars() { 275 275 assert_js!( 276 276 r#" 277 - fn go(x) { 277 + pub fn go(x) { 278 278 let assert <<"\"\\\r\n\t\f\u{1f600}">> = x 279 279 } 280 280 "#, ··· 285 285 fn match_utf8() { 286 286 assert_js!( 287 287 r#" 288 - fn go(x) { 288 + pub fn go(x) { 289 289 let assert <<"Gleam 👍":utf8>> = x 290 290 } 291 291 "#, ··· 296 296 fn match_case_utf8_with_escape_chars() { 297 297 assert_js!( 298 298 r#" 299 - fn go(x) { 299 + pub fn go(x) { 300 300 case x { 301 301 <<"\"\\\r\n\t\f\u{1f600}">> -> 1 302 302 _ -> 2 ··· 310 310 fn match_case_utf8() { 311 311 assert_js!( 312 312 r#" 313 - fn go(x) { 313 + pub fn go(x) { 314 314 case x { 315 315 <<"Gleam 👍":utf8>> -> 1 316 316 _ -> 2 ··· 324 324 fn utf8_codepoint() { 325 325 assert_js!( 326 326 r#" 327 - fn go(x) { 327 + pub fn go(x) { 328 328 <<x:utf8_codepoint, "Gleam":utf8>> 329 329 } 330 330 "#, ··· 346 346 fn bit_string() { 347 347 assert_js!( 348 348 r#" 349 - fn go(x) { 349 + pub fn go(x) { 350 350 <<x:bits>> 351 351 } 352 352 "#, ··· 357 357 fn bits() { 358 358 assert_js!( 359 359 r#" 360 - fn go(x) { 360 + pub fn go(x) { 361 361 <<x:bits>> 362 362 } 363 363 "#, ··· 368 368 fn bit_array_sliced() { 369 369 assert_js!( 370 370 r#" 371 - fn go(x) { 371 + pub fn go(x) { 372 372 <<<<0xAB>>:bits-4>> 373 373 } 374 374 "#, ··· 379 379 fn bit_array_dynamic_slice() { 380 380 assert_js!( 381 381 r#" 382 - fn go(x) { 382 + pub fn go(x) { 383 383 let i = 4 384 384 <<<<0xAB>>:bits-size(i)>> 385 385 } ··· 413 413 fn empty_match() { 414 414 assert_js!( 415 415 r#" 416 - fn go(x) { 416 + pub fn go(x) { 417 417 let assert <<>> = x 418 418 } 419 419 "#, ··· 424 424 fn case_empty_match() { 425 425 assert_js!( 426 426 r#" 427 - fn go(x) { 427 + pub fn go(x) { 428 428 case x { 429 429 <<>> -> 1 430 430 _ -> 2 ··· 438 438 fn match_bytes() { 439 439 assert_js!( 440 440 r#" 441 - fn go(x) { 441 + pub fn go(x) { 442 442 let assert <<1, y>> = x 443 443 } 444 444 "#, ··· 449 449 fn case_match_bytes() { 450 450 assert_js!( 451 451 r#" 452 - fn go(x) { 452 + pub fn go(x) { 453 453 case x { 454 454 <<1, y>> -> y 455 455 _ -> 1 ··· 463 463 fn match_sized() { 464 464 assert_js!( 465 465 r#" 466 - fn go(x) { 466 + pub fn go(x) { 467 467 let assert <<a:16, b:8>> = x 468 468 } 469 469 "#, ··· 474 474 fn case_match_sized() { 475 475 assert_js!( 476 476 r#" 477 - fn go(x) { 477 + pub fn go(x) { 478 478 case x { 479 479 <<a:16, b:8>> -> a + b 480 480 _ -> 1 ··· 488 488 fn match_sized_unaligned() { 489 489 assert_js!( 490 490 r#" 491 - fn go(x) { 491 + pub fn go(x) { 492 492 let assert <<a:17, b:7>> = x 493 493 } 494 494 "#, ··· 499 499 fn case_match_sized_unaligned() { 500 500 assert_js!( 501 501 r#" 502 - fn go(x) { 502 + pub fn go(x) { 503 503 case x { 504 504 <<a:17, b:7>> -> b * 2 505 505 _ -> 1 ··· 513 513 fn match_sized_constant_pattern() { 514 514 assert_js!( 515 515 r#" 516 - fn go(x) { 516 + pub fn go(x) { 517 517 let assert <<1234:16, 123:8>> = x 518 518 } 519 519 "#, ··· 524 524 fn case_match_sized_constant_pattern() { 525 525 assert_js!( 526 526 r#" 527 - fn go(x) { 527 + pub fn go(x) { 528 528 case x { 529 529 <<1234:16, 123:8>> -> 1 530 530 _ -> 2 ··· 538 538 fn match_unsigned() { 539 539 assert_js!( 540 540 r#" 541 - fn go(x) { 541 + pub fn go(x) { 542 542 let assert <<a:unsigned>> = x 543 543 } 544 544 "#, ··· 549 549 fn case_match_unsigned() { 550 550 assert_js!( 551 551 r#" 552 - fn go(x) { 552 + pub fn go(x) { 553 553 case x { 554 554 <<a:unsigned>> -> a 555 555 _ -> 1 ··· 563 563 fn match_unsigned_constant_pattern() { 564 564 assert_js!( 565 565 r#" 566 - fn go(x) { 566 + pub fn go(x) { 567 567 let assert <<-2:unsigned>> = x 568 568 } 569 569 "#, ··· 574 574 fn case_match_unsigned_constant_pattern() { 575 575 assert_js!( 576 576 r#" 577 - fn go(x) { 577 + pub fn go(x) { 578 578 case x { 579 579 <<-2:unsigned>> -> 1 580 580 _ -> 2 ··· 588 588 fn match_signed() { 589 589 assert_js!( 590 590 r#" 591 - fn go(x) { 591 + pub fn go(x) { 592 592 let assert <<a:signed>> = x 593 593 } 594 594 "#, ··· 599 599 fn case_match_signed() { 600 600 assert_js!( 601 601 r#" 602 - fn go(x) { 602 + pub fn go(x) { 603 603 case x { 604 604 <<a:signed>> -> a 605 605 _ -> 1 ··· 613 613 fn match_signed_constant_pattern() { 614 614 assert_js!( 615 615 r#" 616 - fn go(x) { 616 + pub fn go(x) { 617 617 let assert <<-1:signed>> = x 618 618 } 619 619 "#, ··· 624 624 fn case_match_signed_constant_pattern() { 625 625 assert_js!( 626 626 r#" 627 - fn go(x) { 627 + pub fn go(x) { 628 628 case x { 629 629 <<-1:signed>> -> 1 630 630 _ -> 2 ··· 638 638 fn match_sized_big_endian() { 639 639 assert_js!( 640 640 r#" 641 - fn go(x) { 641 + pub fn go(x) { 642 642 let assert <<a:16-big>> = x 643 643 } 644 644 "#, ··· 649 649 fn case_match_sized_big_endian() { 650 650 assert_js!( 651 651 r#" 652 - fn go(x) { 652 + pub fn go(x) { 653 653 case x { 654 654 <<a:16-big>> -> a 655 655 _ -> 1 ··· 663 663 fn match_sized_big_endian_constant_pattern() { 664 664 assert_js!( 665 665 r#" 666 - fn go(x) { 666 + pub fn go(x) { 667 667 let assert <<1234:16-big>> = x 668 668 } 669 669 "#, ··· 674 674 fn case_match_sized_big_endian_constant_pattern() { 675 675 assert_js!( 676 676 r#" 677 - fn go(x) { 677 + pub fn go(x) { 678 678 case x { 679 679 <<1234:16-big>> -> 1 680 680 _ -> 2 ··· 688 688 fn match_sized_little_endian() { 689 689 assert_js!( 690 690 r#" 691 - fn go(x) { 691 + pub fn go(x) { 692 692 let assert <<a:16-little>> = x 693 693 } 694 694 "#, ··· 699 699 fn case_match_sized_little_endian() { 700 700 assert_js!( 701 701 r#" 702 - fn go(x) { 702 + pub fn go(x) { 703 703 case x { 704 704 <<a:16-little>> -> a 705 705 _ -> 1 ··· 713 713 fn match_sized_little_endian_constant_pattern() { 714 714 assert_js!( 715 715 r#" 716 - fn go(x) { 716 + pub fn go(x) { 717 717 let assert <<1234:16-little>> = x 718 718 } 719 719 "#, ··· 724 724 fn case_match_sized_little_endian_constant_pattern() { 725 725 assert_js!( 726 726 r#" 727 - fn go(x) { 727 + pub fn go(x) { 728 728 case x { 729 729 <<1234:16-little>> -> 1 730 730 _ -> 2 ··· 738 738 fn match_sized_big_endian_unsigned() { 739 739 assert_js!( 740 740 r#" 741 - fn go(x) { 741 + pub fn go(x) { 742 742 let assert <<a:16-big-unsigned>> = x 743 743 } 744 744 "#, ··· 749 749 fn case_match_sized_big_endian_unsigned() { 750 750 assert_js!( 751 751 r#" 752 - fn go(x) { 752 + pub fn go(x) { 753 753 case x { 754 754 <<a:16-big-unsigned>> -> a 755 755 _ -> 1 ··· 763 763 fn match_sized_big_endian_unsigned_constant_pattern() { 764 764 assert_js!( 765 765 r#" 766 - fn go(x) { 766 + pub fn go(x) { 767 767 let assert <<1234:16-big-unsigned>> = x 768 768 } 769 769 "#, ··· 774 774 fn case_match_sized_big_endian_unsigned_constant_pattern() { 775 775 assert_js!( 776 776 r#" 777 - fn go(x) { 777 + pub fn go(x) { 778 778 case x { 779 779 <<1234:16-big-unsigned>> -> 1 780 780 _ -> 2 ··· 788 788 fn match_sized_big_endian_signed() { 789 789 assert_js!( 790 790 r#" 791 - fn go(x) { 791 + pub fn go(x) { 792 792 let assert <<a:16-big-signed>> = x 793 793 } 794 794 "#, ··· 799 799 fn case_match_sized_big_endian_signed() { 800 800 assert_js!( 801 801 r#" 802 - fn go(x) { 802 + pub fn go(x) { 803 803 case x { 804 804 <<a:16-big-signed>> -> a 805 805 _ -> 1 ··· 813 813 fn match_sized_big_endian_signed_constant_pattern() { 814 814 assert_js!( 815 815 r#" 816 - fn go(x) { 816 + pub fn go(x) { 817 817 let assert <<1234:16-big-signed>> = x 818 818 } 819 819 "#, ··· 824 824 fn case_match_sized_big_endian_signed_constant_pattern() { 825 825 assert_js!( 826 826 r#" 827 - fn go(x) { 827 + pub fn go(x) { 828 828 case x { 829 829 <<1234:16-big-signed>> -> 1 830 830 _ -> 2 ··· 838 838 fn match_sized_little_endian_unsigned() { 839 839 assert_js!( 840 840 r#" 841 - fn go(x) { 841 + pub fn go(x) { 842 842 let assert <<a:16-little-unsigned>> = x 843 843 } 844 844 "#, ··· 849 849 fn case_match_sized_little_endian_unsigned() { 850 850 assert_js!( 851 851 r#" 852 - fn go(x) { 852 + pub fn go(x) { 853 853 case x { 854 854 <<a:16-little-unsigned>> -> a 855 855 _ -> 1 ··· 863 863 fn match_sized_little_endian_unsigned_constant_pattern() { 864 864 assert_js!( 865 865 r#" 866 - fn go(x) { 866 + pub fn go(x) { 867 867 let assert <<1234:16-little-unsigned>> = x 868 868 } 869 869 "#, ··· 874 874 fn case_match_sized_little_endian_unsigned_constant_pattern() { 875 875 assert_js!( 876 876 r#" 877 - fn go(x) { 877 + pub fn go(x) { 878 878 case x { 879 879 <<1234:16-little-unsigned>> -> 1 880 880 _ -> 2 ··· 888 888 fn match_sized_little_endian_signed() { 889 889 assert_js!( 890 890 r#" 891 - fn go(x) { 891 + pub fn go(x) { 892 892 let assert <<a:16-little-signed>> = x 893 893 } 894 894 "#, ··· 899 899 fn case_match_sized_little_endian_signed() { 900 900 assert_js!( 901 901 r#" 902 - fn go(x) { 902 + pub fn go(x) { 903 903 case x { 904 904 <<a:16-little-signed>> -> a 905 905 _ -> 1 ··· 913 913 fn match_sized_little_endian_signed_constant_pattern() { 914 914 assert_js!( 915 915 r#" 916 - fn go(x) { 916 + pub fn go(x) { 917 917 let assert <<1234:16-little-signed>> = x 918 918 } 919 919 "#, ··· 924 924 fn case_match_sized_little_endian_signed_constant_pattern() { 925 925 assert_js!( 926 926 r#" 927 - fn go(x) { 927 + pub fn go(x) { 928 928 case x { 929 929 <<1234:16-little-signed>> -> 1 930 930 _ -> 2 ··· 938 938 fn match_dynamic_size() { 939 939 assert_js!( 940 940 r#" 941 - fn go(x) { 941 + pub fn go(x) { 942 942 let n = 16 943 943 let assert <<a:size(n)>> = x 944 944 } ··· 950 950 fn case_match_dynamic_size() { 951 951 assert_js!( 952 952 r#" 953 - fn go(x) { 953 + pub fn go(x) { 954 954 let n = 16 955 955 case x { 956 956 <<a:size(n)>> -> a ··· 965 965 fn match_dynamic_size_with_other_segments() { 966 966 assert_js!( 967 967 r#" 968 - fn go(x) { 968 + pub fn go(x) { 969 969 let n = 16 970 970 let m = 32 971 971 let assert <<first:size(8), a:size(n), b:size(m), rest:bits>> = x ··· 978 978 fn case_match_dynamic_size_with_other_segments() { 979 979 assert_js!( 980 980 r#" 981 - fn go(x) { 981 + pub fn go(x) { 982 982 let n = 16 983 983 let m = 32 984 984 case x { ··· 994 994 fn match_dynamic_size_shadowed_variable() { 995 995 assert_js!( 996 996 r#" 997 - fn go(x) { 997 + pub fn go(x) { 998 998 let n = 16 999 999 let n = 5 1000 1000 let assert <<a:size(n)>> = x ··· 1007 1007 fn case_match_dynamic_size_shadowed_variable() { 1008 1008 assert_js!( 1009 1009 r#" 1010 - fn go(x) { 1010 + pub fn go(x) { 1011 1011 let n = 16 1012 1012 let n = 5 1013 1013 case x { ··· 1023 1023 fn match_dynamic_size_literal_value() { 1024 1024 assert_js!( 1025 1025 r#" 1026 - fn go(x) { 1026 + pub fn go(x) { 1027 1027 let n = 8 1028 1028 let assert <<a:size(n), 0b010101:size(8)>> = x 1029 1029 } ··· 1035 1035 fn case_match_dynamic_size_literal_value() { 1036 1036 assert_js!( 1037 1037 r#" 1038 - fn go(x) { 1038 + pub fn go(x) { 1039 1039 let n = 8 1040 1040 case x { 1041 1041 <<a:size(n), 0b010101:size(8)>> -> a ··· 1050 1050 fn match_dynamic_bits_size() { 1051 1051 assert_js!( 1052 1052 r#" 1053 - fn go(x) { 1053 + pub fn go(x) { 1054 1054 let n = 16 1055 1055 let assert <<a:bits-size(n)>> = x 1056 1056 } ··· 1062 1062 fn case_match_dynamic_bits_size() { 1063 1063 assert_js!( 1064 1064 r#" 1065 - fn go(x) { 1065 + pub fn go(x) { 1066 1066 let n = 16 1067 1067 case x { 1068 1068 <<a:bits-size(n)>> -> a ··· 1077 1077 fn match_dynamic_bytes_size() { 1078 1078 assert_js!( 1079 1079 r#" 1080 - fn go(x) { 1080 + pub fn go(x) { 1081 1081 let n = 3 1082 1082 let assert <<a:bytes-size(n)>> = x 1083 1083 } ··· 1089 1089 fn case_match_dynamic_bytes_size() { 1090 1090 assert_js!( 1091 1091 r#" 1092 - fn go(x) { 1092 + pub fn go(x) { 1093 1093 let n = 3 1094 1094 case x { 1095 1095 <<a:bytes-size(n)>> -> a ··· 1104 1104 fn discard_sized() { 1105 1105 assert_js!( 1106 1106 r#" 1107 - fn go(x) { 1107 + pub fn go(x) { 1108 1108 let assert <<_:16, _:8>> = x 1109 1109 let assert <<_:16-little-signed, _:8>> = x 1110 1110 } ··· 1116 1116 fn case_discard_sized() { 1117 1117 assert_js!( 1118 1118 r#" 1119 - fn go(x) { 1119 + pub fn go(x) { 1120 1120 case x { 1121 1121 <<_:16, _:8>> -> 1 1122 1122 _ -> 2 ··· 1134 1134 fn match_sized_value() { 1135 1135 assert_js!( 1136 1136 r#" 1137 - fn go(x) { 1137 + pub fn go(x) { 1138 1138 let assert <<i:16>> = x 1139 1139 } 1140 1140 "#, ··· 1145 1145 fn case_match_sized_value() { 1146 1146 assert_js!( 1147 1147 r#" 1148 - fn go(x) { 1148 + pub fn go(x) { 1149 1149 case x { 1150 1150 <<i:16>> -> i 1151 1151 _ -> 1 ··· 1159 1159 fn match_sized_value_constant_pattern() { 1160 1160 assert_js!( 1161 1161 r#" 1162 - fn go(x) { 1162 + pub fn go(x) { 1163 1163 let assert <<258:16>> = x 1164 1164 } 1165 1165 "#, ··· 1170 1170 fn case_match_sized_value_constant_pattern() { 1171 1171 assert_js!( 1172 1172 r#" 1173 - fn go(x) { 1173 + pub fn go(x) { 1174 1174 case x { 1175 1175 <<258:16>> -> 1 1176 1176 _ -> 2 ··· 1184 1184 fn match_float() { 1185 1185 assert_js!( 1186 1186 r#" 1187 - fn go(x) { 1187 + pub fn go(x) { 1188 1188 let assert <<a:float, b:int>> = x 1189 1189 } 1190 1190 "#, ··· 1195 1195 fn case_match_float() { 1196 1196 assert_js!( 1197 1197 r#" 1198 - fn go(x) { 1198 + pub fn go(x) { 1199 1199 case x { 1200 1200 <<a:float, b:int>> -> #(a, b) 1201 1201 _ -> #(1.1, 2) ··· 1209 1209 fn match_float_big_endian() { 1210 1210 assert_js!( 1211 1211 r#" 1212 - fn go(x) { 1212 + pub fn go(x) { 1213 1213 let assert <<a:float-big, b:int>> = x 1214 1214 } 1215 1215 "#, ··· 1220 1220 fn case_match_float_big_endian() { 1221 1221 assert_js!( 1222 1222 r#" 1223 - fn go(x) { 1223 + pub fn go(x) { 1224 1224 case x { 1225 1225 <<a:float-big, b:int>> -> #(a, b) 1226 1226 _ -> #(1.1, 1) ··· 1234 1234 fn match_float_little_endian() { 1235 1235 assert_js!( 1236 1236 r#" 1237 - fn go(x) { 1237 + pub fn go(x) { 1238 1238 let assert <<a:float-little, b:int>> = x 1239 1239 } 1240 1240 "#, ··· 1245 1245 fn case_match_float_little_endian() { 1246 1246 assert_js!( 1247 1247 r#" 1248 - fn go(x) { 1248 + pub fn go(x) { 1249 1249 case x { 1250 1250 <<a:float-little, b:int>> -> #(a, b) 1251 1251 _ -> #(1.1, 2) ··· 1259 1259 fn match_float_sized() { 1260 1260 assert_js!( 1261 1261 r#" 1262 - fn go(x) { 1262 + pub fn go(x) { 1263 1263 let assert <<a:float-32, b:int>> = x 1264 1264 } 1265 1265 "#, ··· 1270 1270 fn case_match_float_sized() { 1271 1271 assert_js!( 1272 1272 r#" 1273 - fn go(x) { 1273 + pub fn go(x) { 1274 1274 case x { 1275 1275 <<a:float-32, b:int>> -> #(a, b) 1276 1276 _ -> #(1.1, 2) ··· 1284 1284 fn match_float_sized_big_endian() { 1285 1285 assert_js!( 1286 1286 r#" 1287 - fn go(x) { 1287 + pub fn go(x) { 1288 1288 let assert <<a:float-32-big, b:int>> = x 1289 1289 } 1290 1290 "#, ··· 1295 1295 fn case_match_float_sized_big_endian() { 1296 1296 assert_js!( 1297 1297 r#" 1298 - fn go(x) { 1298 + pub fn go(x) { 1299 1299 case x { 1300 1300 <<a:float-32-big, b:int>> -> #(a, b) 1301 1301 _ -> #(1.1, 2) ··· 1309 1309 fn match_float_sized_little_endian() { 1310 1310 assert_js!( 1311 1311 r#" 1312 - fn go(x) { 1312 + pub fn go(x) { 1313 1313 let assert <<a:float-32-little, b:int>> = x 1314 1314 } 1315 1315 "#, ··· 1320 1320 fn case_match_float_sized_little_endian() { 1321 1321 assert_js!( 1322 1322 r#" 1323 - fn go(x) { 1323 + pub fn go(x) { 1324 1324 case x { 1325 1325 <<a:float-32-little, b:int>> -> #(a, b) 1326 1326 _ -> #(1.1, 2) ··· 1334 1334 fn match_literal_float() { 1335 1335 assert_js!( 1336 1336 r#" 1337 - fn go(x) { 1337 + pub fn go(x) { 1338 1338 let assert <<1.4, b:int>> = x 1339 1339 } 1340 1340 "#, ··· 1345 1345 fn case_match_literal_float() { 1346 1346 assert_js!( 1347 1347 r#" 1348 - fn go(x) { 1348 + pub fn go(x) { 1349 1349 case x { 1350 1350 <<1.4, b:int>> -> 1 1351 1351 _ -> 2 ··· 1359 1359 fn match_literal_unaligned_float() { 1360 1360 assert_js!( 1361 1361 r#" 1362 - fn go(x) { 1362 + pub fn go(x) { 1363 1363 let n = 1 1364 1364 let assert <<_:size(n), 1.1, _:bits>> = x 1365 1365 } ··· 1371 1371 fn case_match_literal_unaligned_float() { 1372 1372 assert_js!( 1373 1373 r#" 1374 - fn go(x) { 1374 + pub fn go(x) { 1375 1375 let n = 1 1376 1376 case x { 1377 1377 <<_:size(n), 1.1, _:int>> -> 1 ··· 1386 1386 fn match_literal_aligned_float() { 1387 1387 assert_js!( 1388 1388 r#" 1389 - fn go(x) { 1389 + pub fn go(x) { 1390 1390 let assert <<_, 1.1, _:bits>> = x 1391 1391 } 1392 1392 "#, ··· 1397 1397 fn case_match_literal_aligned_float() { 1398 1398 assert_js!( 1399 1399 r#" 1400 - fn go(x) { 1400 + pub fn go(x) { 1401 1401 case x { 1402 1402 <<_, 1.1, _:int>> -> 1 1403 1403 _ -> 2 ··· 1411 1411 fn match_float_16_bit() { 1412 1412 assert_js!( 1413 1413 r#" 1414 - fn go(x) { 1414 + pub fn go(x) { 1415 1415 let assert <<a:float-size(16)>> = x 1416 1416 } 1417 1417 "# ··· 1422 1422 fn case_match_float_16_bit() { 1423 1423 assert_js!( 1424 1424 r#" 1425 - fn go(x) { 1425 + pub fn go(x) { 1426 1426 case x { 1427 1427 <<a:float-size(16)>> -> a 1428 1428 _ -> 1.1 ··· 1436 1436 fn match_rest() { 1437 1437 assert_js!( 1438 1438 r#" 1439 - fn go(x) { 1439 + pub fn go(x) { 1440 1440 let assert <<_, b:bytes>> = <<1,2,3>> 1441 1441 } 1442 1442 "#, ··· 1447 1447 fn case_match_rest() { 1448 1448 assert_js!( 1449 1449 r#" 1450 - fn go(x) { 1450 + pub fn go(x) { 1451 1451 case <<1, 2, 3>> { 1452 1452 <<_, b:bytes>> -> b 1453 1453 _ -> x ··· 1461 1461 fn match_bytes_with_size() { 1462 1462 assert_js!( 1463 1463 r#" 1464 - fn go(x) { 1464 + pub fn go(x) { 1465 1465 let assert <<f:bytes-2>> = <<1, 2>> 1466 1466 } 1467 1467 "#, ··· 1472 1472 fn case_match_bytes_with_size() { 1473 1473 assert_js!( 1474 1474 r#" 1475 - fn go(x) { 1475 + pub fn go(x) { 1476 1476 case <<1, 2>> { 1477 1477 <<f:bytes-2>> -> f 1478 1478 _ -> x ··· 1486 1486 fn match_bits_with_size() { 1487 1487 assert_js!( 1488 1488 r#" 1489 - fn go(x) { 1489 + pub fn go(x) { 1490 1490 let assert <<_:4, f:bits-2, _:1>> = <<0x77:7>> 1491 1491 } 1492 1492 "#, ··· 1497 1497 fn case_match_bits_with_size() { 1498 1498 assert_js!( 1499 1499 r#" 1500 - fn go(x) { 1500 + pub fn go(x) { 1501 1501 case <<0x77:7>> { 1502 1502 <<_:4, f:bits-2, _:1>> -> f 1503 1503 _ -> x ··· 1511 1511 fn match_rest_bytes() { 1512 1512 assert_js!( 1513 1513 r#" 1514 - fn go(x) { 1514 + pub fn go(x) { 1515 1515 let assert <<_, b:bytes>> = <<1,2,3>> 1516 1516 } 1517 1517 "#, ··· 1522 1522 fn case_match_rest_bytes() { 1523 1523 assert_js!( 1524 1524 r#" 1525 - fn go(x) { 1525 + pub fn go(x) { 1526 1526 case x { 1527 1527 <<_, b:bytes>> -> b 1528 1528 _ -> x ··· 1536 1536 fn match_rest_bits() { 1537 1537 assert_js!( 1538 1538 r#" 1539 - fn go(x) { 1539 + pub fn go(x) { 1540 1540 let assert <<_, b:bits>> = <<1,2,3>> 1541 1541 } 1542 1542 "#, ··· 1547 1547 fn case_match_rest_bits() { 1548 1548 assert_js!( 1549 1549 r#" 1550 - fn go(x) { 1550 + pub fn go(x) { 1551 1551 case x { 1552 1552 <<_, b:bits>> -> b 1553 1553 _ -> x ··· 1561 1561 fn match_rest_bits_unaligned() { 1562 1562 assert_js!( 1563 1563 r#" 1564 - fn go(x) { 1564 + pub fn go(x) { 1565 1565 let assert <<_:5, b:bits>> = <<1,2,3>> 1566 1566 } 1567 1567 "#, ··· 1572 1572 fn case_match_rest_bits_unaligned() { 1573 1573 assert_js!( 1574 1574 r#" 1575 - fn go(x) { 1575 + pub fn go(x) { 1576 1576 case x { 1577 1577 <<_:5, b:bits>> -> b 1578 1578 _ -> x ··· 1586 1586 fn match_binary_size() { 1587 1587 assert_js!( 1588 1588 r#" 1589 - fn go(x) { 1589 + pub fn go(x) { 1590 1590 let assert <<_, a:2-bytes>> = x 1591 1591 let assert <<_, b:bytes-size(2)>> = x 1592 1592 } ··· 1598 1598 fn case_match_binary_size() { 1599 1599 assert_js!( 1600 1600 r#" 1601 - fn go(x) { 1601 + pub fn go(x) { 1602 1602 case x { 1603 1603 <<_, a:2-bytes>> -> a 1604 1604 _ -> x ··· 1739 1739 1740 1740 #[test] 1741 1741 fn bit_array_literal_string_constant_is_treated_as_utf8() { 1742 - assert_js!(r#"const a = <<"hello", " ", "world">>"#); 1742 + assert_js!(r#"pub const a = <<"hello", " ", "world">>"#); 1743 1743 } 1744 1744 1745 1745 #[test] ··· 1769 1769 fn with_unit() { 1770 1770 assert_js!( 1771 1771 r#" 1772 - fn main() { 1772 + pub fn main() { 1773 1773 <<1:size(2)-unit(2), 2:size(3)-unit(4)>> 1774 1774 } 1775 1775 "#, ··· 1780 1780 fn dynamic_size_with_unit() { 1781 1781 assert_js!( 1782 1782 r#" 1783 - fn main() { 1783 + pub fn main() { 1784 1784 let size = 3 1785 1785 <<1:size(size)-unit(2)>> 1786 1786 } ··· 1792 1792 fn pattern_with_unit() { 1793 1793 assert_js!( 1794 1794 r#" 1795 - fn go(x) { 1795 + pub fn go(x) { 1796 1796 let assert <<1:size(2)-unit(2), 2:size(3)-unit(4)>> = x 1797 1797 } 1798 1798 "#, ··· 1803 1803 fn case_pattern_with_unit() { 1804 1804 assert_js!( 1805 1805 r#" 1806 - fn go(x) { 1806 + pub fn go(x) { 1807 1807 case x { 1808 1808 <<1:size(2)-unit(2), 2:size(3)-unit(4)>> -> 1 1809 1809 _ -> 2 ··· 1817 1817 fn dynamic_size_pattern_with_unit() { 1818 1818 assert_js!( 1819 1819 r#" 1820 - fn go(x) { 1820 + pub fn go(x) { 1821 1821 let size = 3 1822 1822 let assert <<1:size(size)-unit(2)>> = x 1823 1823 } ··· 1829 1829 fn case_dynamic_size_pattern_with_unit() { 1830 1830 assert_js!( 1831 1831 r#" 1832 - fn go(x) { 1832 + pub fn go(x) { 1833 1833 let size = 3 1834 1834 case x { 1835 1835 <<1:size(size)-unit(2)>> -> 1 ··· 1844 1844 fn case_dynamic_size_float_pattern_with_unit() { 1845 1845 assert_js!( 1846 1846 r#" 1847 - fn go(x) { 1847 + pub fn go(x) { 1848 1848 let size = 3 1849 1849 case x { 1850 1850 <<1.3:size(size)-unit(2)>> -> 1 ··· 1859 1859 fn case_with_remaining_bytes_after_constant_size() { 1860 1860 assert_js!( 1861 1861 r#" 1862 - fn go(x) { 1862 + pub fn go(x) { 1863 1863 case x { 1864 1864 <<_, _, _:bytes>> -> 1 1865 1865 _ -> 2 ··· 1873 1873 fn case_with_remaining_bytes_after_variable_size() { 1874 1874 assert_js!( 1875 1875 r#" 1876 - fn go(x) { 1876 + pub fn go(x) { 1877 1877 let n = 1 1878 1878 case x { 1879 1879 <<_:size(n), _, _:bytes>> -> 1 ··· 1888 1888 fn case_with_remaining_bytes_after_variable_size_2() { 1889 1889 assert_js!( 1890 1890 r#" 1891 - fn go(x) { 1891 + pub fn go(x) { 1892 1892 let n = 1 1893 1893 case x { 1894 1894 <<m:size(n), _:size(m), _:bytes>> -> 1 ··· 1903 1903 fn case_is_byte_aligned() { 1904 1904 assert_js!( 1905 1905 r#" 1906 - fn is_byte_aligned(x) { 1906 + pub fn is_byte_aligned(x) { 1907 1907 case x { 1908 1908 <<_:bytes>> -> True 1909 1909 _ -> False ··· 1917 1917 fn alternative_patterns_with_variable_size() { 1918 1918 assert_js!( 1919 1919 r#" 1920 - fn go(x) { 1920 + pub fn go(x) { 1921 1921 case x { 1922 1922 <<_, n, rest:size(n)>> | 1923 1923 <<n, _, rest:size(n)>> -> True ··· 1932 1932 fn variable_sized_segment() { 1933 1933 assert_js!( 1934 1934 r#" 1935 - fn go(x) { 1935 + pub fn go(x) { 1936 1936 case x { 1937 1937 <<n, rest:size(n)>> -> 1 1938 1938 _ -> 2 ··· 1946 1946 fn segments_shadowing_each_other() { 1947 1947 assert_js!( 1948 1948 r#" 1949 - fn go(x) { 1949 + pub fn go(x) { 1950 1950 let n = 1 1951 1951 case x { 1952 1952 <<n, rest:size(n)>> -> 1 ··· 1961 1961 fn negative_size_pattern() { 1962 1962 assert_js!( 1963 1963 r#" 1964 - fn go(x) { 1964 + pub fn go(x) { 1965 1965 let n = -10 1966 1966 case x { 1967 1967 <<int:size(n)>> -> int ··· 1976 1976 fn negative_size_pattern_2() { 1977 1977 assert_js!( 1978 1978 r#" 1979 - fn go(x) { 1979 + pub fn go(x) { 1980 1980 case x { 1981 1981 <<n:signed, int:size(n)>> -> int 1982 1982 _ -> 2
+17 -17
compiler-core/src/javascript/tests/blocks.rs
··· 4 4 fn block() { 5 5 assert_js!( 6 6 r#" 7 - fn go() { 7 + pub fn go() { 8 8 let x = { 9 9 1 10 10 2 ··· 19 19 fn nested_simple_blocks() { 20 20 assert_js!( 21 21 r#" 22 - fn go() { 22 + pub fn go() { 23 23 let x = { 24 24 { 25 25 3 ··· 35 35 fn nested_multiexpr_blocks() { 36 36 assert_js!( 37 37 r#" 38 - fn go() { 38 + pub fn go() { 39 39 let x = { 40 40 1 41 41 { ··· 53 53 fn nested_multiexpr_blocks_with_pipe() { 54 54 assert_js!( 55 55 r#" 56 - fn add1(a) { 56 + pub fn add1(a) { 57 57 a + 1 58 58 } 59 - fn go() { 59 + pub fn go() { 60 60 let x = { 61 61 1 62 62 { ··· 74 74 fn nested_multiexpr_non_ending_blocks() { 75 75 assert_js!( 76 76 r#" 77 - fn go() { 77 + pub fn go() { 78 78 let x = { 79 79 1 80 80 { ··· 93 93 fn nested_multiexpr_blocks_with_case() { 94 94 assert_js!( 95 95 r#" 96 - fn go() { 96 + pub fn go() { 97 97 let x = { 98 98 1 99 99 { ··· 113 113 fn sequences() { 114 114 assert_js!( 115 115 r#" 116 - fn go() { 116 + pub fn go() { 117 117 "one" 118 118 "two" 119 119 "three" ··· 126 126 fn left_operator_sequence() { 127 127 assert_js!( 128 128 r#" 129 - fn go() { 129 + pub fn go() { 130 130 1 == { 131 131 1 132 132 2 ··· 140 140 fn right_operator_sequence() { 141 141 assert_js!( 142 142 r#" 143 - fn go() { 143 + pub fn go() { 144 144 { 145 145 1 146 146 2 ··· 154 154 fn concat_blocks() { 155 155 assert_js!( 156 156 r#" 157 - fn main(f, a, b) { 157 + pub fn main(f, a, b) { 158 158 { 159 159 a 160 160 |> f ··· 171 171 fn blocks_returning_functions() { 172 172 assert_js!( 173 173 r#" 174 - fn b() { 174 + pub fn b() { 175 175 { 176 176 fn(cb) { cb(1) } 177 177 } ··· 188 188 fn blocks_returning_use() { 189 189 assert_js!( 190 190 r#" 191 - fn b() { 191 + pub fn b() { 192 192 { 193 193 use a <- fn(cb) { cb(1) } 194 194 a ··· 207 207 fn block_with_parenthesised_expression_returning_from_function() { 208 208 assert_js!( 209 209 r#" 210 - fn b() { 210 + pub fn b() { 211 211 { 212 212 1 + 2 213 213 } ··· 220 220 fn block_in_tail_position_is_not_an_iife() { 221 221 assert_js!( 222 222 r#" 223 - fn b() { 223 + pub fn b() { 224 224 let x = 1 225 225 { 226 226 Nil ··· 235 235 fn block_in_tail_position_shadowing_variables() { 236 236 assert_js!( 237 237 r#" 238 - fn b() { 238 + pub fn b() { 239 239 let x = 1 240 240 { 241 241 let x = 2 ··· 250 250 fn block_in_tail_position_with_just_an_assignment() { 251 251 assert_js!( 252 252 r#" 253 - fn b() { 253 + pub fn b() { 254 254 let x = 1 255 255 { 256 256 let x = x
+10 -10
compiler-core/src/javascript/tests/bools.rs
··· 4 4 fn expressions() { 5 5 assert_js!( 6 6 r#" 7 - fn go() { 7 + pub fn go() { 8 8 True 9 9 False 10 10 Nil ··· 17 17 fn constants() { 18 18 assert_js!( 19 19 r#" 20 - const a = True 21 - const b = False 22 - const c = Nil 20 + pub const a = True 21 + pub const b = False 22 + pub const c = Nil 23 23 "#, 24 24 ); 25 25 } ··· 39 39 fn operators() { 40 40 assert_js!( 41 41 r#" 42 - fn go() { 42 + pub fn go() { 43 43 True && True 44 44 False || False 45 45 } ··· 51 51 fn assigning() { 52 52 assert_js!( 53 53 r#" 54 - fn go(x, y) { 54 + pub fn go(x, y) { 55 55 let assert True = x 56 56 let assert False = x 57 57 let assert Nil = y ··· 67 67 assert_js!( 68 68 r#" 69 69 pub type True { True False Nil } 70 - fn go(x, y) { 70 + pub fn go(x, y) { 71 71 let assert True = x 72 72 let assert False = x 73 73 let assert Nil = y ··· 94 94 fn equality() { 95 95 assert_js!( 96 96 r#" 97 - fn go(a, b) { 97 + pub fn go(a, b) { 98 98 a == True 99 99 a != True 100 100 a == False ··· 113 113 fn case() { 114 114 assert_js!( 115 115 r#" 116 - fn go(a) { 116 + pub fn go(a) { 117 117 case a { 118 118 True -> 1 119 119 False -> 0 ··· 127 127 fn nil_case() { 128 128 assert_js!( 129 129 r#" 130 - fn go(a) { 130 + pub fn go(a) { 131 131 case a { 132 132 Nil -> 0 133 133 }
+19 -19
compiler-core/src/javascript/tests/case.rs
··· 19 19 fn tuple_and_guard() { 20 20 assert_js!( 21 21 r#" 22 - fn go(x) { 22 + pub fn go(x) { 23 23 case #(1, 2) { 24 24 #(1, a) if a == 2 -> 1 25 25 #(_, _) -> 2 ··· 33 33 fn guard_variable_only_brought_into_scope_when_needed() { 34 34 assert_js!( 35 35 r#" 36 - fn go(x) { 36 + pub fn go(x) { 37 37 case x { 38 38 // We want `a` to be defined before the guard check, and 39 39 // `b` to be defined only if the predicate on a matches! ··· 66 66 fn pointless() { 67 67 assert_js!( 68 68 r#" 69 - fn go(x) { 69 + pub fn go(x) { 70 70 case x { 71 71 _ -> x 72 72 } ··· 80 80 fn following_todo() { 81 81 assert_js!( 82 82 r#" 83 - fn go(x) { 83 + pub fn go(x) { 84 84 case x { 85 85 True -> todo 86 86 _ -> 1 ··· 94 94 fn multi_subject_catch_all() { 95 95 assert_js!( 96 96 r#" 97 - fn go(x, y) { 97 + pub fn go(x, y) { 98 98 case x, y { 99 99 True, True -> 1 100 100 _, _ -> 0 ··· 108 108 fn multi_subject_or() { 109 109 assert_js!( 110 110 r#" 111 - fn go(x, y) { 111 + pub fn go(x, y) { 112 112 case x, y { 113 113 True, _ | _, True -> 1 114 114 _, _ -> 0 ··· 122 122 fn multi_subject_no_catch_all() { 123 123 assert_js!( 124 124 r#" 125 - fn go(x, y) { 125 + pub fn go(x, y) { 126 126 case x, y { 127 127 True, _ -> 1 128 128 _, True -> 2 ··· 137 137 fn multi_subject_subject_assignments() { 138 138 assert_js!( 139 139 r#" 140 - fn go() { 140 + pub fn go() { 141 141 case True, False { 142 142 True, True -> 1 143 143 _, _ -> 0 ··· 151 151 fn assignment() { 152 152 assert_js!( 153 153 r#" 154 - fn go(x) { 154 + pub fn go(x) { 155 155 let y = case x { 156 156 True -> 1 157 157 _ -> 0 ··· 166 166 fn preassign_assignment() { 167 167 assert_js!( 168 168 r#" 169 - fn go(x) { 169 + pub fn go(x) { 170 170 let y = case x() { 171 171 True -> 1 172 172 _ -> 0 ··· 182 182 fn pipe() { 183 183 assert_js!( 184 184 r#" 185 - fn go(x, f) { 185 + pub fn go(x, f) { 186 186 case x |> f { 187 187 0 -> 1 188 188 _ -> 2 ··· 196 196 fn result() { 197 197 assert_js!( 198 198 r#" 199 - fn go(x) { 199 + pub fn go(x) { 200 200 case x { 201 201 Ok(_) -> 1 202 202 Error(_) -> 0 ··· 211 211 fn called_case() { 212 212 assert_js!( 213 213 r#" 214 - fn go(x, y) { 214 + pub fn go(x, y) { 215 215 case x { 216 216 0 -> y 217 217 _ -> y ··· 226 226 fn case_local_var_in_tuple() { 227 227 assert_js!( 228 228 r#" 229 - fn go(x, y) { 229 + pub fn go(x, y) { 230 230 let z = False 231 231 case True { 232 232 x if #(x, z) == #(True, False) -> x ··· 242 242 fn case_branches_guards_are_wrapped_in_parentheses() { 243 243 assert_js!( 244 244 r#" 245 - fn anything() -> a { 245 + pub fn anything() -> a { 246 246 case [] { 247 247 [a] if False || True -> a 248 248 _ -> anything() ··· 257 257 fn nested_string_prefix_match() { 258 258 assert_js!( 259 259 r#" 260 - fn main() { 260 + pub fn main() { 261 261 case Ok(["a", "b c", "d"]) { 262 262 Ok(["a", "b " <> _, "d"]) -> 1 263 263 _ -> 1 ··· 272 272 fn nested_string_prefix_match_that_would_crash_on_js() { 273 273 assert_js!( 274 274 r#" 275 - fn main() { 275 + pub fn main() { 276 276 case Ok(["b c", "d"]) { 277 277 Ok(["b " <> _, "d"]) -> 1 278 278 _ -> 1 ··· 379 379 fn record_update_in_pipeline_in_case_clause() { 380 380 assert_js!( 381 381 " 382 - type Wibble { 382 + pub type Wibble { 383 383 Wibble(wibble: Int, wobble: Int) 384 384 } 385 385 ··· 387 387 x 388 388 } 389 389 390 - fn go(x) { 390 + pub fn go(x) { 391 391 case x { 392 392 Wibble(1, _) -> Wibble(..x, wibble: 4) |> identity 393 393 Wibble(_, 3) -> Wibble(..x, wobble: 10) |> identity
+4 -4
compiler-core/src/javascript/tests/case_clause_guards.rs
··· 474 474 assert_js!( 475 475 ("package", "other_module", "pub type T { A }"), 476 476 r#"import other_module.{A as B} 477 - fn func() { 477 + pub fn func() { 478 478 case B { 479 479 x if x == B -> True 480 480 _ -> False ··· 491 491 pub type X { 492 492 Ok 493 493 } 494 - fn func() { 494 + pub fn func() { 495 495 case Y { 496 496 y if y == Y -> True 497 497 _ -> False ··· 508 508 pub type X { 509 509 Ok 510 510 } 511 - fn func(x) { 511 + pub fn func(x) { 512 512 case gleam.Ok { 513 513 _ if [] == [ gleam.Ok ] -> True 514 514 _ -> False ··· 522 522 #[test] 523 523 fn constructor_function_in_guard() { 524 524 assert_js!( 525 - r#"fn func(x) { 525 + r#"pub fn func(x) { 526 526 case [] { 527 527 _ if [] == [ Ok ] -> True 528 528 _ -> False
+3 -3
compiler-core/src/javascript/tests/consts.rs
··· 48 48 } 49 49 50 50 pub const x = X(1, ["1"]) 51 - const y = X(1, []) 51 + pub const y = X(1, []) 52 52 "# 53 53 ); 54 54 } ··· 62 62 } 63 63 64 64 pub const x = [X(1, ["1"])] 65 - const y = [X(1, ["1"])] 65 + pub const y = [X(1, ["1"])] 66 66 "# 67 67 ); 68 68 } ··· 76 76 } 77 77 78 78 pub const x = #(X(1, ["1"])) 79 - const y = #(X(1, ["1"])) 79 + pub const y = #(X(1, ["1"])) 80 80 "# 81 81 ); 82 82 }
+30 -46
compiler-core/src/javascript/tests/custom_types.rs
··· 5 5 fn zero_arity_literal() { 6 6 assert_js!( 7 7 r#" 8 - type Mine { 8 + pub type Mine { 9 9 This 10 10 ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant 11 11 } 12 12 13 - fn go() { 13 + pub fn go() { 14 14 This 15 15 ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant 16 16 } ··· 22 22 fn zero_arity_const() { 23 23 assert_js!( 24 24 r#" 25 - type Mine { 25 + pub type Mine { 26 26 This 27 27 ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant 28 28 } 29 29 30 - const this = This 31 - const that = ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant 30 + pub const this = This 31 + pub const that = ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant 32 32 "#, 33 33 ); 34 34 } ··· 104 104 assert_js!( 105 105 ("other", r#"pub type One { Two }"#), 106 106 r#"import other 107 - const x = other.Two 107 + pub const x = other.Two 108 108 "#, 109 109 ); 110 110 } ··· 114 114 assert_js!( 115 115 ("other", r#"pub type One { Two }"#), 116 116 r#"import other.{Two} 117 - const a = Two 117 + pub const a = Two 118 118 "#, 119 119 ); 120 120 } 121 121 122 - // TODO 123 - // #[test] 124 - // fn const_zero_arity_imported_unqualified_aliased() { 125 - // assert_js!( 126 - // ( CURRENT_PACKAGE, "other", r#"pub type One { Two }"#), 127 - // r#"import other.{Two as Three} 128 - // const a = Three 129 - // "#, 130 - // r#"// const a = { type: "Two" }; 131 - 132 - // import * as Other from "../other.js"; 133 - // const { Two as Three } = other; 134 - // "# 135 - // ); 136 - // } 137 - 138 122 #[test] 139 123 fn const_with_fields() { 140 124 assert_js!( 141 125 r#" 142 - type Mine { 126 + pub type Mine { 143 127 Mine(a: Int, b: Int) 144 128 } 145 129 146 - const labels = Mine(b: 2, a: 1) 147 - const no_labels = Mine(3, 4) 130 + pub const labels = Mine(b: 2, a: 1) 131 + pub const no_labels = Mine(3, 4) 148 132 "#, 149 133 ); 150 134 } ··· 167 151 fn unnamed_fields() { 168 152 assert_js!( 169 153 r#" 170 - type Ip{ 154 + pub type Ip { 171 155 Ip(String) 172 156 } 173 157 174 - const local = Ip("0.0.0.0") 158 + pub const local = Ip("0.0.0.0") 175 159 176 - fn build(x) { 160 + pub fn build(x) { 177 161 x("1.2.3.4") 178 162 } 179 163 180 - fn go() { 164 + pub fn go() { 181 165 build(Ip) 182 166 Ip("5.6.7.8") 183 167 } 184 168 185 - fn destructure(x) { 169 + pub fn destructure(x) { 186 170 let Ip(raw) = x 187 171 raw 188 172 } ··· 208 192 fn long_name_variant_without_labels() { 209 193 assert_js!( 210 194 r#" 211 - type TypeWithALongNameAndSeveralArguments{ 195 + pub type TypeWithALongNameAndSeveralArguments{ 212 196 TypeWithALongNameAndSeveralArguments(String, String, String, String, String) 213 197 } 214 198 215 199 216 - fn go() { 200 + pub fn go() { 217 201 TypeWithALongNameAndSeveralArguments 218 202 } 219 203 "#, ··· 237 221 fn custom_type_with_named_fields() { 238 222 assert_js!( 239 223 r#" 240 - type Cat { 224 + pub type Cat { 241 225 Cat(name: String, cuteness: Int) 242 226 } 243 227 244 - type Box { 228 + pub type Box { 245 229 Box(occupant: Cat) 246 230 } 247 231 248 - const felix = Cat("Felix", 12) 249 - const tom = Cat(cuteness: 1, name: "Tom") 232 + pub const felix = Cat("Felix", 12) 233 + pub const tom = Cat(cuteness: 1, name: "Tom") 250 234 251 - fn go() { 235 + pub fn go() { 252 236 Cat("Nubi", 1) 253 237 Cat(2, name: "Nubi") 254 238 Cat(cuteness: 3, name: "Nubi") 255 239 } 256 240 257 - fn update(cat) { 241 + pub fn update(cat) { 258 242 Cat(..cat, name: "Sid") 259 243 Cat(..cat, name: "Bartholemew Wonder Puss the Fourth !!!!!!!!!!!!!!!!") 260 244 Cat(..new_cat(), name: "Molly") ··· 262 246 Cat(..box.occupant, cuteness: box.occupant.cuteness + 1) 263 247 } 264 248 265 - fn access(cat: Cat) { 249 + pub fn access(cat: Cat) { 266 250 cat.cuteness 267 251 } 268 252 269 - fn new_cat() { 253 + pub fn new_cat() { 270 254 Cat(name: "Beau", cuteness: 11) 271 255 } 272 256 "#, ··· 277 261 fn destructure_custom_type_with_named_fields() { 278 262 assert_js!( 279 263 r#" 280 - type Cat { 264 + pub type Cat { 281 265 Cat(name: String, cuteness: Int) 282 266 } 283 267 284 - fn go(cat) { 268 + pub fn go(cat) { 285 269 let Cat(x, y) = cat 286 270 let Cat(name: x, ..) = cat 287 271 let assert Cat(cuteness: 4, name: x) = cat ··· 296 280 fn destructure_custom_type_with_mixed_fields_first_unlabelled() { 297 281 assert_js!( 298 282 r#" 299 - type Cat { 283 + pub type Cat { 300 284 Cat(String, cuteness: Int) 301 285 } 302 286 303 - fn go(cat) { 287 + pub fn go(cat) { 304 288 let Cat(x, y) = cat 305 289 let Cat(cuteness: y, ..) = cat 306 290 let Cat(x, cuteness: y) = cat ··· 315 299 fn nested_pattern_with_labels() { 316 300 assert_js!( 317 301 r#"pub type Box(x) { Box(a: Int, b: x) } 318 - fn go(x) { 302 + pub fn go(x) { 319 303 case x { 320 304 Box(a: _, b: Box(a: a, b: b)) -> a + b 321 305 _ -> 1
+13 -13
compiler-core/src/javascript/tests/lists.rs
··· 4 4 fn list_literals() { 5 5 assert_js!( 6 6 r#" 7 - fn go(x) { 8 - [] 9 - [1] 10 - [1, 2] 11 - [1, 2, ..x] 7 + pub fn go(x) { 8 + [] 9 + [1] 10 + [1, 2] 11 + [1, 2, ..x] 12 12 } 13 13 "#, 14 14 ); ··· 18 18 fn long_list_literals() { 19 19 assert_js!( 20 20 r#" 21 - fn go() { 21 + pub fn go() { 22 22 [111111111111111111111111111111111111111111111111111111111111111111111111] 23 23 [11111111111111111111111111111111111111111111, 1111111111111111111111111111111111111111111] 24 24 } ··· 30 30 fn multi_line_list_literals() { 31 31 assert_js!( 32 32 r#" 33 - fn go(x) { 33 + pub fn go(x) { 34 34 [{True 1}] 35 35 } 36 36 "#, ··· 41 41 fn list_constants() { 42 42 assert_js!( 43 43 r#" 44 - const a = [] 45 - const b = [1, 2, 3] 44 + pub const a = [] 45 + pub const b = [1, 2, 3] 46 46 "#, 47 47 ); 48 48 } ··· 61 61 fn list_destructuring() { 62 62 assert_js!( 63 63 r#" 64 - fn go(x, y) { 64 + pub fn go(x, y) { 65 65 let assert [] = x 66 66 let assert [a] = x 67 67 let assert [1, 2] = x ··· 76 76 fn equality() { 77 77 assert_js!( 78 78 r#" 79 - fn go() { 79 + pub fn go() { 80 80 [] == [1] 81 81 [] != [1] 82 82 } ··· 88 88 fn case() { 89 89 assert_js!( 90 90 r#" 91 - fn go(xs) { 91 + pub fn go(xs) { 92 92 case xs { 93 93 [] -> 0 94 94 [_] -> 1 ··· 105 105 fn tight_empty_list() { 106 106 assert_js!( 107 107 r#" 108 - fn go(func) { 108 + pub fn go(func) { 109 109 let huuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuge_variable = [] 110 110 } 111 111 "#,
+2 -2
compiler-core/src/javascript/tests/modules.rs
··· 60 60 ("rocket_ship", r#"pub const x = 1"#), 61 61 r#" 62 62 import rocket_ship.{ x as y } 63 - const z = y 63 + pub const z = y 64 64 "#, 65 65 ); 66 66 } ··· 71 71 ("x", r#"pub const v = 1"#), 72 72 r#" 73 73 import x as y 74 - const z = y.v 74 + pub const z = y.v 75 75 "#, 76 76 ); 77 77 }
+53 -53
compiler-core/src/javascript/tests/numbers.rs
··· 4 4 fn int_literals() { 5 5 assert_js!( 6 6 r#" 7 - fn go() { 8 - 1 9 - 2 10 - -3 11 - 4001 12 - 0b00001111 13 - 0o17 14 - 0xF 15 - 1_000 7 + pub fn go() { 8 + 1 9 + 2 10 + -3 11 + 4001 12 + 0b00001111 13 + 0o17 14 + 0xF 15 + 1_000 16 16 } 17 17 "#, 18 18 ); ··· 22 22 fn float_literals() { 23 23 assert_js!( 24 24 r#" 25 - fn go() { 26 - 1.5 27 - 2.0 28 - -0.1 29 - 1. 25 + pub fn go() { 26 + 1.5 27 + 2.0 28 + -0.1 29 + 1. 30 30 } 31 31 "#, 32 32 ); ··· 36 36 fn float_scientific_literals() { 37 37 assert_js!( 38 38 r#" 39 - fn go() { 40 - 0.01e-1 41 - 0.01e-0 42 - -10.01e-1 43 - -10.01e-0 44 - 100.001e523 45 - -100.001e-523 46 - 100.001e123_456_789 47 - -100.001e-123_456_789 39 + pub fn go() { 40 + 0.01e-1 41 + 0.01e-0 42 + -10.01e-1 43 + -10.01e-0 44 + 100.001e523 45 + -100.001e-523 46 + 100.001e123_456_789 47 + -100.001e-123_456_789 48 48 } 49 49 "#, 50 50 ); ··· 54 54 fn int_operators() { 55 55 assert_js!( 56 56 r#" 57 - fn go() { 58 - 1 + 1 // => 2 59 - 5 - 1 // => 4 60 - 5 / 2 // => 2 61 - 3 * 3 // => 9 62 - 5 % 2 // => 1 63 - 2 > 1 // => True 64 - 2 < 1 // => False 65 - 2 >= 1 // => True 66 - 2 <= 1 // => False 57 + pub fn go() { 58 + 1 + 1 // => 2 59 + 5 - 1 // => 4 60 + 5 / 2 // => 2 61 + 3 * 3 // => 9 62 + 5 % 2 // => 1 63 + 2 > 1 // => True 64 + 2 < 1 // => False 65 + 2 >= 1 // => True 66 + 2 <= 1 // => False 67 67 } 68 68 "#, 69 69 ); ··· 73 73 fn int_divide_complex_expr() { 74 74 assert_js!( 75 75 r#" 76 - fn go() { 76 + pub fn go() { 77 77 case 1 >= 0 { 78 78 True -> 2 79 79 False -> 4 ··· 87 87 fn int_mod_complex_expr() { 88 88 assert_js!( 89 89 r#" 90 - fn go() { 90 + pub fn go() { 91 91 case 1 >= 0 { 92 92 True -> 2 93 93 False -> 4 ··· 101 101 fn float_operators() { 102 102 assert_js!( 103 103 r#" 104 - fn go() { 104 + pub fn go() { 105 105 1.0 +. 1.4 // => 2.4 106 106 5.0 -. 1.5 // => 3.5 107 107 5.0 /. 2.0 // => 2.5 ··· 120 120 fn float_divide_complex_expr() { 121 121 assert_js!( 122 122 r#" 123 - fn go() { 123 + pub fn go() { 124 124 case 1.0 >=. 0.0 { 125 125 True -> 2.0 126 126 False -> 4.0 ··· 134 134 fn wide_float_div() { 135 135 assert_js!( 136 136 r#" 137 - fn go() { 137 + pub fn go() { 138 138 111111111111111111111111111111. /. 22222222222222222222222222222222222. 139 139 } 140 140 "#, ··· 145 145 fn int_patterns() { 146 146 assert_js!( 147 147 r#" 148 - fn go(x) { 148 + pub fn go(x) { 149 149 let assert 4 = x 150 150 } 151 151 "#, ··· 156 156 fn int_equality() { 157 157 assert_js!( 158 158 r#" 159 - fn go() { 159 + pub fn go() { 160 160 1 != 2 161 161 1 == 2 162 162 } ··· 168 168 fn int_equality1() { 169 169 assert_js!( 170 170 r#" 171 - fn go(y) { 171 + pub fn go(y) { 172 172 let x = 1 173 173 x == y 174 174 } ··· 180 180 fn float_equality() { 181 181 assert_js!( 182 182 r#" 183 - fn go() { 183 + pub fn go() { 184 184 1.0 != 2.0 185 185 1.0 == 2.0 186 186 } ··· 192 192 fn float_equality1() { 193 193 assert_js!( 194 194 r#" 195 - fn go(y) { 195 + pub fn go(y) { 196 196 let x = 1.0 197 197 x == y 198 198 } ··· 204 204 fn operator_precedence() { 205 205 assert_js!( 206 206 r#" 207 - fn go() { 207 + pub fn go() { 208 208 2.4 *. { 3.5 +. 6.0 } 209 209 } 210 210 "#, ··· 215 215 fn remainder() { 216 216 assert_js!( 217 217 r#" 218 - fn go() { 218 + pub fn go() { 219 219 5 % 0 // => 0 220 220 } 221 221 "#, ··· 226 226 fn int_negation() { 227 227 assert_js!( 228 228 r#" 229 - fn go() { 229 + pub fn go() { 230 230 let a = 3 231 231 let b = -a 232 232 } ··· 238 238 fn repeated_int_negation() { 239 239 assert_js!( 240 240 r#" 241 - fn go() { 241 + pub fn go() { 242 242 let a = 3 243 243 let b = --a 244 244 } ··· 251 251 fn preceeding_zeros_int() { 252 252 assert_js!( 253 253 r#" 254 - fn main() { 254 + pub fn main() { 255 255 09_179 256 256 } 257 257 "# ··· 263 263 fn preceeding_zeros_float() { 264 264 assert_js!( 265 265 r#" 266 - fn main() { 266 + pub fn main() { 267 267 09_179.1 268 268 } 269 269 "# ··· 275 275 fn preceeding_zeros_int_const() { 276 276 assert_js!( 277 277 r#" 278 - const x = 09_179 278 + pub const x = 09_179 279 279 "# 280 280 ); 281 281 } ··· 285 285 fn preceeding_zeros_float_const() { 286 286 assert_js!( 287 287 r#" 288 - const x = 09_179.1 288 + pub const x = 09_179.1 289 289 "# 290 290 ); 291 291 } ··· 295 295 fn preceeding_zeros_int_pattern() { 296 296 assert_js!( 297 297 r#" 298 - fn main(x) { 298 + pub fn main(x) { 299 299 let assert 09_179 = x 300 300 } 301 301 "# ··· 307 307 fn preceeding_zeros_float_pattern() { 308 308 assert_js!( 309 309 r#" 310 - fn main(x) { 310 + pub fn main(x) { 311 311 let assert 09_179.1 = x 312 312 } 313 313 "#
+6 -6
compiler-core/src/javascript/tests/panic.rs
··· 4 4 fn bare() { 5 5 assert_js!( 6 6 r#" 7 - fn go() { 7 + pub fn go() { 8 8 panic 9 9 } 10 10 "#, ··· 15 15 fn panic_as() { 16 16 assert_js!( 17 17 r#" 18 - fn go() { 18 + pub fn go() { 19 19 let x = "wibble" 20 20 panic as x 21 21 } ··· 38 38 fn as_expression() { 39 39 assert_js!( 40 40 r#" 41 - fn go(f) { 41 + pub fn go(f) { 42 42 let boop = panic 43 43 f(panic) 44 44 } ··· 50 50 fn pipe() { 51 51 assert_js!( 52 52 r#" 53 - fn go(f) { 53 + pub fn go(f) { 54 54 f |> panic 55 55 } 56 56 "#, ··· 61 61 fn sequence() { 62 62 assert_js!( 63 63 r#" 64 - fn go(at_the_disco) { 64 + pub fn go(at_the_disco) { 65 65 panic 66 66 at_the_disco 67 67 } ··· 73 73 fn case() { 74 74 assert_js!( 75 75 r#" 76 - fn go(x) { 76 + pub fn go(x) { 77 77 case x { 78 78 _ -> panic 79 79 }
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__assert.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 3 assertion_line: 16 4 - expression: "fn go(x) { let assert 1 = x }" 4 + expression: "pub fn go(x) { let assert 1 = x }" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 - fn go(x) { let assert 1 = x } 8 + pub fn go(x) { let assert 1 = x } 9 9 10 10 ----- COMPILED JAVASCRIPT 11 11 import { makeError } from "../gleam.mjs"; 12 12 13 13 const FILEPATH = "src/module.gleam"; 14 14 15 - function go(x) { 15 + export function go(x) { 16 16 if (x !== 1) { 17 17 throw makeError( 18 18 "let_assert", ··· 21 21 1, 22 22 "go", 23 23 "Pattern match failed, no pattern matched the value.", 24 - { value: x, start: 11, end: 27, pattern_start: 22, pattern_end: 23 } 24 + { value: x, start: 15, end: 31, pattern_start: 26, pattern_end: 27 } 25 25 ) 26 26 } 27 27 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__assert1.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 3 assertion_line: 21 4 - expression: "fn go(x) { let assert #(1, 2) = x }" 4 + expression: "pub fn go(x) { let assert #(1, 2) = x }" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 - fn go(x) { let assert #(1, 2) = x } 8 + pub fn go(x) { let assert #(1, 2) = x } 9 9 10 10 ----- COMPILED JAVASCRIPT 11 11 import { makeError } from "../gleam.mjs"; 12 12 13 13 const FILEPATH = "src/module.gleam"; 14 14 15 - function go(x) { 15 + export function go(x) { 16 16 if (x[1] !== 2 || x[0] !== 1) { 17 17 throw makeError( 18 18 "let_assert", ··· 21 21 1, 22 22 "go", 23 23 "Pattern match failed, no pattern matched the value.", 24 - { value: x, start: 11, end: 33, pattern_start: 22, pattern_end: 29 } 24 + { value: x, start: 15, end: 37, pattern_start: 26, pattern_end: 33 } 25 25 ) 26 26 } 27 27 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__assert_that_always_fails.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 3 assertion_line: 287 4 - expression: "\ntype Wibble {\n Wibble(Int)\n Wobble(Int)\n}\n\nfn go() {\n let assert Wobble(n) = Wibble(1)\n n\n}\n" 4 + expression: "\ntype Wibble {\n Wibble(Int)\n Wobble(Int)\n}\n\npub fn go() {\n let assert Wobble(n) = Wibble(1)\n n\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE ··· 11 11 Wobble(Int) 12 12 } 13 13 14 - fn go() { 14 + pub fn go() { 15 15 let assert Wobble(n) = Wibble(1) 16 16 n 17 17 } ··· 36 36 } 37 37 } 38 38 39 - function go() { 39 + export function go() { 40 40 let $ = new Wibble(1); 41 41 throw makeError( 42 42 "let_assert", ··· 45 45 8, 46 46 "go", 47 47 "Pattern match failed, no pattern matched the value.", 48 - { value: $, start: 62, end: 94, pattern_start: 73, pattern_end: 82 } 48 + { value: $, start: 66, end: 98, pattern_start: 77, pattern_end: 86 } 49 49 ) 50 50 51 51 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__assert_that_always_succeeds.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 - expression: "\ntype Wibble {\n Wibble(Int)\n}\n\nfn go() {\n let assert Wibble(n) = Wibble(1)\n n\n}\n" 3 + assertion_line: 271 4 + expression: "\ntype Wibble {\n Wibble(Int)\n}\n\npub fn go() {\n let assert Wibble(n) = Wibble(1)\n n\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 ··· 8 10 Wibble(Int) 9 11 } 10 12 11 - fn go() { 13 + pub fn go() { 12 14 let assert Wibble(n) = Wibble(1) 13 15 n 14 16 } ··· 24 26 } 25 27 } 26 28 27 - function go() { 29 + export function go() { 28 30 let $ = new Wibble(1); 29 31 let n = $[0]; 30 32 return n;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__assert_with_multiple_variants.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 3 assertion_line: 321 4 - expression: "\ntype Wibble {\n Wibble(Int)\n Wobble(Int)\n Woo(Int)\n}\n\nfn go() {\n let assert Wobble(n) = todo\n n\n}\n" 4 + expression: "\ntype Wibble {\n Wibble(Int)\n Wobble(Int)\n Woo(Int)\n}\n\npub fn go() {\n let assert Wobble(n) = todo\n n\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE ··· 12 12 Woo(Int) 13 13 } 14 14 15 - fn go() { 15 + pub fn go() { 16 16 let assert Wobble(n) = todo 17 17 n 18 18 } ··· 44 44 } 45 45 } 46 46 47 - function go() { 47 + export function go() { 48 48 let _block; 49 49 throw makeError( 50 50 "todo", ··· 64 64 9, 65 65 "go", 66 66 "Pattern match failed, no pattern matched the value.", 67 - { value: $, start: 75, end: 102, pattern_start: 86, pattern_end: 95 } 67 + { value: $, start: 79, end: 106, pattern_start: 90, pattern_end: 99 } 68 68 ) 69 69 } 70 70 let n = $[0];
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__catch_all_assert.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 - expression: "\ntype Wibble {\n Wibble(Int)\n Wobble(Int)\n}\n\nfn go() {\n let assert _ = Wibble(1)\n 1\n}\n" 3 + assertion_line: 304 4 + expression: "\ntype Wibble {\n Wibble(Int)\n Wobble(Int)\n}\n\npub fn go() {\n let assert _ = Wibble(1)\n 1\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 ··· 9 11 Wobble(Int) 10 12 } 11 13 12 - fn go() { 14 + pub fn go() { 13 15 let assert _ = Wibble(1) 14 16 1 15 17 } ··· 32 34 } 33 35 } 34 36 35 - function go() { 37 + export function go() { 36 38 let $ = new Wibble(1); 37 39 38 40 return 1;
+5 -8
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__constant_assignments.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 - expression: "\nconst a = True\n\nfn go() {\n a\n let a = 10\n a + 20\n}\n\nfn second() {\n let a = 10\n a + 20\n}\n" 3 + assertion_line: 63 4 + expression: "\nconst a = True\n\npub fn go() {\n a\n let a = 10\n a + 20\n}\n\nfn second() {\n let a = 10\n a + 20\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 9 const a = True 8 10 9 - fn go() { 11 + pub fn go() { 10 12 a 11 13 let a = 10 12 14 a + 20 ··· 19 21 20 22 21 23 ----- COMPILED JAVASCRIPT 22 - function second() { 23 - let a$1 = 10; 24 - return a$1 + 20; 25 - } 26 - 27 24 const a = true; 28 25 29 - function go() { 26 + export function go() { 30 27 a; 31 28 let a$1 = 10; 32 29 return a$1 + 20;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__nested_binding.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 3 assertion_line: 26 4 - expression: "\nfn go(x) {\n let assert #(a, #(b, c, 2) as t, _, 1) = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert #(a, #(b, c, 2) as t, _, 1) = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert #(a, #(b, c, 2) as t, _, 1) = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x[3] !== 1 || x[1][2] !== 2) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 56, pattern_start: 25, pattern_end: 52 } 28 + { value: x, start: 18, end: 60, pattern_start: 29, pattern_end: 56 } 29 29 ) 30 30 } 31 31 let a = x[0];
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__returning_literal_subject.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 3 assertion_line: 83 4 - expression: "fn go(x) { let assert 1 = x + 1 }" 4 + expression: "pub fn go(x) { let assert 1 = x + 1 }" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 - fn go(x) { let assert 1 = x + 1 } 8 + pub fn go(x) { let assert 1 = x + 1 } 9 9 10 10 ----- COMPILED JAVASCRIPT 11 11 import { makeError } from "../gleam.mjs"; 12 12 13 13 const FILEPATH = "src/module.gleam"; 14 14 15 - function go(x) { 15 + export function go(x) { 16 16 let $ = x + 1; 17 17 if ($ !== 1) { 18 18 throw makeError( ··· 22 22 1, 23 23 "go", 24 24 "Pattern match failed, no pattern matched the value.", 25 - { value: $, start: 11, end: 31, pattern_start: 22, pattern_end: 23 } 25 + { value: $, start: 15, end: 35, pattern_start: 26, pattern_end: 27 } 26 26 ) 27 27 } 28 28 return $;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__tuple_matching.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 3 assertion_line: 5 4 - expression: "\nfn go(x) {\n let assert #(1, 2) = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert #(1, 2) = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert #(1, 2) = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x[1] !== 2 || x[0] !== 1) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 36, pattern_start: 25, pattern_end: 32 } 28 + { value: x, start: 18, end: 40, pattern_start: 29, pattern_end: 36 } 29 29 ) 30 30 } 31 31 return x;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__use_discard_assignment.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 - expression: "\ntype Wibble {\n Wibble(Int)\n Wobble(Int)\n Woo(Int)\n}\n\nfn fun(f) { f(Wibble(1)) }\n\nfn go() {\n use _ <- fun\n 1\n}\n" 3 + assertion_line: 339 4 + expression: "\ntype Wibble {\n Wibble(Int)\n Wobble(Int)\n Woo(Int)\n}\n\nfn fun(f) { f(Wibble(1)) }\n\npub fn go() {\n use _ <- fun\n 1\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 ··· 12 14 13 15 fn fun(f) { f(Wibble(1)) } 14 16 15 - fn go() { 17 + pub fn go() { 16 18 use _ <- fun 17 19 1 18 20 } ··· 46 48 return f(new Wibble(1)); 47 49 } 48 50 49 - function go() { 51 + export function go() { 50 52 return fun((_) => { return 1; }); 51 53 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__use_matching_assignment.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 - expression: "\nfn fun(f) { f(#(2, 4)) }\n\nfn go() {\n use #(_, n) <- fun\n n\n}\n" 3 + assertion_line: 359 4 + expression: "\nfn fun(f) { f(#(2, 4)) }\n\npub fn go() {\n use #(_, n) <- fun\n n\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 9 fn fun(f) { f(#(2, 4)) } 8 10 9 - fn go() { 11 + pub fn go() { 10 12 use #(_, n) <- fun 11 13 n 12 14 } ··· 17 19 return f([2, 4]); 18 20 } 19 21 20 - function go() { 22 + export function go() { 21 23 return fun( 22 24 (_use0) => { 23 25 let n = _use0[1];
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__assignments__variable_renaming.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/assignments.rs 3 3 assertion_line: 37 4 - expression: "\n\nfn go(x, wibble) {\n let a = 1\n wibble(a)\n let a = 2\n wibble(a)\n let assert #(a, 3) = x\n let b = a\n wibble(b)\n let c = {\n let a = a\n #(a, b)\n }\n wibble(a)\n // make sure arguments are counted in initial state\n let x = c\n x\n}\n" 4 + expression: "\n\npub fn go(x, wibble) {\n let a = 1\n wibble(a)\n let a = 2\n wibble(a)\n let assert #(a, 3) = x\n let b = a\n wibble(b)\n let c = {\n let a = a\n #(a, b)\n }\n wibble(a)\n // make sure arguments are counted in initial state\n let x = c\n x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 9 10 - fn go(x, wibble) { 10 + pub fn go(x, wibble) { 11 11 let a = 1 12 12 wibble(a) 13 13 let a = 2 ··· 31 31 32 32 const FILEPATH = "src/module.gleam"; 33 33 34 - function go(x, wibble) { 34 + export function go(x, wibble) { 35 35 let a = 1; 36 36 wibble(a); 37 37 let a$1 = 2; ··· 44 44 8, 45 45 "go", 46 46 "Pattern match failed, no pattern matched the value.", 47 - { value: x, start: 71, end: 93, pattern_start: 82, pattern_end: 89 } 47 + { value: x, start: 75, end: 97, pattern_start: 86, pattern_end: 93 } 48 48 ) 49 49 } 50 50 let a$2 = x[0];
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__alternative_patterns_with_variable_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<_, n, rest:size(n)>> |\n <<n, _, rest:size(n)>> -> True\n _ -> False\n }\n}\n" 3 + assertion_line: 1918 4 + expression: "\npub fn go(x) {\n case x {\n <<_, n, rest:size(n)>> |\n <<n, _, rest:size(n)>> -> True\n _ -> False\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<_, n, rest:size(n)>> | 10 12 <<n, _, rest:size(n)>> -> True ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySliceToInt } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 if (x.bitSize >= 8 && x.bitSize >= 16) { 21 23 let n = x.byteAt(1); 22 24 if (x.bitSize === 16 + n) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__bit_array_dynamic_slice.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let i = 4\n <<<<0xAB>>:bits-size(i)>>\n}\n" 3 + assertion_line: 380 4 + expression: "\npub fn go(x) {\n let i = 4\n <<<<0xAB>>:bits-size(i)>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let i = 4 9 11 <<<<0xAB>>:bits-size(i)>> 10 12 } ··· 13 15 ----- COMPILED JAVASCRIPT 14 16 import { toBitArray, bitArraySlice } from "../gleam.mjs"; 15 17 16 - function go(x) { 18 + export function go(x) { 17 19 let i = 4; 18 20 return toBitArray([bitArraySlice(toBitArray([171]), 0, i)]); 19 21 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__bit_array_literal_string_constant_is_treated_as_utf8.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "const a = <<\"hello\", \" \", \"world\">>" 3 + assertion_line: 1742 4 + expression: "pub const a = <<\"hello\", \" \", \"world\">>" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 - const a = <<"hello", " ", "world">> 8 + pub const a = <<"hello", " ", "world">> 7 9 8 10 ----- COMPILED JAVASCRIPT 9 11 import { toBitArray, stringBits } from "../gleam.mjs"; 10 12 11 - const a = /* @__PURE__ */ toBitArray([ 13 + export const a = /* @__PURE__ */ toBitArray([ 12 14 stringBits("hello"), 13 15 stringBits(" "), 14 16 stringBits("world"),
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__bit_array_sliced.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n <<<<0xAB>>:bits-4>>\n}\n" 3 + assertion_line: 369 4 + expression: "\npub fn go(x) {\n <<<<0xAB>>:bits-4>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 <<<<0xAB>>:bits-4>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, bitArraySlice } from "../gleam.mjs"; 14 16 15 - function go(x) { 17 + export function go(x) { 16 18 return toBitArray([bitArraySlice(toBitArray([171]), 0, 4)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__bit_string.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n <<x:bits>>\n}\n" 3 + assertion_line: 347 4 + expression: "\npub fn go(x) {\n <<x:bits>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 <<x:bits>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go(x) { 17 + export function go(x) { 16 18 return toBitArray([x]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__bits.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n <<x:bits>>\n}\n" 3 + assertion_line: 358 4 + expression: "\npub fn go(x) {\n <<x:bits>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 <<x:bits>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go(x) { 17 + export function go(x) { 16 18 return toBitArray([x]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_discard_sized.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<_:16, _:8>> -> 1\n _ -> 2\n }\n case x {\n <<_:16-little-signed, _:8>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1117 4 + expression: "\npub fn go(x) {\n case x {\n <<_:16, _:8>> -> 1\n _ -> 2\n }\n case x {\n <<_:16-little-signed, _:8>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<_:16, _:8>> -> 1 10 12 _ -> 2 ··· 17 19 18 20 19 21 ----- COMPILED JAVASCRIPT 20 - function go(x) { 22 + export function go(x) { 21 23 if (x.bitSize >= 16 && x.bitSize === 24) { 22 24 1 23 25 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_dynamic_size_float_pattern_with_unit.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let size = 3\n case x {\n <<1.3:size(size)-unit(2)>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1845 4 + expression: "\npub fn go(x) {\n let size = 3\n case x {\n <<1.3:size(size)-unit(2)>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let size = 3 9 11 case x { 10 12 <<1.3:size(size)-unit(2)>> -> 1 ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySliceToFloat } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let size = 3; 21 23 if ( 22 24 size >= 0 &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_dynamic_size_pattern_with_unit.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let size = 3\n case x {\n <<1:size(size)-unit(2)>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1830 4 + expression: "\npub fn go(x) {\n let size = 3\n case x {\n <<1:size(size)-unit(2)>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let size = 3 9 11 case x { 10 12 <<1:size(size)-unit(2)>> -> 1 ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySliceToInt } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let size = 3; 21 23 if ( 22 24 size >= 0 &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_empty_match.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 425 4 + expression: "\npub fn go(x) {\n case x {\n <<>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 0) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_is_byte_aligned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn is_byte_aligned(x) {\n case x {\n <<_:bytes>> -> True\n _ -> False\n }\n}\n" 3 + assertion_line: 1904 4 + expression: "\npub fn is_byte_aligned(x) {\n case x {\n <<_:bytes>> -> True\n _ -> False\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn is_byte_aligned(x) { 9 + pub fn is_byte_aligned(x) { 8 10 case x { 9 11 <<_:bytes>> -> True 10 12 _ -> False ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function is_byte_aligned(x) { 18 + export function is_byte_aligned(x) { 17 19 if (x.bitSize % 8 === 0) { 18 20 return true; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_binary_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<_, a:2-bytes>> -> a\n _ -> x\n }\n\n case x {\n <<_, b:bytes-size(2)>> -> b\n _ -> x\n }\n}\n" 3 + assertion_line: 1599 4 + expression: "\npub fn go(x) {\n case x {\n <<_, a:2-bytes>> -> a\n _ -> x\n }\n\n case x {\n <<_, b:bytes-size(2)>> -> b\n _ -> x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<_, a:2-bytes>> -> a 10 12 _ -> x ··· 20 22 ----- COMPILED JAVASCRIPT 21 23 import { bitArraySlice } from "../gleam.mjs"; 22 24 23 - function go(x) { 25 + export function go(x) { 24 26 if (x.bitSize >= 8 && x.bitSize === 24) { 25 27 let a = bitArraySlice(x, 8, 24); 26 28 a
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_bits_with_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case <<0x77:7>> {\n <<_:4, f:bits-2, _:1>> -> f\n _ -> x\n }\n}\n" 3 + assertion_line: 1498 4 + expression: "\npub fn go(x) {\n case <<0x77:7>> {\n <<_:4, f:bits-2, _:1>> -> f\n _ -> x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case <<0x77:7>> { 9 11 <<_:4, f:bits-2, _:1>> -> f 10 12 _ -> x ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { toBitArray, bitArraySlice, sizedInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 let $ = toBitArray([sizedInt(0x77, 7, true)]); 20 22 if ($.bitSize >= 4 && $.bitSize >= 6 && $.bitSize === 7) { 21 23 let f = bitArraySlice($, 4, 6);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_bytes.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<1, y>> -> y\n _ -> 1\n }\n}\n" 3 + assertion_line: 450 4 + expression: "\npub fn go(x) {\n case x {\n <<1, y>> -> y\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<1, y>> -> y 10 12 _ -> 1 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize >= 8 && x.byteAt(0) === 1 && x.bitSize === 16) { 18 20 let y = x.byteAt(1); 19 21 return y;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_bytes_with_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case <<1, 2>> {\n <<f:bytes-2>> -> f\n _ -> x\n }\n}\n" 3 + assertion_line: 1473 4 + expression: "\npub fn go(x) {\n case <<1, 2>> {\n <<f:bytes-2>> -> f\n _ -> x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case <<1, 2>> { 9 11 <<f:bytes-2>> -> f 10 12 _ -> x ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { toBitArray, bitArraySlice } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 let $ = toBitArray([1, 2]); 20 22 if ($.bitSize === 16) { 21 23 let f = bitArraySlice($, 0, 16);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_dynamic_bits_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 16\n case x {\n <<a:bits-size(n)>> -> a\n _ -> x\n }\n}\n" 3 + assertion_line: 1063 4 + expression: "\npub fn go(x) {\n let n = 16\n case x {\n <<a:bits-size(n)>> -> a\n _ -> x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 16 9 11 case x { 10 12 <<a:bits-size(n)>> -> a ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySlice } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let n = 16; 21 23 if (n >= 0 && x.bitSize === n) { 22 24 let a = bitArraySlice(x, 0, n);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_dynamic_bytes_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 3\n case x {\n <<a:bytes-size(n)>> -> a\n _ -> x\n }\n}\n" 3 + assertion_line: 1090 4 + expression: "\npub fn go(x) {\n let n = 3\n case x {\n <<a:bytes-size(n)>> -> a\n _ -> x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 3 9 11 case x { 10 12 <<a:bytes-size(n)>> -> a ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySlice } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let n = 3; 21 23 if (n >= 0 && x.bitSize === n * 8) { 22 24 let a = bitArraySlice(x, 0, n * 8);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_dynamic_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 16\n case x {\n <<a:size(n)>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 951 4 + expression: "\npub fn go(x) {\n let n = 16\n case x {\n <<a:size(n)>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 16 9 11 case x { 10 12 <<a:size(n)>> -> a ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySliceToInt } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let n = 16; 21 23 if (n >= 0 && x.bitSize === n) { 22 24 let a = bitArraySliceToInt(x, 0, n, true, false);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_dynamic_size_literal_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 8\n case x {\n <<a:size(n), 0b010101:size(8)>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 1036 4 + expression: "\npub fn go(x) {\n let n = 8\n case x {\n <<a:size(n), 0b010101:size(8)>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 8 9 11 case x { 10 12 <<a:size(n), 0b010101:size(8)>> -> a ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySliceToInt } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let n = 8; 21 23 if ( 22 24 n >= 0 &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_dynamic_size_shadowed_variable.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 16\n let n = 5\n case x {\n <<a:size(n)>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 1008 4 + expression: "\npub fn go(x) {\n let n = 16\n let n = 5\n case x {\n <<a:size(n)>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 16 9 11 let n = 5 10 12 case x { ··· 17 19 ----- COMPILED JAVASCRIPT 18 20 import { bitArraySliceToInt } from "../gleam.mjs"; 19 21 20 - function go(x) { 22 + export function go(x) { 21 23 let n = 16; 22 24 let n$1 = 5; 23 25 if (n$1 >= 0 && x.bitSize === n$1) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_dynamic_size_with_other_segments.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 16\n let m = 32\n case x {\n <<first:size(8), a:size(n), b:size(m), rest:bits>> -> first + a + b\n _ -> 1\n }\n}\n" 3 + assertion_line: 979 4 + expression: "\npub fn go(x) {\n let n = 16\n let m = 32\n case x {\n <<first:size(8), a:size(n), b:size(m), rest:bits>> -> first + a + b\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 16 9 11 let m = 32 10 12 case x { ··· 17 19 ----- COMPILED JAVASCRIPT 18 20 import { bitArraySlice, bitArraySliceToInt } from "../gleam.mjs"; 19 21 20 - function go(x) { 22 + export function go(x) { 21 23 let n = 16; 22 24 let m = 32; 23 25 if (
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_float.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:float, b:int>> -> #(a, b)\n _ -> #(1.1, 2)\n }\n}\n" 3 + assertion_line: 1196 4 + expression: "\npub fn go(x) {\n case x {\n <<a:float, b:int>> -> #(a, b)\n _ -> #(1.1, 2)\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:float, b:int>> -> #(a, b) 10 12 _ -> #(1.1, 2) ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToFloat } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if ( 20 22 x.bitSize >= 64 && 21 23 Number.isFinite(bitArraySliceToFloat(x, 0, 64, true)) &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_float_16_bit.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:float-size(16)>> -> a\n _ -> 1.1\n }\n}\n" 3 + assertion_line: 1423 4 + expression: "\npub fn go(x) {\n case x {\n <<a:float-size(16)>> -> a\n _ -> 1.1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:float-size(16)>> -> a 10 12 _ -> 1.1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToFloat } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize === 16 && Number.isFinite(bitArraySliceToFloat(x, 0, 16, true))) { 20 22 let a = bitArraySliceToFloat(x, 0, 16, true); 21 23 return a;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_float_big_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:float-big, b:int>> -> #(a, b)\n _ -> #(1.1, 1)\n }\n}\n" 3 + assertion_line: 1221 4 + expression: "\npub fn go(x) {\n case x {\n <<a:float-big, b:int>> -> #(a, b)\n _ -> #(1.1, 1)\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:float-big, b:int>> -> #(a, b) 10 12 _ -> #(1.1, 1) ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToFloat } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if ( 20 22 x.bitSize >= 64 && 21 23 Number.isFinite(bitArraySliceToFloat(x, 0, 64, true)) &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_float_little_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:float-little, b:int>> -> #(a, b)\n _ -> #(1.1, 2)\n }\n}\n" 3 + assertion_line: 1246 4 + expression: "\npub fn go(x) {\n case x {\n <<a:float-little, b:int>> -> #(a, b)\n _ -> #(1.1, 2)\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:float-little, b:int>> -> #(a, b) 10 12 _ -> #(1.1, 2) ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToFloat } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if ( 20 22 x.bitSize >= 64 && 21 23 Number.isFinite(bitArraySliceToFloat(x, 0, 64, false)) &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_float_sized.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:float-32, b:int>> -> #(a, b)\n _ -> #(1.1, 2)\n }\n}\n" 3 + assertion_line: 1271 4 + expression: "\npub fn go(x) {\n case x {\n <<a:float-32, b:int>> -> #(a, b)\n _ -> #(1.1, 2)\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:float-32, b:int>> -> #(a, b) 10 12 _ -> #(1.1, 2) ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToFloat } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if ( 20 22 x.bitSize >= 32 && 21 23 Number.isFinite(bitArraySliceToFloat(x, 0, 32, true)) &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_float_sized_big_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:float-32-big, b:int>> -> #(a, b)\n _ -> #(1.1, 2)\n }\n}\n" 3 + assertion_line: 1296 4 + expression: "\npub fn go(x) {\n case x {\n <<a:float-32-big, b:int>> -> #(a, b)\n _ -> #(1.1, 2)\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:float-32-big, b:int>> -> #(a, b) 10 12 _ -> #(1.1, 2) ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToFloat } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if ( 20 22 x.bitSize >= 32 && 21 23 Number.isFinite(bitArraySliceToFloat(x, 0, 32, true)) &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_float_sized_little_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:float-32-little, b:int>> -> #(a, b)\n _ -> #(1.1, 2)\n }\n}\n" 3 + assertion_line: 1321 4 + expression: "\npub fn go(x) {\n case x {\n <<a:float-32-little, b:int>> -> #(a, b)\n _ -> #(1.1, 2)\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:float-32-little, b:int>> -> #(a, b) 10 12 _ -> #(1.1, 2) ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToFloat } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if ( 20 22 x.bitSize >= 32 && 21 23 Number.isFinite(bitArraySliceToFloat(x, 0, 32, false)) &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_literal_aligned_float.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<_, 1.1, _:int>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1398 4 + expression: "\npub fn go(x) {\n case x {\n <<_, 1.1, _:int>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<_, 1.1, _:int>> -> 1 10 12 _ -> 2 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToFloat } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if ( 20 22 x.bitSize >= 8 && 21 23 x.bitSize >= 72 &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_literal_float.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<1.4, b:int>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1346 4 + expression: "\npub fn go(x) {\n case x {\n <<1.4, b:int>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<1.4, b:int>> -> 1 10 12 _ -> 2 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToFloat } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if ( 20 22 x.bitSize >= 64 && 21 23 bitArraySliceToFloat(x, 0, 64, true) === 1.4 &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_literal_unaligned_float.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 1\n case x {\n <<_:size(n), 1.1, _:int>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1372 4 + expression: "\npub fn go(x) {\n let n = 1\n case x {\n <<_:size(n), 1.1, _:int>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 1 9 11 case x { 10 12 <<_:size(n), 1.1, _:int>> -> 1 ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySliceToFloat } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let n = 1; 21 23 if ( 22 24 n >= 0 &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_rest.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case <<1, 2, 3>> {\n <<_, b:bytes>> -> b\n _ -> x\n }\n}\n" 3 + assertion_line: 1448 4 + expression: "\npub fn go(x) {\n case <<1, 2, 3>> {\n <<_, b:bytes>> -> b\n _ -> x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case <<1, 2, 3>> { 9 11 <<_, b:bytes>> -> b 10 12 _ -> x ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { toBitArray, bitArraySlice } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 let $ = toBitArray([1, 2, 3]); 20 22 if ($.bitSize >= 8 && ($.bitSize - 8) % 8 === 0) { 21 23 let b = bitArraySlice($, 8);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_rest_bits.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<_, b:bits>> -> b\n _ -> x\n }\n}\n" 3 + assertion_line: 1548 4 + expression: "\npub fn go(x) {\n case x {\n <<_, b:bits>> -> b\n _ -> x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<_, b:bits>> -> b 10 12 _ -> x ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySlice } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize >= 8) { 20 22 let b = bitArraySlice(x, 8); 21 23 return b;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_rest_bits_unaligned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<_:5, b:bits>> -> b\n _ -> x\n }\n}\n" 3 + assertion_line: 1573 4 + expression: "\npub fn go(x) {\n case x {\n <<_:5, b:bits>> -> b\n _ -> x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<_:5, b:bits>> -> b 10 12 _ -> x ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySlice } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize >= 5) { 20 22 let b = bitArraySlice(x, 5); 21 23 return b;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_rest_bytes.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<_, b:bytes>> -> b\n _ -> x\n }\n}\n" 3 + assertion_line: 1523 4 + expression: "\npub fn go(x) {\n case x {\n <<_, b:bytes>> -> b\n _ -> x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<_, b:bytes>> -> b 10 12 _ -> x ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySlice } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize >= 8 && (x.bitSize - 8) % 8 === 0) { 20 22 let b = bitArraySlice(x, 8); 21 23 return b;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_signed.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:signed>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 600 4 + expression: "\npub fn go(x) {\n case x {\n <<a:signed>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:signed>> -> a 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize === 8) { 20 22 let a = bitArraySliceToInt(x, 0, 8, true, true); 21 23 return a;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_signed_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<-1:signed>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 625 4 + expression: "\npub fn go(x) {\n case x {\n <<-1:signed>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<-1:signed>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 8 && x.byteAt(0) === 255) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:16, b:8>> -> a + b\n _ -> 1\n }\n}\n" 3 + assertion_line: 475 4 + expression: "\npub fn go(x) {\n case x {\n <<a:16, b:8>> -> a + b\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:16, b:8>> -> a + b 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize >= 16 && x.bitSize === 24) { 20 22 let a = bitArraySliceToInt(x, 0, 16, true, false); 21 23 let b = x.byteAt(2);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_big_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:16-big>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 650 4 + expression: "\npub fn go(x) {\n case x {\n <<a:16-big>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:16-big>> -> a 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize === 16) { 20 22 let a = bitArraySliceToInt(x, 0, 16, true, false); 21 23 return a;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_big_endian_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<1234:16-big>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 675 4 + expression: "\npub fn go(x) {\n case x {\n <<1234:16-big>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<1234:16-big>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 16 && x.byteAt(0) === 4 && x.byteAt(1) === 210) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_big_endian_signed.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:16-big-signed>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 800 4 + expression: "\npub fn go(x) {\n case x {\n <<a:16-big-signed>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:16-big-signed>> -> a 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize === 16) { 20 22 let a = bitArraySliceToInt(x, 0, 16, true, true); 21 23 return a;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_big_endian_signed_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<1234:16-big-signed>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 825 4 + expression: "\npub fn go(x) {\n case x {\n <<1234:16-big-signed>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<1234:16-big-signed>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 16 && x.byteAt(0) === 4 && x.byteAt(1) === 210) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_big_endian_unsigned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:16-big-unsigned>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 750 4 + expression: "\npub fn go(x) {\n case x {\n <<a:16-big-unsigned>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:16-big-unsigned>> -> a 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize === 16) { 20 22 let a = bitArraySliceToInt(x, 0, 16, true, false); 21 23 return a;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_big_endian_unsigned_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<1234:16-big-unsigned>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 775 4 + expression: "\npub fn go(x) {\n case x {\n <<1234:16-big-unsigned>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<1234:16-big-unsigned>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 16 && x.byteAt(0) === 4 && x.byteAt(1) === 210) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<1234:16, 123:8>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 525 4 + expression: "\npub fn go(x) {\n case x {\n <<1234:16, 123:8>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<1234:16, 123:8>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if ( 18 20 x.bitSize >= 16 && 19 21 x.byteAt(0) === 4 && x.byteAt(1) === 210 &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_little_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:16-little>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 700 4 + expression: "\npub fn go(x) {\n case x {\n <<a:16-little>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:16-little>> -> a 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize === 16) { 20 22 let a = bitArraySliceToInt(x, 0, 16, false, false); 21 23 return a;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_little_endian_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<1234:16-little>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 725 4 + expression: "\npub fn go(x) {\n case x {\n <<1234:16-little>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<1234:16-little>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 16 && x.byteAt(0) === 210 && x.byteAt(1) === 4) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_little_endian_signed.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:16-little-signed>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 900 4 + expression: "\npub fn go(x) {\n case x {\n <<a:16-little-signed>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:16-little-signed>> -> a 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize === 16) { 20 22 let a = bitArraySliceToInt(x, 0, 16, false, true); 21 23 return a;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_little_endian_signed_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<1234:16-little-signed>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 925 4 + expression: "\npub fn go(x) {\n case x {\n <<1234:16-little-signed>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<1234:16-little-signed>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 16 && x.byteAt(0) === 210 && x.byteAt(1) === 4) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_little_endian_unsigned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:16-little-unsigned>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 850 4 + expression: "\npub fn go(x) {\n case x {\n <<a:16-little-unsigned>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:16-little-unsigned>> -> a 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize === 16) { 20 22 let a = bitArraySliceToInt(x, 0, 16, false, false); 21 23 return a;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_little_endian_unsigned_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<1234:16-little-unsigned>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 875 4 + expression: "\npub fn go(x) {\n case x {\n <<1234:16-little-unsigned>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<1234:16-little-unsigned>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 16 && x.byteAt(0) === 210 && x.byteAt(1) === 4) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_unaligned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:17, b:7>> -> b * 2\n _ -> 1\n }\n}\n" 3 + assertion_line: 500 4 + expression: "\npub fn go(x) {\n case x {\n <<a:17, b:7>> -> b * 2\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:17, b:7>> -> b * 2 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize >= 17 && x.bitSize === 24) { 20 22 let a = bitArraySliceToInt(x, 0, 17, true, false); 21 23 let b = bitArraySliceToInt(x, 17, 24, true, false);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<i:16>> -> i\n _ -> 1\n }\n}\n" 3 + assertion_line: 1146 4 + expression: "\npub fn go(x) {\n case x {\n <<i:16>> -> i\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<i:16>> -> i 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize === 16) { 20 22 let i = bitArraySliceToInt(x, 0, 16, true, false); 21 23 return i;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_sized_value_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<258:16>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1171 4 + expression: "\npub fn go(x) {\n case x {\n <<258:16>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<258:16>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 16 && x.byteAt(0) === 1 && x.byteAt(1) === 2) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_unsigned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<a:unsigned>> -> a\n _ -> 1\n }\n}\n" 3 + assertion_line: 550 4 + expression: "\npub fn go(x) {\n case x {\n <<a:unsigned>> -> a\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<a:unsigned>> -> a 10 12 _ -> 1 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 8) { 18 20 let a = x.byteAt(0); 19 21 return a;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_match_unsigned_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<-2:unsigned>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 575 4 + expression: "\npub fn go(x) {\n case x {\n <<-2:unsigned>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<-2:unsigned>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize === 8 && x.byteAt(0) === 254) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_pattern_with_unit.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<1:size(2)-unit(2), 2:size(3)-unit(4)>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1804 4 + expression: "\npub fn go(x) {\n case x {\n <<1:size(2)-unit(2), 2:size(3)-unit(4)>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<1:size(2)-unit(2), 2:size(3)-unit(4)>> -> 1 10 12 _ -> 2 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if ( 20 22 x.bitSize >= 4 && 21 23 bitArraySliceToInt(x, 0, 4, true, false) === 1 &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_with_remaining_bytes_after_constant_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<_, _, _:bytes>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1860 4 + expression: "\npub fn go(x) {\n case x {\n <<_, _, _:bytes>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<_, _, _:bytes>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if (x.bitSize >= 8 && x.bitSize >= 16 && (x.bitSize - 16) % 8 === 0) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_with_remaining_bytes_after_variable_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 1\n case x {\n <<_:size(n), _, _:bytes>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1874 4 + expression: "\npub fn go(x) {\n let n = 1\n case x {\n <<_:size(n), _, _:bytes>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 1 9 11 case x { 10 12 <<_:size(n), _, _:bytes>> -> 1 ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - function go(x) { 19 + export function go(x) { 18 20 let n = 1; 19 21 if ( 20 22 n >= 0 &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__case_with_remaining_bytes_after_variable_size_2.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 1\n case x {\n <<m:size(n), _:size(m), _:bytes>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1889 4 + expression: "\npub fn go(x) {\n let n = 1\n case x {\n <<m:size(n), _:size(m), _:bytes>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 1 9 11 case x { 10 12 <<m:size(n), _:size(m), _:bytes>> -> 1 ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySliceToInt } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let n = 1; 21 23 if (n >= 0 && x.bitSize >= n) { 22 24 let m = bitArraySliceToInt(x, 0, n, true, false);
+5 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__discard_sized.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1105 4 - expression: "\nfn go(x) {\n let assert <<_:16, _:8>> = x\n let assert <<_:16-little-signed, _:8>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<_:16, _:8>> = x\n let assert <<_:16-little-signed, _:8>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<_:16, _:8>> = x 11 11 let assert <<_:16-little-signed, _:8>> = x 12 12 } ··· 17 17 18 18 const FILEPATH = "src/module.gleam"; 19 19 20 - function go(x) { 20 + export function go(x) { 21 21 if (x.bitSize !== 24) { 22 22 throw makeError( 23 23 "let_assert", ··· 26 26 3, 27 27 "go", 28 28 "Pattern match failed, no pattern matched the value.", 29 - { value: x, start: 14, end: 42, pattern_start: 25, pattern_end: 38 } 29 + { value: x, start: 18, end: 46, pattern_start: 29, pattern_end: 42 } 30 30 ) 31 31 } 32 32 if (x.bitSize !== 24) { ··· 37 37 4, 38 38 "go", 39 39 "Pattern match failed, no pattern matched the value.", 40 - { value: x, start: 45, end: 87, pattern_start: 56, pattern_end: 83 } 40 + { value: x, start: 49, end: 91, pattern_start: 60, pattern_end: 87 } 41 41 ) 42 42 } 43 43 return x;
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__dynamic_size_pattern_with_unit.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let size = 3\n let assert <<1:size(size)-unit(2)>> = x\n}\n" 3 + assertion_line: 1818 4 + expression: "\npub fn go(x) {\n let size = 3\n let assert <<1:size(size)-unit(2)>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let size = 3 9 11 let assert <<1:size(size)-unit(2)>> = x 10 12 } ··· 15 17 16 18 const FILEPATH = "src/module.gleam"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 let size = 3; 20 22 if ( 21 23 size < 0 || ··· 29 31 4, 30 32 "go", 31 33 "Pattern match failed, no pattern matched the value.", 32 - { value: x, start: 29, end: 68, pattern_start: 40, pattern_end: 64 } 34 + { value: x, start: 33, end: 72, pattern_start: 44, pattern_end: 68 } 33 35 ) 34 36 } 35 37 return x;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__dynamic_size_with_unit.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn main() {\n let size = 3\n <<1:size(size)-unit(2)>>\n}\n" 3 + assertion_line: 1781 4 + expression: "\npub fn main() {\n let size = 3\n <<1:size(size)-unit(2)>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn main() { 9 + pub fn main() { 8 10 let size = 3 9 11 <<1:size(size)-unit(2)>> 10 12 } ··· 13 15 ----- COMPILED JAVASCRIPT 14 16 import { toBitArray, sizedInt } from "../gleam.mjs"; 15 17 16 - function main() { 18 + export function main() { 17 19 let size = 3; 18 20 return toBitArray([sizedInt(1, size * 2, true)]); 19 21 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__empty.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<>>\n}\n" 3 + assertion_line: 11 4 + expression: "\npub fn go() {\n <<>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([]); 17 19 }
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__empty_match.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 414 4 - expression: "\nfn go(x) {\n let assert <<>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 0) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 33, pattern_start: 25, pattern_end: 29 } 28 + { value: x, start: 18, end: 37, pattern_start: 29, pattern_end: 33 } 29 29 ) 30 30 } 31 31 return x;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__explicit_sized_constant_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<256:size(32)>>\n}\n" 3 + assertion_line: 220 4 + expression: "\npub fn go() {\n <<256:size(32)>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<256:size(32)>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([0, 0, 1, 0]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__explicit_sized_dynamic_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(i: Int) {\n <<i:size(32)>>\n}\n" 3 + assertion_line: 231 4 + expression: "\npub fn go(i: Int) {\n <<i:size(32)>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(i: Int) { 9 + pub fn go(i: Int) { 8 10 <<i:size(32)>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedInt } from "../gleam.mjs"; 14 16 15 - function go(i) { 17 + export function go(i) { 16 18 return toBitArray([sizedInt(i, 32, true)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__float.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<1.1:float>>\n}\n" 3 + assertion_line: 55 4 + expression: "\npub fn go() {\n <<1.1:float>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<1.1:float>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedFloat } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([sizedFloat(1.1, 64, true)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__float_big_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<1.1:float-big>>\n}\n" 3 + assertion_line: 66 4 + expression: "\npub fn go() {\n <<1.1:float-big>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<1.1:float-big>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedFloat } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([sizedFloat(1.1, 64, true)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__float_little_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<1.1:float-little>>\n}\n" 3 + assertion_line: 77 4 + expression: "\npub fn go() {\n <<1.1:float-little>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<1.1:float-little>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedFloat } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([sizedFloat(1.1, 64, false)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__float_sized.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<1.1:float-32>>\n}\n" 3 + assertion_line: 88 4 + expression: "\npub fn go() {\n <<1.1:float-32>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<1.1:float-32>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedFloat } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([sizedFloat(1.1, 32, true)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__float_sized_big_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<1.1:float-32-big>>\n}\n" 3 + assertion_line: 99 4 + expression: "\npub fn go() {\n <<1.1:float-32-big>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<1.1:float-32-big>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedFloat } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([sizedFloat(1.1, 32, true)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__float_sized_little_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<1.1:float-32-little>>\n}\n" 3 + assertion_line: 110 4 + expression: "\npub fn go() {\n <<1.1:float-32-little>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<1.1:float-32-little>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedFloat } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([sizedFloat(1.1, 32, false)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__integer.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<256:int>>\n}\n" 3 + assertion_line: 44 4 + expression: "\npub fn go() {\n <<256:int>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<256:int>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([0]); 17 19 }
+5 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_binary_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1587 4 - expression: "\nfn go(x) {\n let assert <<_, a:2-bytes>> = x\n let assert <<_, b:bytes-size(2)>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<_, a:2-bytes>> = x\n let assert <<_, b:bytes-size(2)>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<_, a:2-bytes>> = x 11 11 let assert <<_, b:bytes-size(2)>> = x 12 12 } ··· 17 17 18 18 const FILEPATH = "src/module.gleam"; 19 19 20 - function go(x) { 20 + export function go(x) { 21 21 if (x.bitSize !== 24) { 22 22 throw makeError( 23 23 "let_assert", ··· 26 26 3, 27 27 "go", 28 28 "Pattern match failed, no pattern matched the value.", 29 - { value: x, start: 14, end: 45, pattern_start: 25, pattern_end: 41 } 29 + { value: x, start: 18, end: 49, pattern_start: 29, pattern_end: 45 } 30 30 ) 31 31 } 32 32 let a = bitArraySlice(x, 8, 24); ··· 38 38 4, 39 39 "go", 40 40 "Pattern match failed, no pattern matched the value.", 41 - { value: x, start: 48, end: 85, pattern_start: 59, pattern_end: 81 } 41 + { value: x, start: 52, end: 89, pattern_start: 63, pattern_end: 85 } 42 42 ) 43 43 } 44 44 let b = bitArraySlice(x, 8, 24);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_bits_with_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1487 4 - expression: "\nfn go(x) {\n let assert <<_:4, f:bits-2, _:1>> = <<0x77:7>>\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<_:4, f:bits-2, _:1>> = <<0x77:7>>\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<_:4, f:bits-2, _:1>> = <<0x77:7>> 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 let $ = toBitArray([sizedInt(0x77, 7, true)]); 21 21 if ($.bitSize !== 7) { 22 22 throw makeError( ··· 26 26 3, 27 27 "go", 28 28 "Pattern match failed, no pattern matched the value.", 29 - { value: $, start: 14, end: 60, pattern_start: 25, pattern_end: 47 } 29 + { value: $, start: 18, end: 64, pattern_start: 29, pattern_end: 51 } 30 30 ) 31 31 } 32 32 let f = bitArraySlice($, 4, 6);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_bytes.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 439 4 - expression: "\nfn go(x) {\n let assert <<1, y>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<1, y>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<1, y>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16 || x.byteAt(0) !== 1) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 37, pattern_start: 25, pattern_end: 33 } 28 + { value: x, start: 18, end: 41, pattern_start: 29, pattern_end: 37 } 29 29 ) 30 30 } 31 31 let y = x.byteAt(1);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_bytes_with_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1462 4 - expression: "\nfn go(x) {\n let assert <<f:bytes-2>> = <<1, 2>>\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<f:bytes-2>> = <<1, 2>>\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<f:bytes-2>> = <<1, 2>> 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 let $ = toBitArray([1, 2]); 21 21 if ($.bitSize !== 16) { 22 22 throw makeError( ··· 26 26 3, 27 27 "go", 28 28 "Pattern match failed, no pattern matched the value.", 29 - { value: $, start: 14, end: 49, pattern_start: 25, pattern_end: 38 } 29 + { value: $, start: 18, end: 53, pattern_start: 29, pattern_end: 42 } 30 30 ) 31 31 } 32 32 let f = bitArraySlice($, 0, 16);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_case_utf8.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<\"Gleam 👍\":utf8>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 311 4 + expression: "\npub fn go(x) {\n case x {\n <<\"Gleam 👍\":utf8>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<"Gleam 👍":utf8>> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if ( 18 20 x.bitSize === 80 && 19 21 x.byteAt(0) === 71 &&
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_case_utf8_with_escape_chars.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<\"\\\"\\\\\\r\\n\\t\\f\\u{1f600}\">> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 297 4 + expression: "\npub fn go(x) {\n case x {\n <<\"\\\"\\\\\\r\\n\\t\\f\\u{1f600}\">> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<"\"\\\r\n\t\f\u{1f600}">> -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 if ( 18 20 x.bitSize === 80 && 19 21 x.byteAt(0) === 34 &&
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_dynamic_bits_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 16\n let assert <<a:bits-size(n)>> = x\n}\n" 3 + assertion_line: 1051 4 + expression: "\npub fn go(x) {\n let n = 16\n let assert <<a:bits-size(n)>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 16 9 11 let assert <<a:bits-size(n)>> = x 10 12 } ··· 15 17 16 18 const FILEPATH = "src/module.gleam"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 let n = 16; 20 22 if (n < 0 || x.bitSize !== n) { 21 23 throw makeError( ··· 25 27 4, 26 28 "go", 27 29 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 27, end: 60, pattern_start: 38, pattern_end: 56 } 30 + { value: x, start: 31, end: 64, pattern_start: 42, pattern_end: 60 } 29 31 ) 30 32 } 31 33 let a = bitArraySlice(x, 0, n);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_dynamic_bytes_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 3\n let assert <<a:bytes-size(n)>> = x\n}\n" 3 + assertion_line: 1078 4 + expression: "\npub fn go(x) {\n let n = 3\n let assert <<a:bytes-size(n)>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 3 9 11 let assert <<a:bytes-size(n)>> = x 10 12 } ··· 15 17 16 18 const FILEPATH = "src/module.gleam"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 let n = 3; 20 22 if (n < 0 || x.bitSize !== n * 8) { 21 23 throw makeError( ··· 25 27 4, 26 28 "go", 27 29 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 26, end: 60, pattern_start: 37, pattern_end: 56 } 30 + { value: x, start: 30, end: 64, pattern_start: 41, pattern_end: 60 } 29 31 ) 30 32 } 31 33 let a = bitArraySlice(x, 0, n * 8);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_dynamic_size.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 16\n let assert <<a:size(n)>> = x\n}\n" 3 + assertion_line: 939 4 + expression: "\npub fn go(x) {\n let n = 16\n let assert <<a:size(n)>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 16 9 11 let assert <<a:size(n)>> = x 10 12 } ··· 15 17 16 18 const FILEPATH = "src/module.gleam"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 let n = 16; 20 22 if (n < 0 || x.bitSize !== n) { 21 23 throw makeError( ··· 25 27 4, 26 28 "go", 27 29 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 27, end: 55, pattern_start: 38, pattern_end: 51 } 30 + { value: x, start: 31, end: 59, pattern_start: 42, pattern_end: 55 } 29 31 ) 30 32 } 31 33 let a = bitArraySliceToInt(x, 0, n, true, false);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_dynamic_size_literal_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 8\n let assert <<a:size(n), 0b010101:size(8)>> = x\n}\n" 3 + assertion_line: 1024 4 + expression: "\npub fn go(x) {\n let n = 8\n let assert <<a:size(n), 0b010101:size(8)>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 8 9 11 let assert <<a:size(n), 0b010101:size(8)>> = x 10 12 } ··· 15 17 16 18 const FILEPATH = "src/module.gleam"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 let n = 8; 20 22 if ( 21 23 n < 0 || ··· 29 31 4, 30 32 "go", 31 33 "Pattern match failed, no pattern matched the value.", 32 - { value: x, start: 26, end: 72, pattern_start: 37, pattern_end: 68 } 34 + { value: x, start: 30, end: 76, pattern_start: 41, pattern_end: 72 } 33 35 ) 34 36 } 35 37 let a = bitArraySliceToInt(x, 0, n, true, false);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_dynamic_size_shadowed_variable.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 16\n let n = 5\n let assert <<a:size(n)>> = x\n}\n" 3 + assertion_line: 995 4 + expression: "\npub fn go(x) {\n let n = 16\n let n = 5\n let assert <<a:size(n)>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 16 9 11 let n = 5 10 12 let assert <<a:size(n)>> = x ··· 16 18 17 19 const FILEPATH = "src/module.gleam"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let n = 16; 21 23 let n$1 = 5; 22 24 if (n$1 < 0 || x.bitSize !== n$1) { ··· 27 29 5, 28 30 "go", 29 31 "Pattern match failed, no pattern matched the value.", 30 - { value: x, start: 39, end: 67, pattern_start: 50, pattern_end: 63 } 32 + { value: x, start: 43, end: 71, pattern_start: 54, pattern_end: 67 } 31 33 ) 32 34 } 33 35 let a = bitArraySliceToInt(x, 0, n$1, true, false);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_dynamic_size_with_other_segments.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 16\n let m = 32\n let assert <<first:size(8), a:size(n), b:size(m), rest:bits>> = x\n}\n" 3 + assertion_line: 966 4 + expression: "\npub fn go(x) {\n let n = 16\n let m = 32\n let assert <<first:size(8), a:size(n), b:size(m), rest:bits>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 16 9 11 let m = 32 10 12 let assert <<first:size(8), a:size(n), b:size(m), rest:bits>> = x ··· 16 18 17 19 const FILEPATH = "src/module.gleam"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let n = 16; 21 23 let m = 32; 22 24 if (x.bitSize < 8 + m + n || n < 0 || m < 0) { ··· 27 29 5, 28 30 "go", 29 31 "Pattern match failed, no pattern matched the value.", 30 - { value: x, start: 40, end: 105, pattern_start: 51, pattern_end: 101 } 32 + { value: x, start: 44, end: 109, pattern_start: 55, pattern_end: 105 } 31 33 ) 32 34 } 33 35 let first = x.byteAt(0);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_float.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let assert <<a:float, b:int>> = x\n}\n" 3 + assertion_line: 1185 4 + expression: "\npub fn go(x) {\n let assert <<a:float, b:int>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let assert <<a:float, b:int>> = x 9 11 } 10 12 ··· 14 16 15 17 const FILEPATH = "src/module.gleam"; 16 18 17 - function go(x) { 19 + export function go(x) { 18 20 if (x.bitSize !== 72 || !Number.isFinite(bitArraySliceToFloat(x, 0, 64, true))) { 19 21 throw makeError( 20 22 "let_assert", ··· 23 25 3, 24 26 "go", 25 27 "Pattern match failed, no pattern matched the value.", 26 - { value: x, start: 14, end: 47, pattern_start: 25, pattern_end: 43 } 28 + { value: x, start: 18, end: 51, pattern_start: 29, pattern_end: 47 } 27 29 ) 28 30 } 29 31 let a = bitArraySliceToFloat(x, 0, 64, true);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_float_16_bit.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let assert <<a:float-size(16)>> = x\n}\n" 3 + assertion_line: 1412 4 + expression: "\npub fn go(x) {\n let assert <<a:float-size(16)>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let assert <<a:float-size(16)>> = x 9 11 } 10 12 ··· 14 16 15 17 const FILEPATH = "src/module.gleam"; 16 18 17 - function go(x) { 19 + export function go(x) { 18 20 if (x.bitSize !== 16 || !Number.isFinite(bitArraySliceToFloat(x, 0, 16, true))) { 19 21 throw makeError( 20 22 "let_assert", ··· 23 25 3, 24 26 "go", 25 27 "Pattern match failed, no pattern matched the value.", 26 - { value: x, start: 14, end: 49, pattern_start: 25, pattern_end: 45 } 28 + { value: x, start: 18, end: 53, pattern_start: 29, pattern_end: 49 } 27 29 ) 28 30 } 29 31 let a = bitArraySliceToFloat(x, 0, 16, true);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_float_big_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let assert <<a:float-big, b:int>> = x\n}\n" 3 + assertion_line: 1210 4 + expression: "\npub fn go(x) {\n let assert <<a:float-big, b:int>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let assert <<a:float-big, b:int>> = x 9 11 } 10 12 ··· 14 16 15 17 const FILEPATH = "src/module.gleam"; 16 18 17 - function go(x) { 19 + export function go(x) { 18 20 if (x.bitSize !== 72 || !Number.isFinite(bitArraySliceToFloat(x, 0, 64, true))) { 19 21 throw makeError( 20 22 "let_assert", ··· 23 25 3, 24 26 "go", 25 27 "Pattern match failed, no pattern matched the value.", 26 - { value: x, start: 14, end: 51, pattern_start: 25, pattern_end: 47 } 28 + { value: x, start: 18, end: 55, pattern_start: 29, pattern_end: 51 } 27 29 ) 28 30 } 29 31 let a = bitArraySliceToFloat(x, 0, 64, true);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_float_little_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let assert <<a:float-little, b:int>> = x\n}\n" 3 + assertion_line: 1235 4 + expression: "\npub fn go(x) {\n let assert <<a:float-little, b:int>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let assert <<a:float-little, b:int>> = x 9 11 } 10 12 ··· 14 16 15 17 const FILEPATH = "src/module.gleam"; 16 18 17 - function go(x) { 19 + export function go(x) { 18 20 if ( 19 21 x.bitSize !== 72 || 20 22 !Number.isFinite(bitArraySliceToFloat(x, 0, 64, false)) ··· 26 28 3, 27 29 "go", 28 30 "Pattern match failed, no pattern matched the value.", 29 - { value: x, start: 14, end: 54, pattern_start: 25, pattern_end: 50 } 31 + { value: x, start: 18, end: 58, pattern_start: 29, pattern_end: 54 } 30 32 ) 31 33 } 32 34 let a = bitArraySliceToFloat(x, 0, 64, false);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_float_sized.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let assert <<a:float-32, b:int>> = x\n}\n" 3 + assertion_line: 1260 4 + expression: "\npub fn go(x) {\n let assert <<a:float-32, b:int>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let assert <<a:float-32, b:int>> = x 9 11 } 10 12 ··· 14 16 15 17 const FILEPATH = "src/module.gleam"; 16 18 17 - function go(x) { 19 + export function go(x) { 18 20 if (x.bitSize !== 40 || !Number.isFinite(bitArraySliceToFloat(x, 0, 32, true))) { 19 21 throw makeError( 20 22 "let_assert", ··· 23 25 3, 24 26 "go", 25 27 "Pattern match failed, no pattern matched the value.", 26 - { value: x, start: 14, end: 50, pattern_start: 25, pattern_end: 46 } 28 + { value: x, start: 18, end: 54, pattern_start: 29, pattern_end: 50 } 27 29 ) 28 30 } 29 31 let a = bitArraySliceToFloat(x, 0, 32, true);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_float_sized_big_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let assert <<a:float-32-big, b:int>> = x\n}\n" 3 + assertion_line: 1285 4 + expression: "\npub fn go(x) {\n let assert <<a:float-32-big, b:int>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let assert <<a:float-32-big, b:int>> = x 9 11 } 10 12 ··· 14 16 15 17 const FILEPATH = "src/module.gleam"; 16 18 17 - function go(x) { 19 + export function go(x) { 18 20 if (x.bitSize !== 40 || !Number.isFinite(bitArraySliceToFloat(x, 0, 32, true))) { 19 21 throw makeError( 20 22 "let_assert", ··· 23 25 3, 24 26 "go", 25 27 "Pattern match failed, no pattern matched the value.", 26 - { value: x, start: 14, end: 54, pattern_start: 25, pattern_end: 50 } 28 + { value: x, start: 18, end: 58, pattern_start: 29, pattern_end: 54 } 27 29 ) 28 30 } 29 31 let a = bitArraySliceToFloat(x, 0, 32, true);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_float_sized_little_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let assert <<a:float-32-little, b:int>> = x\n}\n" 3 + assertion_line: 1310 4 + expression: "\npub fn go(x) {\n let assert <<a:float-32-little, b:int>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let assert <<a:float-32-little, b:int>> = x 9 11 } 10 12 ··· 14 16 15 17 const FILEPATH = "src/module.gleam"; 16 18 17 - function go(x) { 19 + export function go(x) { 18 20 if ( 19 21 x.bitSize !== 40 || 20 22 !Number.isFinite(bitArraySliceToFloat(x, 0, 32, false)) ··· 26 28 3, 27 29 "go", 28 30 "Pattern match failed, no pattern matched the value.", 29 - { value: x, start: 14, end: 57, pattern_start: 25, pattern_end: 53 } 31 + { value: x, start: 18, end: 61, pattern_start: 29, pattern_end: 57 } 30 32 ) 31 33 } 32 34 let a = bitArraySliceToFloat(x, 0, 32, false);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_literal_aligned_float.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1387 4 - expression: "\nfn go(x) {\n let assert <<_, 1.1, _:bits>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<_, 1.1, _:bits>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<_, 1.1, _:bits>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize < 72 || bitArraySliceToFloat(x, 8, 72, true) !== 1.1) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 47, pattern_start: 25, pattern_end: 43 } 28 + { value: x, start: 18, end: 51, pattern_start: 29, pattern_end: 47 } 29 29 ) 30 30 } 31 31 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_literal_float.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1335 4 - expression: "\nfn go(x) {\n let assert <<1.4, b:int>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<1.4, b:int>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<1.4, b:int>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 72 || bitArraySliceToFloat(x, 0, 64, true) !== 1.4) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 43, pattern_start: 25, pattern_end: 39 } 28 + { value: x, start: 18, end: 47, pattern_start: 29, pattern_end: 43 } 29 29 ) 30 30 } 31 31 let b = x.byteAt(8);
+6 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_literal_unaligned_float.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 1\n let assert <<_:size(n), 1.1, _:bits>> = x\n}\n" 3 + assertion_line: 1360 4 + expression: "\npub fn go(x) {\n let n = 1\n let assert <<_:size(n), 1.1, _:bits>> = x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 1 9 11 let assert <<_:size(n), 1.1, _:bits>> = x 10 12 } ··· 15 17 16 18 const FILEPATH = "src/module.gleam"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 let n = 1; 20 22 if ( 21 23 n < 0 || ··· 29 31 4, 30 32 "go", 31 33 "Pattern match failed, no pattern matched the value.", 32 - { value: x, start: 26, end: 67, pattern_start: 37, pattern_end: 63 } 34 + { value: x, start: 30, end: 71, pattern_start: 41, pattern_end: 67 } 33 35 ) 34 36 } 35 37 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_rest.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1437 4 - expression: "\nfn go(x) {\n let assert <<_, b:bytes>> = <<1,2,3>>\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<_, b:bytes>> = <<1,2,3>>\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<_, b:bytes>> = <<1,2,3>> 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 let $ = toBitArray([1, 2, 3]); 21 21 if ($.bitSize < 8 || ($.bitSize - 8) % 8 !== 0) { 22 22 throw makeError( ··· 26 26 3, 27 27 "go", 28 28 "Pattern match failed, no pattern matched the value.", 29 - { value: $, start: 14, end: 51, pattern_start: 25, pattern_end: 39 } 29 + { value: $, start: 18, end: 55, pattern_start: 29, pattern_end: 43 } 30 30 ) 31 31 } 32 32 let b = bitArraySlice($, 8);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_rest_bits.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1537 4 - expression: "\nfn go(x) {\n let assert <<_, b:bits>> = <<1,2,3>>\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<_, b:bits>> = <<1,2,3>>\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<_, b:bits>> = <<1,2,3>> 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 let $ = toBitArray([1, 2, 3]); 21 21 if ($.bitSize < 8) { 22 22 throw makeError( ··· 26 26 3, 27 27 "go", 28 28 "Pattern match failed, no pattern matched the value.", 29 - { value: $, start: 14, end: 50, pattern_start: 25, pattern_end: 38 } 29 + { value: $, start: 18, end: 54, pattern_start: 29, pattern_end: 42 } 30 30 ) 31 31 } 32 32 let b = bitArraySlice($, 8);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_rest_bits_unaligned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1562 4 - expression: "\nfn go(x) {\n let assert <<_:5, b:bits>> = <<1,2,3>>\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<_:5, b:bits>> = <<1,2,3>>\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<_:5, b:bits>> = <<1,2,3>> 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 let $ = toBitArray([1, 2, 3]); 21 21 if ($.bitSize < 5) { 22 22 throw makeError( ··· 26 26 3, 27 27 "go", 28 28 "Pattern match failed, no pattern matched the value.", 29 - { value: $, start: 14, end: 52, pattern_start: 25, pattern_end: 40 } 29 + { value: $, start: 18, end: 56, pattern_start: 29, pattern_end: 44 } 30 30 ) 31 31 } 32 32 let b = bitArraySlice($, 5);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_rest_bytes.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1512 4 - expression: "\nfn go(x) {\n let assert <<_, b:bytes>> = <<1,2,3>>\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<_, b:bytes>> = <<1,2,3>>\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<_, b:bytes>> = <<1,2,3>> 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 let $ = toBitArray([1, 2, 3]); 21 21 if ($.bitSize < 8 || ($.bitSize - 8) % 8 !== 0) { 22 22 throw makeError( ··· 26 26 3, 27 27 "go", 28 28 "Pattern match failed, no pattern matched the value.", 29 - { value: $, start: 14, end: 51, pattern_start: 25, pattern_end: 39 } 29 + { value: $, start: 18, end: 55, pattern_start: 29, pattern_end: 43 } 30 30 ) 31 31 } 32 32 let b = bitArraySlice($, 8);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_signed.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 589 4 - expression: "\nfn go(x) {\n let assert <<a:signed>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<a:signed>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<a:signed>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 8) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 41, pattern_start: 25, pattern_end: 37 } 28 + { value: x, start: 18, end: 45, pattern_start: 29, pattern_end: 41 } 29 29 ) 30 30 } 31 31 let a = bitArraySliceToInt(x, 0, 8, true, true);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_signed_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 614 4 - expression: "\nfn go(x) {\n let assert <<-1:signed>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<-1:signed>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<-1:signed>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 8 || x.byteAt(0) !== 255) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 42, pattern_start: 25, pattern_end: 38 } 28 + { value: x, start: 18, end: 46, pattern_start: 29, pattern_end: 42 } 29 29 ) 30 30 } 31 31 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 464 4 - expression: "\nfn go(x) {\n let assert <<a:16, b:8>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<a:16, b:8>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<a:16, b:8>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 24) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 42, pattern_start: 25, pattern_end: 38 } 28 + { value: x, start: 18, end: 46, pattern_start: 29, pattern_end: 42 } 29 29 ) 30 30 } 31 31 let a = bitArraySliceToInt(x, 0, 16, true, false);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_big_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 639 4 - expression: "\nfn go(x) {\n let assert <<a:16-big>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<a:16-big>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<a:16-big>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 41, pattern_start: 25, pattern_end: 37 } 28 + { value: x, start: 18, end: 45, pattern_start: 29, pattern_end: 41 } 29 29 ) 30 30 } 31 31 let a = bitArraySliceToInt(x, 0, 16, true, false);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_big_endian_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 664 4 - expression: "\nfn go(x) {\n let assert <<1234:16-big>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<1234:16-big>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<1234:16-big>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16 || x.byteAt(0) !== 4 || x.byteAt(1) !== 210) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 44, pattern_start: 25, pattern_end: 40 } 28 + { value: x, start: 18, end: 48, pattern_start: 29, pattern_end: 44 } 29 29 ) 30 30 } 31 31 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_big_endian_signed.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 789 4 - expression: "\nfn go(x) {\n let assert <<a:16-big-signed>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<a:16-big-signed>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<a:16-big-signed>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 48, pattern_start: 25, pattern_end: 44 } 28 + { value: x, start: 18, end: 52, pattern_start: 29, pattern_end: 48 } 29 29 ) 30 30 } 31 31 let a = bitArraySliceToInt(x, 0, 16, true, true);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_big_endian_signed_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 814 4 - expression: "\nfn go(x) {\n let assert <<1234:16-big-signed>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<1234:16-big-signed>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<1234:16-big-signed>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16 || x.byteAt(0) !== 4 || x.byteAt(1) !== 210) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 51, pattern_start: 25, pattern_end: 47 } 28 + { value: x, start: 18, end: 55, pattern_start: 29, pattern_end: 51 } 29 29 ) 30 30 } 31 31 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_big_endian_unsigned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 739 4 - expression: "\nfn go(x) {\n let assert <<a:16-big-unsigned>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<a:16-big-unsigned>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<a:16-big-unsigned>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 50, pattern_start: 25, pattern_end: 46 } 28 + { value: x, start: 18, end: 54, pattern_start: 29, pattern_end: 50 } 29 29 ) 30 30 } 31 31 let a = bitArraySliceToInt(x, 0, 16, true, false);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_big_endian_unsigned_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 764 4 - expression: "\nfn go(x) {\n let assert <<1234:16-big-unsigned>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<1234:16-big-unsigned>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<1234:16-big-unsigned>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16 || x.byteAt(0) !== 4 || x.byteAt(1) !== 210) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 53, pattern_start: 25, pattern_end: 49 } 28 + { value: x, start: 18, end: 57, pattern_start: 29, pattern_end: 53 } 29 29 ) 30 30 } 31 31 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 514 4 - expression: "\nfn go(x) {\n let assert <<1234:16, 123:8>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<1234:16, 123:8>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<1234:16, 123:8>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if ( 21 21 x.bitSize !== 24 || 22 22 x.byteAt(0) !== 4 || x.byteAt(1) !== 210 || ··· 29 29 3, 30 30 "go", 31 31 "Pattern match failed, no pattern matched the value.", 32 - { value: x, start: 14, end: 47, pattern_start: 25, pattern_end: 43 } 32 + { value: x, start: 18, end: 51, pattern_start: 29, pattern_end: 47 } 33 33 ) 34 34 } 35 35 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_little_endian.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 689 4 - expression: "\nfn go(x) {\n let assert <<a:16-little>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<a:16-little>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<a:16-little>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 44, pattern_start: 25, pattern_end: 40 } 28 + { value: x, start: 18, end: 48, pattern_start: 29, pattern_end: 44 } 29 29 ) 30 30 } 31 31 let a = bitArraySliceToInt(x, 0, 16, false, false);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_little_endian_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 714 4 - expression: "\nfn go(x) {\n let assert <<1234:16-little>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<1234:16-little>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<1234:16-little>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16 || x.byteAt(0) !== 210 || x.byteAt(1) !== 4) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 47, pattern_start: 25, pattern_end: 43 } 28 + { value: x, start: 18, end: 51, pattern_start: 29, pattern_end: 47 } 29 29 ) 30 30 } 31 31 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_little_endian_signed.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 889 4 - expression: "\nfn go(x) {\n let assert <<a:16-little-signed>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<a:16-little-signed>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<a:16-little-signed>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 51, pattern_start: 25, pattern_end: 47 } 28 + { value: x, start: 18, end: 55, pattern_start: 29, pattern_end: 51 } 29 29 ) 30 30 } 31 31 let a = bitArraySliceToInt(x, 0, 16, false, true);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_little_endian_signed_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 914 4 - expression: "\nfn go(x) {\n let assert <<1234:16-little-signed>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<1234:16-little-signed>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<1234:16-little-signed>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16 || x.byteAt(0) !== 210 || x.byteAt(1) !== 4) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 54, pattern_start: 25, pattern_end: 50 } 28 + { value: x, start: 18, end: 58, pattern_start: 29, pattern_end: 54 } 29 29 ) 30 30 } 31 31 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_little_endian_unsigned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 839 4 - expression: "\nfn go(x) {\n let assert <<a:16-little-unsigned>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<a:16-little-unsigned>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<a:16-little-unsigned>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 53, pattern_start: 25, pattern_end: 49 } 28 + { value: x, start: 18, end: 57, pattern_start: 29, pattern_end: 53 } 29 29 ) 30 30 } 31 31 let a = bitArraySliceToInt(x, 0, 16, false, false);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_little_endian_unsigned_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 864 4 - expression: "\nfn go(x) {\n let assert <<1234:16-little-unsigned>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<1234:16-little-unsigned>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<1234:16-little-unsigned>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16 || x.byteAt(0) !== 210 || x.byteAt(1) !== 4) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 56, pattern_start: 25, pattern_end: 52 } 28 + { value: x, start: 18, end: 60, pattern_start: 29, pattern_end: 56 } 29 29 ) 30 30 } 31 31 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_unaligned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 489 4 - expression: "\nfn go(x) {\n let assert <<a:17, b:7>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<a:17, b:7>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<a:17, b:7>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 24) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 42, pattern_start: 25, pattern_end: 38 } 28 + { value: x, start: 18, end: 46, pattern_start: 29, pattern_end: 42 } 29 29 ) 30 30 } 31 31 let a = bitArraySliceToInt(x, 0, 17, true, false);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1135 4 - expression: "\nfn go(x) {\n let assert <<i:16>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<i:16>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<i:16>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 37, pattern_start: 25, pattern_end: 33 } 28 + { value: x, start: 18, end: 41, pattern_start: 29, pattern_end: 37 } 29 29 ) 30 30 } 31 31 let i = bitArraySliceToInt(x, 0, 16, true, false);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_sized_value_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1160 4 - expression: "\nfn go(x) {\n let assert <<258:16>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<258:16>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<258:16>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 16 || x.byteAt(0) !== 1 || x.byteAt(1) !== 2) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 39, pattern_start: 25, pattern_end: 35 } 28 + { value: x, start: 18, end: 43, pattern_start: 29, pattern_end: 39 } 29 29 ) 30 30 } 31 31 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_unsigned.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 539 4 - expression: "\nfn go(x) {\n let assert <<a:unsigned>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<a:unsigned>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<a:unsigned>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 8) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 43, pattern_start: 25, pattern_end: 39 } 28 + { value: x, start: 18, end: 47, pattern_start: 29, pattern_end: 43 } 29 29 ) 30 30 } 31 31 let a = x.byteAt(0);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_unsigned_constant_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 564 4 - expression: "\nfn go(x) {\n let assert <<-2:unsigned>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<-2:unsigned>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<-2:unsigned>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x.bitSize !== 8 || x.byteAt(0) !== 254) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 44, pattern_start: 25, pattern_end: 40 } 28 + { value: x, start: 18, end: 48, pattern_start: 29, pattern_end: 44 } 29 29 ) 30 30 } 31 31 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_utf8.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 286 4 - expression: "\nfn go(x) {\n let assert <<\"Gleam 👍\":utf8>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<\"Gleam 👍\":utf8>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<"Gleam 👍":utf8>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if ( 21 21 x.bitSize !== 80 || 22 22 x.byteAt(0) !== 71 || ··· 37 37 3, 38 38 "go", 39 39 "Pattern match failed, no pattern matched the value.", 40 - { value: x, start: 14, end: 50, pattern_start: 25, pattern_end: 46 } 40 + { value: x, start: 18, end: 54, pattern_start: 29, pattern_end: 50 } 41 41 ) 42 42 } 43 43 return x;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__match_utf8_with_escape_chars.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 275 4 - expression: "\nfn go(x) {\n let assert <<\"\\\"\\\\\\r\\n\\t\\f\\u{1f600}\">> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<\"\\\"\\\\\\r\\n\\t\\f\\u{1f600}\">> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<"\"\\\r\n\t\f\u{1f600}">> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if ( 21 21 x.bitSize !== 80 || 22 22 x.byteAt(0) !== 34 || ··· 37 37 3, 38 38 "go", 39 39 "Pattern match failed, no pattern matched the value.", 40 - { value: x, start: 14, end: 56, pattern_start: 25, pattern_end: 52 } 40 + { value: x, start: 18, end: 60, pattern_start: 29, pattern_end: 56 } 41 41 ) 42 42 } 43 43 return x;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__negative_size_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = -10\n case x {\n <<int:size(n)>> -> int\n _ -> 2\n }\n}\n" 3 + assertion_line: 1962 4 + expression: "\npub fn go(x) {\n let n = -10\n case x {\n <<int:size(n)>> -> int\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = -10 9 11 case x { 10 12 <<int:size(n)>> -> int ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySliceToInt } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let n = -10; 21 23 if (n >= 0 && x.bitSize === n) { 22 24 let int = bitArraySliceToInt(x, 0, n, true, false);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__negative_size_pattern_2.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<n:signed, int:size(n)>> -> int\n _ -> 2\n }\n}\n" 3 + assertion_line: 1977 4 + expression: "\npub fn go(x) {\n case x {\n <<n:signed, int:size(n)>> -> int\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<n:signed, int:size(n)>> -> int 10 12 _ -> 2 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize >= 8) { 20 22 let n = bitArraySliceToInt(x, 0, 8, true, true); 21 23 if (n >= 0 && x.bitSize === 8 + n) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__one.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<256>>\n}\n" 3 + assertion_line: 22 4 + expression: "\npub fn go() {\n <<256>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<256>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([0]); 17 19 }
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__pattern_with_unit.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 3 assertion_line: 1793 4 - expression: "\nfn go(x) {\n let assert <<1:size(2)-unit(2), 2:size(3)-unit(4)>> = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert <<1:size(2)-unit(2), 2:size(3)-unit(4)>> = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert <<1:size(2)-unit(2), 2:size(3)-unit(4)>> = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if ( 21 21 x.bitSize !== 16 || 22 22 bitArraySliceToInt(x, 0, 4, true, false) !== 1 || ··· 29 29 3, 30 30 "go", 31 31 "Pattern match failed, no pattern matched the value.", 32 - { value: x, start: 14, end: 69, pattern_start: 25, pattern_end: 65 } 32 + { value: x, start: 18, end: 73, pattern_start: 29, pattern_end: 69 } 33 33 ) 34 34 } 35 35 return x;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__segments_shadowing_each_other.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n let n = 1\n case x {\n <<n, rest:size(n)>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1947 4 + expression: "\npub fn go(x) {\n let n = 1\n case x {\n <<n, rest:size(n)>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let n = 1 9 11 case x { 10 12 <<n, rest:size(n)>> -> 1 ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { bitArraySliceToInt } from "../gleam.mjs"; 18 20 19 - function go(x) { 21 + export function go(x) { 20 22 let n = 1; 21 23 if (x.bitSize >= 8) { 22 24 let n$1 = x.byteAt(0);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__sized_big_endian_constant_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<256:16-big>>\n}\n" 3 + assertion_line: 176 4 + expression: "\npub fn go() {\n <<256:16-big>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<256:16-big>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([1, 0]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__sized_big_endian_dynamic_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(i: Int) {\n <<i:16-big>>\n}\n" 3 + assertion_line: 187 4 + expression: "\npub fn go(i: Int) {\n <<i:16-big>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(i: Int) { 9 + pub fn go(i: Int) { 8 10 <<i:16-big>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedInt } from "../gleam.mjs"; 14 16 15 - function go(i) { 17 + export function go(i) { 16 18 return toBitArray([sizedInt(i, 16, true)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__sized_constant_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<256:64>>\n}\n" 3 + assertion_line: 121 4 + expression: "\npub fn go() {\n <<256:64>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<256:64>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedInt } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([sizedInt(256, 64, true)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__sized_constant_value_max_size_for_compile_time_evaluation.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<-1:48>>\n}\n" 3 + assertion_line: 165 4 + expression: "\npub fn go() {\n <<-1:48>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<-1:48>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([255, 255, 255, 255, 255, 255]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__sized_constant_value_negative_overflow.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<-80_000:16>>\n}\n" 3 + assertion_line: 154 4 + expression: "\npub fn go() {\n <<-80_000:16>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<-80_000:16>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([199, 128]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__sized_constant_value_positive_overflow.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<80_000:16>>\n}\n" 3 + assertion_line: 143 4 + expression: "\npub fn go() {\n <<80_000:16>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<80_000:16>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([56, 128]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__sized_dynamic_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(i: Int) {\n <<i:64>>\n}\n" 3 + assertion_line: 132 4 + expression: "\npub fn go(i: Int) {\n <<i:64>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(i: Int) { 9 + pub fn go(i: Int) { 8 10 <<i:64>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedInt } from "../gleam.mjs"; 14 16 15 - function go(i) { 17 + export function go(i) { 16 18 return toBitArray([sizedInt(i, 64, true)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__sized_little_endian_constant_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<256:16-little>>\n}\n" 3 + assertion_line: 198 4 + expression: "\npub fn go() {\n <<256:16-little>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<256:16-little>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([0, 1]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__sized_little_endian_dynamic_value.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(i: Int) {\n <<i:16-little>>\n}\n" 3 + assertion_line: 209 4 + expression: "\npub fn go(i: Int) {\n <<i:16-little>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(i: Int) { 9 + pub fn go(i: Int) { 8 10 <<i:16-little>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedInt } from "../gleam.mjs"; 14 16 15 - function go(i) { 17 + export function go(i) { 16 18 return toBitArray([sizedInt(i, 16, false)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__two.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go() {\n <<256, 4>>\n}\n" 3 + assertion_line: 33 4 + expression: "\npub fn go() {\n <<256, 4>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 <<256, 4>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return toBitArray([0, 4]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__utf8.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n <<256, 4, x, \"Gleam\":utf8>>\n}\n" 3 + assertion_line: 264 4 + expression: "\npub fn go(x) {\n <<256, 4, x, \"Gleam\":utf8>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 <<256, 4, x, "Gleam":utf8>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, stringBits } from "../gleam.mjs"; 14 16 15 - function go(x) { 17 + export function go(x) { 16 18 return toBitArray([0, 4, x, stringBits("Gleam")]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__utf8_codepoint.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n <<x:utf8_codepoint, \"Gleam\":utf8>>\n}\n" 3 + assertion_line: 325 4 + expression: "\npub fn go(x) {\n <<x:utf8_codepoint, \"Gleam\":utf8>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 <<x:utf8_codepoint, "Gleam":utf8>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, stringBits, codepointBits } from "../gleam.mjs"; 14 16 15 - function go(x) { 17 + export function go(x) { 16 18 return toBitArray([codepointBits(x), stringBits("Gleam")]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__variable.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n <<256, 4, x>>\n}\n" 3 + assertion_line: 253 4 + expression: "\npub fn go(x) {\n <<256, 4, x>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 <<256, 4, x>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray } from "../gleam.mjs"; 14 16 15 - function go(x) { 17 + export function go(x) { 16 18 return toBitArray([0, 4, x]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__variable_sized.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x, y) {\n <<x:size(y)>>\n}\n" 3 + assertion_line: 242 4 + expression: "\npub fn go(x, y) {\n <<x:size(y)>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x, y) { 9 + pub fn go(x, y) { 8 10 <<x:size(y)>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedInt } from "../gleam.mjs"; 14 16 15 - function go(x, y) { 17 + export function go(x, y) { 16 18 return toBitArray([sizedInt(x, y, true)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__variable_sized_segment.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn go(x) {\n case x {\n <<n, rest:size(n)>> -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 1933 4 + expression: "\npub fn go(x) {\n case x {\n <<n, rest:size(n)>> -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 <<n, rest:size(n)>> -> 1 10 12 _ -> 2 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { bitArraySliceToInt } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x.bitSize >= 8) { 20 22 let n = x.byteAt(0); 21 23 if (x.bitSize === 8 + n) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__with_unit.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bit_arrays.rs 3 - expression: "\nfn main() {\n <<1:size(2)-unit(2), 2:size(3)-unit(4)>>\n}\n" 3 + assertion_line: 1770 4 + expression: "\npub fn main() {\n <<1:size(2)-unit(2), 2:size(3)-unit(4)>>\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn main() { 9 + pub fn main() { 8 10 <<1:size(2)-unit(2), 2:size(3)-unit(4)>> 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toBitArray, sizedInt } from "../gleam.mjs"; 14 16 15 - function main() { 17 + export function main() { 16 18 return toBitArray([sizedInt(1, 4, true), sizedInt(2, 12, true)]); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__block.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn go() {\n let x = {\n 1\n 2\n }\n x\n}\n" 3 + assertion_line: 5 4 + expression: "\npub fn go() {\n let x = {\n 1\n 2\n }\n x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 let x = { 9 11 1 10 12 2 ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - function go() { 19 + export function go() { 18 20 let _block; 19 21 { 20 22 1;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__block_in_tail_position_is_not_an_iife.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn b() {\n let x = 1\n {\n Nil\n x + 1\n }\n}\n" 3 + assertion_line: 221 4 + expression: "\npub fn b() {\n let x = 1\n {\n Nil\n x + 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn b() { 9 + pub fn b() { 8 10 let x = 1 9 11 { 10 12 Nil ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - function b() { 19 + export function b() { 18 20 let x = 1; 19 21 { 20 22 undefined;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__block_in_tail_position_shadowing_variables.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn b() {\n let x = 1\n {\n let x = 2\n x + 1\n }\n}\n" 3 + assertion_line: 236 4 + expression: "\npub fn b() {\n let x = 1\n {\n let x = 2\n x + 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn b() { 9 + pub fn b() { 8 10 let x = 1 9 11 { 10 12 let x = 2 ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - function b() { 19 + export function b() { 18 20 let x = 1; 19 21 { 20 22 let x$1 = 2;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__block_in_tail_position_with_just_an_assignment.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn b() {\n let x = 1\n {\n let x = x\n }\n}\n" 3 + assertion_line: 251 4 + expression: "\npub fn b() {\n let x = 1\n {\n let x = x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn b() { 9 + pub fn b() { 8 10 let x = 1 9 11 { 10 12 let x = x ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function b() { 18 + export function b() { 17 19 let x = 1; 18 20 return x; 19 21 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__block_with_parenthesised_expression_returning_from_function.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn b() {\n {\n 1 + 2\n }\n}\n" 3 + assertion_line: 208 4 + expression: "\npub fn b() {\n {\n 1 + 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn b() { 9 + pub fn b() { 8 10 { 9 11 1 + 2 10 12 } ··· 12 14 13 15 14 16 ----- COMPILED JAVASCRIPT 15 - function b() { 17 + export function b() { 16 18 return 1 + 2; 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__blocks_returning_functions.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn b() {\n {\n fn(cb) { cb(1) }\n }\n {\n fn(cb) { cb(2) }\n }\n 3\n}\n" 3 + assertion_line: 172 4 + expression: "\npub fn b() {\n {\n fn(cb) { cb(1) }\n }\n {\n fn(cb) { cb(2) }\n }\n 3\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn b() { 9 + pub fn b() { 8 10 { 9 11 fn(cb) { cb(1) } 10 12 } ··· 16 18 17 19 18 20 ----- COMPILED JAVASCRIPT 19 - function b() { 21 + export function b() { 20 22 ((cb) => { return cb(1); }); 21 23 ((cb) => { return cb(2); }); 22 24 return 3;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__blocks_returning_use.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn b() {\n {\n use a <- fn(cb) { cb(1) }\n a\n }\n {\n use b <- fn(cb) { cb(2) }\n b\n }\n 3\n}\n " 3 + assertion_line: 189 4 + expression: "\npub fn b() {\n {\n use a <- fn(cb) { cb(1) }\n a\n }\n {\n use b <- fn(cb) { cb(2) }\n b\n }\n 3\n}\n " 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn b() { 9 + pub fn b() { 8 10 { 9 11 use a <- fn(cb) { cb(1) } 10 12 a ··· 18 20 19 21 20 22 ----- COMPILED JAVASCRIPT 21 - function b() { 23 + export function b() { 22 24 ((cb) => { return cb(1); })((a) => { return a; }); 23 25 ((cb) => { return cb(2); })((b) => { return b; }); 24 26 return 3;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__concat_blocks.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn main(f, a, b) {\n {\n a\n |> f\n } <> {\n b\n |> f\n }\n}\n" 3 + assertion_line: 155 4 + expression: "\npub fn main(f, a, b) {\n {\n a\n |> f\n } <> {\n b\n |> f\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn main(f, a, b) { 9 + pub fn main(f, a, b) { 8 10 { 9 11 a 10 12 |> f ··· 16 18 17 19 18 20 ----- COMPILED JAVASCRIPT 19 - function main(f, a, b) { 21 + export function main(f, a, b) { 20 22 return (() => { 21 23 let _pipe = a; 22 24 return f(_pipe);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__left_operator_sequence.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn go() {\n 1 == {\n 1\n 2\n }\n}\n" 3 + assertion_line: 127 4 + expression: "\npub fn go() {\n 1 == {\n 1\n 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 1 == { 9 11 1 10 12 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go() { 18 + export function go() { 17 19 return 1 === (() => { 18 20 1; 19 21 return 2;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__nested_multiexpr_blocks.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn go() {\n let x = {\n 1\n {\n 2\n 3\n }\n }\n x\n}\n" 3 + assertion_line: 36 4 + expression: "\npub fn go() {\n let x = {\n 1\n {\n 2\n 3\n }\n }\n x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 let x = { 9 11 1 10 12 { ··· 17 19 18 20 19 21 ----- COMPILED JAVASCRIPT 20 - function go() { 22 + export function go() { 21 23 let _block; 22 24 { 23 25 1;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__nested_multiexpr_blocks_with_case.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn go() {\n let x = {\n 1\n {\n 2\n case True {\n _ -> 3\n }\n }\n }\n x\n}\n" 3 + assertion_line: 94 4 + expression: "\npub fn go() {\n let x = {\n 1\n {\n 2\n case True {\n _ -> 3\n }\n }\n }\n x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 let x = { 9 11 1 10 12 { ··· 19 21 20 22 21 23 ----- COMPILED JAVASCRIPT 22 - function go() { 24 + export function go() { 23 25 let _block; 24 26 { 25 27 1;
+7 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__nested_multiexpr_blocks_with_pipe.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn add1(a) {\n a + 1\n}\nfn go() {\n let x = {\n 1\n {\n 2\n 3 |> add1\n } |> add1\n }\n x\n}\n" 3 + assertion_line: 54 4 + expression: "\npub fn add1(a) {\n a + 1\n}\npub fn go() {\n let x = {\n 1\n {\n 2\n 3 |> add1\n } |> add1\n }\n x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn add1(a) { 9 + pub fn add1(a) { 8 10 a + 1 9 11 } 10 - fn go() { 12 + pub fn go() { 11 13 let x = { 12 14 1 13 15 { ··· 20 22 21 23 22 24 ----- COMPILED JAVASCRIPT 23 - function add1(a) { 25 + export function add1(a) { 24 26 return a + 1; 25 27 } 26 28 27 - function go() { 29 + export function go() { 28 30 let _block; 29 31 { 30 32 1;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__nested_multiexpr_non_ending_blocks.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn go() {\n let x = {\n 1\n {\n 2\n 3\n }\n 4\n }\n x\n}\n" 3 + assertion_line: 75 4 + expression: "\npub fn go() {\n let x = {\n 1\n {\n 2\n 3\n }\n 4\n }\n x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 let x = { 9 11 1 10 12 { ··· 18 20 19 21 20 22 ----- COMPILED JAVASCRIPT 21 - function go() { 23 + export function go() { 22 24 let _block; 23 25 { 24 26 1;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__nested_simple_blocks.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn go() {\n let x = {\n {\n 3\n }\n }\n x\n}\n" 3 + assertion_line: 20 4 + expression: "\npub fn go() {\n let x = {\n {\n 3\n }\n }\n x\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 let x = { 9 11 { 10 12 3 ··· 15 17 16 18 17 19 ----- COMPILED JAVASCRIPT 18 - function go() { 20 + export function go() { 19 21 let x = 3; 20 22 return x; 21 23 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__right_operator_sequence.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn go() {\n {\n 1\n 2\n } == 1\n}\n" 3 + assertion_line: 141 4 + expression: "\npub fn go() {\n {\n 1\n 2\n } == 1\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 { 9 11 1 10 12 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go() { 18 + export function go() { 17 19 return (() => { 18 20 1; 19 21 return 2;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__blocks__sequences.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/blocks.rs 3 - expression: "\nfn go() {\n \"one\"\n \"two\"\n \"three\"\n}\n" 3 + assertion_line: 114 4 + expression: "\npub fn go() {\n \"one\"\n \"two\"\n \"three\"\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 "one" 9 11 "two" 10 12 "three" ··· 12 14 13 15 14 16 ----- COMPILED JAVASCRIPT 15 - function go() { 17 + export function go() { 16 18 "one"; 17 19 "two"; 18 20 return "three";
+5 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bools__assigning.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bools.rs 3 3 assertion_line: 52 4 - expression: "\nfn go(x, y) {\n let assert True = x\n let assert False = x\n let assert Nil = y\n}\n" 4 + expression: "\npub fn go(x, y) {\n let assert True = x\n let assert False = x\n let assert Nil = y\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x, y) { 9 + pub fn go(x, y) { 10 10 let assert True = x 11 11 let assert False = x 12 12 let assert Nil = y ··· 18 18 19 19 const FILEPATH = "src/module.gleam"; 20 20 21 - function go(x, y) { 21 + export function go(x, y) { 22 22 if (!x) { 23 23 throw makeError( 24 24 "let_assert", ··· 27 27 3, 28 28 "go", 29 29 "Pattern match failed, no pattern matched the value.", 30 - { value: x, start: 17, end: 36, pattern_start: 28, pattern_end: 32 } 30 + { value: x, start: 21, end: 40, pattern_start: 32, pattern_end: 36 } 31 31 ) 32 32 } 33 33 throw makeError( ··· 37 37 4, 38 38 "go", 39 39 "Pattern match failed, no pattern matched the value.", 40 - { value: x, start: 39, end: 59, pattern_start: 50, pattern_end: 55 } 40 + { value: x, start: 43, end: 63, pattern_start: 54, pattern_end: 59 } 41 41 ) 42 42 43 43 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bools__case.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bools.rs 3 - expression: "\nfn go(a) {\n case a {\n True -> 1\n False -> 0\n }\n}\n" 3 + assertion_line: 114 4 + expression: "\npub fn go(a) {\n case a {\n True -> 1\n False -> 0\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(a) { 9 + pub fn go(a) { 8 10 case a { 9 11 True -> 1 10 12 False -> 0 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(a) { 18 + export function go(a) { 17 19 if (a) { 18 20 return 1; 19 21 } else {
+9 -7
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bools__constants.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bools.rs 3 - expression: "\nconst a = True\nconst b = False\nconst c = Nil\n" 3 + assertion_line: 18 4 + expression: "\npub const a = True\npub const b = False\npub const c = Nil\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - const a = True 8 - const b = False 9 - const c = Nil 9 + pub const a = True 10 + pub const b = False 11 + pub const c = Nil 10 12 11 13 12 14 ----- COMPILED JAVASCRIPT 13 - const a = true; 15 + export const a = true; 14 16 15 - const b = false; 17 + export const b = false; 16 18 17 - const c = undefined; 19 + export const c = undefined;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bools__equality.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bools.rs 3 - expression: "\nfn go(a, b) {\n a == True\n a != True\n a == False\n a != False\n a == a\n a != a\n b == Nil\n b != Nil\n b == b\n}\n" 3 + assertion_line: 95 4 + expression: "\npub fn go(a, b) {\n a == True\n a != True\n a == False\n a != False\n a == a\n a != a\n b == Nil\n b != Nil\n b == b\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(a, b) { 9 + pub fn go(a, b) { 8 10 a == True 9 11 a != True 10 12 a == False ··· 18 20 19 21 20 22 ----- COMPILED JAVASCRIPT 21 - function go(a, b) { 23 + export function go(a, b) { 22 24 a === true; 23 25 a !== true; 24 26 a === false;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bools__expressions.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bools.rs 3 - expression: "\nfn go() {\n True\n False\n Nil\n}\n" 3 + assertion_line: 5 4 + expression: "\npub fn go() {\n True\n False\n Nil\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 True 9 11 False 10 12 Nil ··· 12 14 13 15 14 16 ----- COMPILED JAVASCRIPT 15 - function go() { 17 + export function go() { 16 18 true; 17 19 false; 18 20 return undefined;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bools__nil_case.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bools.rs 3 - expression: "\nfn go(a) {\n case a {\n Nil -> 0\n }\n}\n" 3 + assertion_line: 128 4 + expression: "\npub fn go(a) {\n case a {\n Nil -> 0\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(a) { 9 + pub fn go(a) { 8 10 case a { 9 11 Nil -> 0 10 12 } ··· 12 14 13 15 14 16 ----- COMPILED JAVASCRIPT 15 - function go(a) { 17 + export function go(a) { 16 18 return 0; 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bools__operators.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bools.rs 3 - expression: "\nfn go() {\n True && True\n False || False\n}\n" 3 + assertion_line: 40 4 + expression: "\npub fn go() {\n True && True\n False || False\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 True && True 9 11 False || False 10 12 } 11 13 12 14 13 15 ----- COMPILED JAVASCRIPT 14 - function go() { 16 + export function go() { 15 17 true && true; 16 18 return false || false; 17 19 }
+5 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bools__shadowed_bools_and_nil.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/bools.rs 3 3 assertion_line: 67 4 - expression: "\npub type True { True False Nil }\nfn go(x, y) {\n let assert True = x\n let assert False = x\n let assert Nil = y\n}\n" 4 + expression: "\npub type True { True False Nil }\npub fn go(x, y) {\n let assert True = x\n let assert False = x\n let assert Nil = y\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 9 pub type True { True False Nil } 10 - fn go(x, y) { 10 + pub fn go(x, y) { 11 11 let assert True = x 12 12 let assert False = x 13 13 let assert Nil = y ··· 25 25 26 26 export class Nil extends $CustomType {} 27 27 28 - function go(x, y) { 28 + export function go(x, y) { 29 29 if (!(x instanceof True)) { 30 30 throw makeError( 31 31 "let_assert", ··· 34 34 4, 35 35 "go", 36 36 "Pattern match failed, no pattern matched the value.", 37 - { value: x, start: 50, end: 69, pattern_start: 61, pattern_end: 65 } 37 + { value: x, start: 54, end: 73, pattern_start: 65, pattern_end: 69 } 38 38 ) 39 39 } 40 40 throw makeError( ··· 44 44 5, 45 45 "go", 46 46 "Pattern match failed, no pattern matched the value.", 47 - { value: x, start: 72, end: 92, pattern_start: 83, pattern_end: 88 } 47 + { value: x, start: 76, end: 96, pattern_start: 87, pattern_end: 92 } 48 48 ) 49 49 50 50 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__assignment.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x) {\n let y = case x {\n True -> 1\n _ -> 0\n }\n y\n}\n" 3 + assertion_line: 152 4 + expression: "\npub fn go(x) {\n let y = case x {\n True -> 1\n _ -> 0\n }\n y\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let y = case x { 9 11 True -> 1 10 12 _ -> 0 ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - function go(x) { 19 + export function go(x) { 18 20 let _block; 19 21 if (x) { 20 22 _block = 1;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__called_case.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x, y) {\n case x {\n 0 -> y\n _ -> y\n }()\n}\n" 3 + assertion_line: 212 4 + expression: "\npub fn go(x, y) {\n case x {\n 0 -> y\n _ -> y\n }()\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x, y) { 9 + pub fn go(x, y) { 8 10 case x { 9 11 0 -> y 10 12 _ -> y ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x, y) { 18 + export function go(x, y) { 17 19 let _block; 18 20 if (x === 0) { 19 21 _block = y;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_branches_guards_are_wrapped_in_parentheses.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn anything() -> a {\n case [] {\n [a] if False || True -> a\n _ -> anything()\n }\n}\n" 3 + assertion_line: 243 4 + expression: "\npub fn anything() -> a {\n case [] {\n [a] if False || True -> a\n _ -> anything()\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn anything() -> a { 9 + pub fn anything() -> a { 8 10 case [] { 9 11 [a] if False || True -> a 10 12 _ -> anything() ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { toList, Empty as $Empty } from "../gleam.mjs"; 17 19 18 - function anything() { 20 + export function anything() { 19 21 while (true) { 20 22 let $ = toList([]); 21 23 if ($ instanceof $Empty) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_local_var_in_tuple.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x, y) {\n let z = False\n case True {\n x if #(x, z) == #(True, False) -> x\n _ -> False\n }\n}\n" 3 + assertion_line: 227 4 + expression: "\npub fn go(x, y) {\n let z = False\n case True {\n x if #(x, z) == #(True, False) -> x\n _ -> False\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x, y) { 9 + pub fn go(x, y) { 8 10 let z = False 9 11 case True { 10 12 x if #(x, z) == #(True, False) -> x ··· 16 18 ----- COMPILED JAVASCRIPT 17 19 import { isEqual } from "../gleam.mjs"; 18 20 19 - function go(x, y) { 21 + export function go(x, y) { 20 22 let z = false; 21 23 let $ = true; 22 24 let x$1 = $;
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__following_todo.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 3 assertion_line: 81 4 - expression: "\nfn go(x) {\n case x {\n True -> todo\n _ -> 1\n }\n}\n" 4 + expression: "\npub fn go(x) {\n case x {\n True -> todo\n _ -> 1\n }\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 case x { 11 11 True -> todo 12 12 _ -> 1 ··· 19 19 20 20 const FILEPATH = "src/module.gleam"; 21 21 22 - function go(x) { 22 + export function go(x) { 23 23 if (x) { 24 24 throw makeError( 25 25 "todo",
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__guard_variable_only_brought_into_scope_when_needed.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x) {\n case x {\n // We want `a` to be defined before the guard check, and\n // `b` to be defined only if the predicate on a matches!\n [a, b] if a == 1 -> a + b\n _ -> 2\n }\n}\n" 3 + assertion_line: 34 4 + expression: "\npub fn go(x) {\n case x {\n // We want `a` to be defined before the guard check, and\n // `b` to be defined only if the predicate on a matches!\n [a, b] if a == 1 -> a + b\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 // We want `a` to be defined before the guard check, and 10 12 // `b` to be defined only if the predicate on a matches! ··· 17 19 ----- COMPILED JAVASCRIPT 18 20 import { Empty as $Empty } from "../gleam.mjs"; 19 21 20 - function go(x) { 22 + export function go(x) { 21 23 if (x instanceof $Empty) { 22 24 return 2; 23 25 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__multi_subject_catch_all.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x, y) {\n case x, y {\n True, True -> 1\n _, _ -> 0\n }\n}\n" 3 + assertion_line: 95 4 + expression: "\npub fn go(x, y) {\n case x, y {\n True, True -> 1\n _, _ -> 0\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x, y) { 9 + pub fn go(x, y) { 8 10 case x, y { 9 11 True, True -> 1 10 12 _, _ -> 0 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x, y) { 18 + export function go(x, y) { 17 19 if (y && x) { 18 20 return 1; 19 21 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__multi_subject_no_catch_all.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x, y) {\n case x, y {\n True, _ -> 1\n _, True -> 2\n False, False -> 0\n }\n}\n" 3 + assertion_line: 123 4 + expression: "\npub fn go(x, y) {\n case x, y {\n True, _ -> 1\n _, True -> 2\n False, False -> 0\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x, y) { 9 + pub fn go(x, y) { 8 10 case x, y { 9 11 True, _ -> 1 10 12 _, True -> 2 ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - function go(x, y) { 19 + export function go(x, y) { 18 20 if (x) { 19 21 return 1; 20 22 } else if (y) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__multi_subject_or.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x, y) {\n case x, y {\n True, _ | _, True -> 1\n _, _ -> 0\n }\n}\n" 3 + assertion_line: 109 4 + expression: "\npub fn go(x, y) {\n case x, y {\n True, _ | _, True -> 1\n _, _ -> 0\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x, y) { 9 + pub fn go(x, y) { 8 10 case x, y { 9 11 True, _ | _, True -> 1 10 12 _, _ -> 0 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x, y) { 18 + export function go(x, y) { 17 19 if (x) { 18 20 return 1; 19 21 } else if (y) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__multi_subject_subject_assignments.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go() {\n case True, False {\n True, True -> 1\n _, _ -> 0\n }\n}\n" 3 + assertion_line: 138 4 + expression: "\npub fn go() {\n case True, False {\n True, True -> 1\n _, _ -> 0\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 case True, False { 9 11 True, True -> 1 10 12 _, _ -> 0 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go() { 18 + export function go() { 17 19 let $ = true; 18 20 let $1 = false; 19 21 return 0;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__nested_string_prefix_match.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn main() {\n case Ok([\"a\", \"b c\", \"d\"]) {\n Ok([\"a\", \"b \" <> _, \"d\"]) -> 1\n _ -> 1\n }\n}\n" 3 + assertion_line: 258 4 + expression: "\npub fn main() {\n case Ok([\"a\", \"b c\", \"d\"]) {\n Ok([\"a\", \"b \" <> _, \"d\"]) -> 1\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn main() { 9 + pub fn main() { 8 10 case Ok(["a", "b c", "d"]) { 9 11 Ok(["a", "b " <> _, "d"]) -> 1 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { Ok, toList, Empty as $Empty } from "../gleam.mjs"; 17 19 18 - function main() { 20 + export function main() { 19 21 let $ = new Ok(toList(["a", "b c", "d"])); 20 22 let $1 = $[0]; 21 23 if ($1 instanceof $Empty) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__nested_string_prefix_match_that_would_crash_on_js.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn main() {\n case Ok([\"b c\", \"d\"]) {\n Ok([\"b \" <> _, \"d\"]) -> 1\n _ -> 1\n }\n}\n" 3 + assertion_line: 273 4 + expression: "\npub fn main() {\n case Ok([\"b c\", \"d\"]) {\n Ok([\"b \" <> _, \"d\"]) -> 1\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn main() { 9 + pub fn main() { 8 10 case Ok(["b c", "d"]) { 9 11 Ok(["b " <> _, "d"]) -> 1 10 12 _ -> 1 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { Ok, toList, Empty as $Empty } from "../gleam.mjs"; 17 19 18 - function main() { 20 + export function main() { 19 21 let $ = new Ok(toList(["b c", "d"])); 20 22 let $1 = $[0]; 21 23 if ($1 instanceof $Empty) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__pipe.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x, f) {\n case x |> f {\n 0 -> 1\n _ -> 2\n }\n}\n" 3 + assertion_line: 183 4 + expression: "\npub fn go(x, f) {\n case x |> f {\n 0 -> 1\n _ -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x, f) { 9 + pub fn go(x, f) { 8 10 case x |> f { 9 11 0 -> 1 10 12 _ -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x, f) { 18 + export function go(x, f) { 17 19 let $ = (() => { 18 20 let _pipe = x; 19 21 return f(_pipe);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__pointless.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x) {\n case x {\n _ -> x\n }\n}\n" 3 + assertion_line: 67 4 + expression: "\npub fn go(x) {\n case x {\n _ -> x\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 _ -> x 10 12 } ··· 12 14 13 15 14 16 ----- COMPILED JAVASCRIPT 15 - function go(x) { 17 + export function go(x) { 16 18 return x; 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__preassign_assignment.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x) {\n let y = case x() {\n True -> 1\n _ -> 0\n }\n y\n}\n" 3 + assertion_line: 167 4 + expression: "\npub fn go(x) {\n let y = case x() {\n True -> 1\n _ -> 0\n }\n y\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 let y = case x() { 9 11 True -> 1 10 12 _ -> 0 ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - function go(x) { 19 + export function go(x) { 18 20 let _block; 19 21 let $ = x(); 20 22 if ($) {
+5 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__record_update_in_pipeline_in_case_clause.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 3 assertion_line: 380 4 - expression: "\ntype Wibble {\n Wibble(wibble: Int, wobble: Int)\n}\n\nfn identity(x) {\n x\n}\n\nfn go(x) {\n case x {\n Wibble(1, _) -> Wibble(..x, wibble: 4) |> identity\n Wibble(_, 3) -> Wibble(..x, wobble: 10) |> identity\n _ -> panic\n }\n}\n" 4 + expression: "\npub type Wibble {\n Wibble(wibble: Int, wobble: Int)\n}\n\nfn identity(x) {\n x\n}\n\npub fn go(x) {\n case x {\n Wibble(1, _) -> Wibble(..x, wibble: 4) |> identity\n Wibble(_, 3) -> Wibble(..x, wobble: 10) |> identity\n _ -> panic\n }\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - type Wibble { 9 + pub type Wibble { 10 10 Wibble(wibble: Int, wobble: Int) 11 11 } 12 12 ··· 14 14 x 15 15 } 16 16 17 - fn go(x) { 17 + pub fn go(x) { 18 18 case x { 19 19 Wibble(1, _) -> Wibble(..x, wibble: 4) |> identity 20 20 Wibble(_, 3) -> Wibble(..x, wobble: 10) |> identity ··· 28 28 29 29 const FILEPATH = "src/module.gleam"; 30 30 31 - class Wibble extends $CustomType { 31 + export class Wibble extends $CustomType { 32 32 constructor(wibble, wobble) { 33 33 super(); 34 34 this.wibble = wibble; ··· 40 40 return x; 41 41 } 42 42 43 - function go(x) { 43 + export function go(x) { 44 44 let $ = x.wibble; 45 45 if ($ === 1) { 46 46 let _block;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__result.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x) {\n case x {\n Ok(_) -> 1\n Error(_) -> 0\n }\n}\n" 3 + assertion_line: 197 4 + expression: "\npub fn go(x) {\n case x {\n Ok(_) -> 1\n Error(_) -> 0\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 Ok(_) -> 1 10 12 Error(_) -> 0 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { Ok } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 if (x instanceof Ok) { 20 22 return 1; 21 23 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__tuple_and_guard.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case.rs 3 - expression: "\nfn go(x) {\n case #(1, 2) {\n #(1, a) if a == 2 -> 1\n #(_, _) -> 2\n }\n}\n" 3 + assertion_line: 20 4 + expression: "\npub fn go(x) {\n case #(1, 2) {\n #(1, a) if a == 2 -> 1\n #(_, _) -> 2\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case #(1, 2) { 9 11 #(1, a) if a == 2 -> 1 10 12 #(_, _) -> 2 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 let $ = [1, 2]; 18 20 let $1 = $[0]; 19 21 if ($1 === 1) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case_clause_guards__constructor_function_in_guard.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case_clause_guards.rs 3 - expression: "fn func(x) {\n case [] {\n _ if [] == [ Ok ] -> True\n _ -> False\n }\n}\n " 3 + assertion_line: 524 4 + expression: "pub fn func(x) {\n case [] {\n _ if [] == [ Ok ] -> True\n _ -> False\n }\n}\n " 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 - fn func(x) { 8 + pub fn func(x) { 7 9 case [] { 8 10 _ if [] == [ Ok ] -> True 9 11 _ -> False ··· 14 16 ----- COMPILED JAVASCRIPT 15 17 import { Ok, toList, isEqual } from "../gleam.mjs"; 16 18 17 - function func(x) { 19 + export function func(x) { 18 20 let $ = toList([]); 19 21 if (isEqual(toList([]), toList([(var0) => { return new Ok(var0); }]))) { 20 22 return true;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case_clause_guards__custom_type_constructor_imported_and_aliased.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case_clause_guards.rs 3 - expression: "import other_module.{A as B}\nfn func() {\n case B {\n x if x == B -> True\n _ -> False\n }\n}\n" 3 + assertion_line: 474 4 + expression: "import other_module.{A as B}\npub fn func() {\n case B {\n x if x == B -> True\n _ -> False\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 import other_module.{A as B} 7 - fn func() { 9 + pub fn func() { 8 10 case B { 9 11 x if x == B -> True 10 12 _ -> False ··· 17 19 import { A as B } from "../../package/other_module.mjs"; 18 20 import { isEqual } from "../gleam.mjs"; 19 21 20 - function func() { 22 + export function func() { 21 23 let $ = new B(); 22 24 let x = $; 23 25 if (isEqual(x, new B())) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case_clause_guards__imported_aliased_ok.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case_clause_guards.rs 3 - expression: "import gleam.{Ok as Y}\npub type X {\n Ok\n}\nfn func() {\n case Y {\n y if y == Y -> True\n _ -> False\n }\n}\n" 3 + assertion_line: 489 4 + expression: "import gleam.{Ok as Y}\npub type X {\n Ok\n}\npub fn func() {\n case Y {\n y if y == Y -> True\n _ -> False\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 import gleam.{Ok as Y} 7 9 pub type X { 8 10 Ok 9 11 } 10 - fn func() { 12 + pub fn func() { 11 13 case Y { 12 14 y if y == Y -> True 13 15 _ -> False ··· 21 23 22 24 export class Ok extends $CustomType {} 23 25 24 - function func() { 26 + export function func() { 25 27 let $ = (var0) => { return new Y(var0); }; 26 28 let y = $; 27 29 if (isEqual(y, (var0) => { return new Y(var0); })) {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case_clause_guards__imported_ok.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/case_clause_guards.rs 3 - expression: "import gleam\npub type X {\n Ok\n}\nfn func(x) {\n case gleam.Ok {\n _ if [] == [ gleam.Ok ] -> True\n _ -> False\n }\n}\n" 3 + assertion_line: 506 4 + expression: "import gleam\npub type X {\n Ok\n}\npub fn func(x) {\n case gleam.Ok {\n _ if [] == [ gleam.Ok ] -> True\n _ -> False\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 import gleam 7 9 pub type X { 8 10 Ok 9 11 } 10 - fn func(x) { 12 + pub fn func(x) { 11 13 case gleam.Ok { 12 14 _ if [] == [ gleam.Ok ] -> True 13 15 _ -> False ··· 21 23 22 24 export class Ok extends $CustomType {} 23 25 24 - function func(x) { 26 + export function func(x) { 25 27 let $ = (var0) => { return new $gleam.Ok(var0); }; 26 28 if (isEqual(toList([]), toList([(var0) => { return new Ok(var0); }]))) { 27 29 return true;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__consts__constant_constructor_gets_pure_annotation.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/consts.rs 3 - expression: "\npub type X {\n X(Int, List(String))\n}\n\npub const x = X(1, [\"1\"])\nconst y = X(1, [])\n " 3 + assertion_line: 44 4 + expression: "\npub type X {\n X(Int, List(String))\n}\n\npub const x = X(1, [\"1\"])\npub const y = X(1, [])\n " 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 ··· 9 11 } 10 12 11 13 pub const x = X(1, ["1"]) 12 - const y = X(1, []) 14 + pub const y = X(1, []) 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT ··· 25 27 26 28 export const x = /* @__PURE__ */ new X(1, /* @__PURE__ */ toList(["1"])); 27 29 28 - const y = /* @__PURE__ */ new X(1, /* @__PURE__ */ toList([])); 30 + export const y = /* @__PURE__ */ new X(1, /* @__PURE__ */ toList([]));
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__consts__constant_list_with_constructors_gets_pure_annotation.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/consts.rs 3 - expression: "\npub type X {\n X(Int, List(String))\n}\n\npub const x = [X(1, [\"1\"])]\nconst y = [X(1, [\"1\"])]\n " 3 + assertion_line: 58 4 + expression: "\npub type X {\n X(Int, List(String))\n}\n\npub const x = [X(1, [\"1\"])]\npub const y = [X(1, [\"1\"])]\n " 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 ··· 9 11 } 10 12 11 13 pub const x = [X(1, ["1"])] 12 - const y = [X(1, ["1"])] 14 + pub const y = [X(1, ["1"])] 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT ··· 27 29 /* @__PURE__ */ new X(1, /* @__PURE__ */ toList(["1"])), 28 30 ]); 29 31 30 - const y = /* @__PURE__ */ toList([ 32 + export const y = /* @__PURE__ */ toList([ 31 33 /* @__PURE__ */ new X(1, /* @__PURE__ */ toList(["1"])), 32 34 ]);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__consts__constant_tuple_with_constructors_gets_pure_annotation.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/consts.rs 3 - expression: "\npub type X {\n X(Int, List(String))\n}\n\npub const x = #(X(1, [\"1\"]))\nconst y = #(X(1, [\"1\"]))\n " 3 + assertion_line: 72 4 + expression: "\npub type X {\n X(Int, List(String))\n}\n\npub const x = #(X(1, [\"1\"]))\npub const y = #(X(1, [\"1\"]))\n " 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 ··· 9 11 } 10 12 11 13 pub const x = #(X(1, ["1"])) 12 - const y = #(X(1, ["1"])) 14 + pub const y = #(X(1, ["1"])) 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT ··· 25 27 26 28 export const x = [/* @__PURE__ */ new X(1, /* @__PURE__ */ toList(["1"]))]; 27 29 28 - const y = [/* @__PURE__ */ new X(1, /* @__PURE__ */ toList(["1"]))]; 30 + export const y = [/* @__PURE__ */ new X(1, /* @__PURE__ */ toList(["1"]))];
+9 -7
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__const_with_fields.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - expression: "\ntype Mine {\n Mine(a: Int, b: Int)\n}\n\nconst labels = Mine(b: 2, a: 1)\nconst no_labels = Mine(3, 4)\n" 3 + assertion_line: 140 4 + expression: "\npub type Mine {\n Mine(a: Int, b: Int)\n}\n\npub const labels = Mine(b: 2, a: 1)\npub const no_labels = Mine(3, 4)\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - type Mine { 9 + pub type Mine { 8 10 Mine(a: Int, b: Int) 9 11 } 10 12 11 - const labels = Mine(b: 2, a: 1) 12 - const no_labels = Mine(3, 4) 13 + pub const labels = Mine(b: 2, a: 1) 14 + pub const no_labels = Mine(3, 4) 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 18 import { CustomType as $CustomType } from "../gleam.mjs"; 17 19 18 - class Mine extends $CustomType { 20 + export class Mine extends $CustomType { 19 21 constructor(a, b) { 20 22 super(); 21 23 this.a = a; ··· 23 25 } 24 26 } 25 27 26 - const labels = /* @__PURE__ */ new Mine(1, 2); 28 + export const labels = /* @__PURE__ */ new Mine(1, 2); 27 29 28 - const no_labels = /* @__PURE__ */ new Mine(3, 4); 30 + export const no_labels = /* @__PURE__ */ new Mine(3, 4);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__const_zero_arity_imported.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - expression: "import other\nconst x = other.Two\n" 3 + assertion_line: 104 4 + expression: "import other\npub const x = other.Two\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 -- other.gleam ··· 8 10 9 11 -- main.gleam 10 12 import other 11 - const x = other.Two 13 + pub const x = other.Two 12 14 13 15 14 16 ----- COMPILED JAVASCRIPT 15 17 import * as $other from "../other.mjs"; 16 18 17 - const x = /* @__PURE__ */ new $other.Two(); 19 + export const x = /* @__PURE__ */ new $other.Two();
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__const_zero_arity_imported_unqualified.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - expression: "import other.{Two}\nconst a = Two\n" 3 + assertion_line: 114 4 + expression: "import other.{Two}\npub const a = Two\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 -- other.gleam ··· 8 10 9 11 -- main.gleam 10 12 import other.{Two} 11 - const a = Two 13 + pub const a = Two 12 14 13 15 14 16 ----- COMPILED JAVASCRIPT 15 17 import * as $other from "../other.mjs"; 16 18 import { Two } from "../other.mjs"; 17 19 18 - const a = /* @__PURE__ */ new Two(); 20 + export const a = /* @__PURE__ */ new Two();
+19 -17
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__custom_type_with_named_fields.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - expression: "\ntype Cat {\n Cat(name: String, cuteness: Int)\n}\n\ntype Box {\n Box(occupant: Cat)\n}\n\nconst felix = Cat(\"Felix\", 12)\nconst tom = Cat(cuteness: 1, name: \"Tom\")\n\nfn go() {\n Cat(\"Nubi\", 1)\n Cat(2, name: \"Nubi\")\n Cat(cuteness: 3, name: \"Nubi\")\n}\n\nfn update(cat) {\n Cat(..cat, name: \"Sid\")\n Cat(..cat, name: \"Bartholemew Wonder Puss the Fourth !!!!!!!!!!!!!!!!\")\n Cat(..new_cat(), name: \"Molly\")\n let box = Box(occupant: cat)\n Cat(..box.occupant, cuteness: box.occupant.cuteness + 1)\n}\n\nfn access(cat: Cat) {\n cat.cuteness\n}\n\nfn new_cat() {\n Cat(name: \"Beau\", cuteness: 11)\n}\n" 3 + assertion_line: 222 4 + expression: "\npub type Cat {\n Cat(name: String, cuteness: Int)\n}\n\npub type Box {\n Box(occupant: Cat)\n}\n\npub const felix = Cat(\"Felix\", 12)\npub const tom = Cat(cuteness: 1, name: \"Tom\")\n\npub fn go() {\n Cat(\"Nubi\", 1)\n Cat(2, name: \"Nubi\")\n Cat(cuteness: 3, name: \"Nubi\")\n}\n\npub fn update(cat) {\n Cat(..cat, name: \"Sid\")\n Cat(..cat, name: \"Bartholemew Wonder Puss the Fourth !!!!!!!!!!!!!!!!\")\n Cat(..new_cat(), name: \"Molly\")\n let box = Box(occupant: cat)\n Cat(..box.occupant, cuteness: box.occupant.cuteness + 1)\n}\n\npub fn access(cat: Cat) {\n cat.cuteness\n}\n\npub fn new_cat() {\n Cat(name: \"Beau\", cuteness: 11)\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - type Cat { 9 + pub type Cat { 8 10 Cat(name: String, cuteness: Int) 9 11 } 10 12 11 - type Box { 13 + pub type Box { 12 14 Box(occupant: Cat) 13 15 } 14 16 15 - const felix = Cat("Felix", 12) 16 - const tom = Cat(cuteness: 1, name: "Tom") 17 + pub const felix = Cat("Felix", 12) 18 + pub const tom = Cat(cuteness: 1, name: "Tom") 17 19 18 - fn go() { 20 + pub fn go() { 19 21 Cat("Nubi", 1) 20 22 Cat(2, name: "Nubi") 21 23 Cat(cuteness: 3, name: "Nubi") 22 24 } 23 25 24 - fn update(cat) { 26 + pub fn update(cat) { 25 27 Cat(..cat, name: "Sid") 26 28 Cat(..cat, name: "Bartholemew Wonder Puss the Fourth !!!!!!!!!!!!!!!!") 27 29 Cat(..new_cat(), name: "Molly") ··· 29 31 Cat(..box.occupant, cuteness: box.occupant.cuteness + 1) 30 32 } 31 33 32 - fn access(cat: Cat) { 34 + pub fn access(cat: Cat) { 33 35 cat.cuteness 34 36 } 35 37 36 - fn new_cat() { 38 + pub fn new_cat() { 37 39 Cat(name: "Beau", cuteness: 11) 38 40 } 39 41 ··· 41 43 ----- COMPILED JAVASCRIPT 42 44 import { CustomType as $CustomType } from "../gleam.mjs"; 43 45 44 - class Cat extends $CustomType { 46 + export class Cat extends $CustomType { 45 47 constructor(name, cuteness) { 46 48 super(); 47 49 this.name = name; ··· 49 51 } 50 52 } 51 53 52 - class Box extends $CustomType { 54 + export class Box extends $CustomType { 53 55 constructor(occupant) { 54 56 super(); 55 57 this.occupant = occupant; 56 58 } 57 59 } 58 60 59 - function go() { 61 + export function go() { 60 62 new Cat("Nubi", 1); 61 63 new Cat("Nubi", 2); 62 64 return new Cat("Nubi", 3); 63 65 } 64 66 65 - function access(cat) { 67 + export function access(cat) { 66 68 return cat.cuteness; 67 69 } 68 70 69 - function new_cat() { 71 + export function new_cat() { 70 72 return new Cat("Beau", 11); 71 73 } 72 74 73 - function update(cat) { 75 + export function update(cat) { 74 76 let _record = cat; 75 77 new Cat("Sid", _record.cuteness) 76 78 let _record$1 = cat; ··· 85 87 return new Cat(_record$3.name, box.occupant.cuteness + 1); 86 88 } 87 89 88 - const felix = /* @__PURE__ */ new Cat("Felix", 12); 90 + export const felix = /* @__PURE__ */ new Cat("Felix", 12); 89 91 90 - const tom = /* @__PURE__ */ new Cat("Tom", 1); 92 + export const tom = /* @__PURE__ */ new Cat("Tom", 1);
+7 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__destructure_custom_type_with_mixed_fields_first_unlabelled.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - expression: "\ntype Cat {\n Cat(String, cuteness: Int)\n}\n\nfn go(cat) {\n let Cat(x, y) = cat\n let Cat(cuteness: y, ..) = cat\n let Cat(x, cuteness: y) = cat\n x\n}\n\n" 3 + assertion_line: 281 4 + expression: "\npub type Cat {\n Cat(String, cuteness: Int)\n}\n\npub fn go(cat) {\n let Cat(x, y) = cat\n let Cat(cuteness: y, ..) = cat\n let Cat(x, cuteness: y) = cat\n x\n}\n\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - type Cat { 9 + pub type Cat { 8 10 Cat(String, cuteness: Int) 9 11 } 10 12 11 - fn go(cat) { 13 + pub fn go(cat) { 12 14 let Cat(x, y) = cat 13 15 let Cat(cuteness: y, ..) = cat 14 16 let Cat(x, cuteness: y) = cat ··· 20 22 ----- COMPILED JAVASCRIPT 21 23 import { CustomType as $CustomType } from "../gleam.mjs"; 22 24 23 - class Cat extends $CustomType { 25 + export class Cat extends $CustomType { 24 26 constructor($0, cuteness) { 25 27 super(); 26 28 this[0] = $0; ··· 28 30 } 29 31 } 30 32 31 - function go(cat) { 33 + export function go(cat) { 32 34 let x = cat[0]; 33 35 let y = cat.cuteness; 34 36 let y$1 = cat.cuteness;
+7 -7
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__destructure_custom_type_with_named_fields.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - assertion_line: 278 4 - expression: "\ntype Cat {\n Cat(name: String, cuteness: Int)\n}\n\nfn go(cat) {\n let Cat(x, y) = cat\n let Cat(name: x, ..) = cat\n let assert Cat(cuteness: 4, name: x) = cat\n x\n}\n\n" 3 + assertion_line: 262 4 + expression: "\npub type Cat {\n Cat(name: String, cuteness: Int)\n}\n\npub fn go(cat) {\n let Cat(x, y) = cat\n let Cat(name: x, ..) = cat\n let assert Cat(cuteness: 4, name: x) = cat\n x\n}\n\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - type Cat { 9 + pub type Cat { 10 10 Cat(name: String, cuteness: Int) 11 11 } 12 12 13 - fn go(cat) { 13 + pub fn go(cat) { 14 14 let Cat(x, y) = cat 15 15 let Cat(name: x, ..) = cat 16 16 let assert Cat(cuteness: 4, name: x) = cat ··· 24 24 25 25 const FILEPATH = "src/module.gleam"; 26 26 27 - class Cat extends $CustomType { 27 + export class Cat extends $CustomType { 28 28 constructor(name, cuteness) { 29 29 super(); 30 30 this.name = name; ··· 32 32 } 33 33 } 34 34 35 - function go(cat) { 35 + export function go(cat) { 36 36 let x = cat.name; 37 37 let y = cat.cuteness; 38 38 let x$1 = cat.name; ··· 44 44 9, 45 45 "go", 46 46 "Pattern match failed, no pattern matched the value.", 47 - { value: cat, start: 116, end: 158, pattern_start: 127, pattern_end: 152 } 47 + { value: cat, start: 124, end: 166, pattern_start: 135, pattern_end: 160 } 48 48 ) 49 49 } 50 50 let x$2 = cat.name;
+7 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__long_name_variant_without_labels.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - expression: "\ntype TypeWithALongNameAndSeveralArguments{\n TypeWithALongNameAndSeveralArguments(String, String, String, String, String)\n}\n\n\nfn go() {\n TypeWithALongNameAndSeveralArguments\n}\n" 3 + assertion_line: 193 4 + expression: "\npub type TypeWithALongNameAndSeveralArguments{\n TypeWithALongNameAndSeveralArguments(String, String, String, String, String)\n}\n\n\npub fn go() {\n TypeWithALongNameAndSeveralArguments\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - type TypeWithALongNameAndSeveralArguments{ 9 + pub type TypeWithALongNameAndSeveralArguments{ 8 10 TypeWithALongNameAndSeveralArguments(String, String, String, String, String) 9 11 } 10 12 11 13 12 - fn go() { 14 + pub fn go() { 13 15 TypeWithALongNameAndSeveralArguments 14 16 } 15 17 ··· 17 19 ----- COMPILED JAVASCRIPT 18 20 import { CustomType as $CustomType } from "../gleam.mjs"; 19 21 20 - class TypeWithALongNameAndSeveralArguments extends $CustomType { 22 + export class TypeWithALongNameAndSeveralArguments extends $CustomType { 21 23 constructor($0, $1, $2, $3, $4) { 22 24 super(); 23 25 this[0] = $0; ··· 28 30 } 29 31 } 30 32 31 - function go() { 33 + export function go() { 32 34 return (var0, var1, var2, var3, var4) => { 33 35 return new TypeWithALongNameAndSeveralArguments( 34 36 var0,
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__nested_pattern_with_labels.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - expression: "pub type Box(x) { Box(a: Int, b: x) }\nfn go(x) {\n case x {\n Box(a: _, b: Box(a: a, b: b)) -> a + b\n _ -> 1\n }\n}\n" 3 + assertion_line: 316 4 + expression: "pub type Box(x) { Box(a: Int, b: x) }\npub fn go(x) {\n case x {\n Box(a: _, b: Box(a: a, b: b)) -> a + b\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 pub type Box(x) { Box(a: Int, b: x) } 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 Box(a: _, b: Box(a: a, b: b)) -> a + b 10 12 _ -> 1 ··· 23 25 } 24 26 } 25 27 26 - function go(x) { 28 + export function go(x) { 27 29 let a = x.b.a; 28 30 let b = x.b.b; 29 31 return a + b;
+13 -11
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__unnamed_fields.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - expression: "\ntype Ip{\n Ip(String)\n}\n\nconst local = Ip(\"0.0.0.0\")\n\nfn build(x) {\n x(\"1.2.3.4\")\n}\n\nfn go() {\n build(Ip)\n Ip(\"5.6.7.8\")\n}\n\nfn destructure(x) {\n let Ip(raw) = x\n raw\n}\n" 3 + assertion_line: 168 4 + expression: "\npub type Ip {\n Ip(String)\n}\n\npub const local = Ip(\"0.0.0.0\")\n\npub fn build(x) {\n x(\"1.2.3.4\")\n}\n\npub fn go() {\n build(Ip)\n Ip(\"5.6.7.8\")\n}\n\npub fn destructure(x) {\n let Ip(raw) = x\n raw\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - type Ip{ 9 + pub type Ip { 8 10 Ip(String) 9 11 } 10 12 11 - const local = Ip("0.0.0.0") 13 + pub const local = Ip("0.0.0.0") 12 14 13 - fn build(x) { 15 + pub fn build(x) { 14 16 x("1.2.3.4") 15 17 } 16 18 17 - fn go() { 19 + pub fn go() { 18 20 build(Ip) 19 21 Ip("5.6.7.8") 20 22 } 21 23 22 - fn destructure(x) { 24 + pub fn destructure(x) { 23 25 let Ip(raw) = x 24 26 raw 25 27 } ··· 28 30 ----- COMPILED JAVASCRIPT 29 31 import { CustomType as $CustomType } from "../gleam.mjs"; 30 32 31 - class Ip extends $CustomType { 33 + export class Ip extends $CustomType { 32 34 constructor($0) { 33 35 super(); 34 36 this[0] = $0; 35 37 } 36 38 } 37 39 38 - function build(x) { 40 + export function build(x) { 39 41 return x("1.2.3.4"); 40 42 } 41 43 42 - function go() { 44 + export function go() { 43 45 build((var0) => { return new Ip(var0); }); 44 46 return new Ip("5.6.7.8"); 45 47 } 46 48 47 - function destructure(x) { 49 + export function destructure(x) { 48 50 let raw = x[0]; 49 51 return raw; 50 52 } 51 53 52 - const local = /* @__PURE__ */ new Ip("0.0.0.0"); 54 + export const local = /* @__PURE__ */ new Ip("0.0.0.0");
+10 -8
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__zero_arity_const.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - expression: "\ntype Mine {\n This\n ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant\n}\n\nconst this = This\nconst that = ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant\n" 3 + assertion_line: 23 4 + expression: "\npub type Mine {\n This\n ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant\n}\n\npub const this = This\npub const that = ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - type Mine { 9 + pub type Mine { 8 10 This 9 11 ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant 10 12 } 11 13 12 - const this = This 13 - const that = ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant 14 + pub const this = This 15 + pub const that = ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 19 import { CustomType as $CustomType } from "../gleam.mjs"; 18 20 19 - class This extends $CustomType {} 21 + export class This extends $CustomType {} 20 22 21 - class ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant extends $CustomType {} 23 + export class ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant extends $CustomType {} 22 24 23 - const this$ = /* @__PURE__ */ new This(); 25 + export const this$ = /* @__PURE__ */ new This(); 24 26 25 - const that = /* @__PURE__ */ new ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant(); 27 + export const that = /* @__PURE__ */ new ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant();
+8 -6
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__zero_arity_literal.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/custom_types.rs 3 - expression: "\ntype Mine {\n This\n ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant\n}\n\nfn go() {\n This\n ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant\n}\n" 3 + assertion_line: 6 4 + expression: "\npub type Mine {\n This\n ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant\n}\n\npub fn go() {\n This\n ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - type Mine { 9 + pub type Mine { 8 10 This 9 11 ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant 10 12 } 11 13 12 - fn go() { 14 + pub fn go() { 13 15 This 14 16 ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant 15 17 } ··· 18 20 ----- COMPILED JAVASCRIPT 19 21 import { CustomType as $CustomType } from "../gleam.mjs"; 20 22 21 - class This extends $CustomType {} 23 + export class This extends $CustomType {} 22 24 23 - class ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant extends $CustomType {} 25 + export class ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant extends $CustomType {} 24 26 25 - function go() { 27 + export function go() { 26 28 new This(); 27 29 return new ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant(); 28 30 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__lists__case.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/lists.rs 3 - expression: "\nfn go(xs) {\n case xs {\n [] -> 0\n [_] -> 1\n [_, _] -> 2\n _ -> 9999\n }\n}\n" 3 + assertion_line: 89 4 + expression: "\npub fn go(xs) {\n case xs {\n [] -> 0\n [_] -> 1\n [_, _] -> 2\n _ -> 9999\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(xs) { 9 + pub fn go(xs) { 8 10 case xs { 9 11 [] -> 0 10 12 [_] -> 1 ··· 17 19 ----- COMPILED JAVASCRIPT 18 20 import { Empty as $Empty } from "../gleam.mjs"; 19 21 20 - function go(xs) { 22 + export function go(xs) { 21 23 if (xs instanceof $Empty) { 22 24 return 0; 23 25 } else {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__lists__equality.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/lists.rs 3 - expression: "\nfn go() {\n [] == [1]\n [] != [1]\n}\n" 3 + assertion_line: 77 4 + expression: "\npub fn go() {\n [] == [1]\n [] != [1]\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 [] == [1] 9 11 [] != [1] 10 12 } ··· 13 15 ----- COMPILED JAVASCRIPT 14 16 import { toList, isEqual } from "../gleam.mjs"; 15 17 16 - function go() { 18 + export function go() { 17 19 isEqual(toList([]), toList([1])); 18 20 return !isEqual(toList([]), toList([1])); 19 21 }
+7 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__lists__list_constants.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/lists.rs 3 - expression: "\nconst a = []\nconst b = [1, 2, 3]\n" 3 + assertion_line: 42 4 + expression: "\npub const a = []\npub const b = [1, 2, 3]\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - const a = [] 8 - const b = [1, 2, 3] 9 + pub const a = [] 10 + pub const b = [1, 2, 3] 9 11 10 12 11 13 ----- COMPILED JAVASCRIPT 12 14 import { toList } from "../gleam.mjs"; 13 15 14 - const a = /* @__PURE__ */ toList([]); 16 + export const a = /* @__PURE__ */ toList([]); 15 17 16 - const b = /* @__PURE__ */ toList([1, 2, 3]); 18 + export const b = /* @__PURE__ */ toList([1, 2, 3]);
+8 -8
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__lists__list_destructuring.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/lists.rs 3 3 assertion_line: 62 4 - expression: "\nfn go(x, y) {\n let assert [] = x\n let assert [a] = x\n let assert [1, 2] = x\n let assert [_, #(3, b)] = y\n let assert [head, ..tail] = y\n}\n" 4 + expression: "\npub fn go(x, y) {\n let assert [] = x\n let assert [a] = x\n let assert [1, 2] = x\n let assert [_, #(3, b)] = y\n let assert [head, ..tail] = y\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x, y) { 9 + pub fn go(x, y) { 10 10 let assert [] = x 11 11 let assert [a] = x 12 12 let assert [1, 2] = x ··· 20 20 21 21 const FILEPATH = "src/module.gleam"; 22 22 23 - function go(x, y) { 23 + export function go(x, y) { 24 24 if (x instanceof $NonEmpty) { 25 25 throw makeError( 26 26 "let_assert", ··· 29 29 3, 30 30 "go", 31 31 "Pattern match failed, no pattern matched the value.", 32 - { value: x, start: 17, end: 34, pattern_start: 28, pattern_end: 30 } 32 + { value: x, start: 21, end: 38, pattern_start: 32, pattern_end: 34 } 33 33 ) 34 34 } 35 35 if (x instanceof $Empty || x.tail instanceof $NonEmpty) { ··· 40 40 4, 41 41 "go", 42 42 "Pattern match failed, no pattern matched the value.", 43 - { value: x, start: 37, end: 55, pattern_start: 48, pattern_end: 51 } 43 + { value: x, start: 41, end: 59, pattern_start: 52, pattern_end: 55 } 44 44 ) 45 45 } 46 46 let a = x.head; ··· 58 58 5, 59 59 "go", 60 60 "Pattern match failed, no pattern matched the value.", 61 - { value: x, start: 58, end: 79, pattern_start: 69, pattern_end: 75 } 61 + { value: x, start: 62, end: 83, pattern_start: 73, pattern_end: 79 } 62 62 ) 63 63 } 64 64 if ( ··· 74 74 6, 75 75 "go", 76 76 "Pattern match failed, no pattern matched the value.", 77 - { value: y, start: 82, end: 109, pattern_start: 93, pattern_end: 105 } 77 + { value: y, start: 86, end: 113, pattern_start: 97, pattern_end: 109 } 78 78 ) 79 79 } 80 80 let b = y.tail.head[1]; ··· 86 86 7, 87 87 "go", 88 88 "Pattern match failed, no pattern matched the value.", 89 - { value: y, start: 112, end: 141, pattern_start: 123, pattern_end: 137 } 89 + { value: y, start: 116, end: 145, pattern_start: 127, pattern_end: 141 } 90 90 ) 91 91 } 92 92 let head = y.head;
+9 -7
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__lists__list_literals.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/lists.rs 3 - expression: "\nfn go(x) {\n []\n [1]\n [1, 2]\n [1, 2, ..x]\n}\n" 3 + assertion_line: 5 4 + expression: "\npub fn go(x) {\n []\n [1]\n [1, 2]\n [1, 2, ..x]\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 8 - [] 9 - [1] 10 - [1, 2] 11 - [1, 2, ..x] 9 + pub fn go(x) { 10 + [] 11 + [1] 12 + [1, 2] 13 + [1, 2, ..x] 12 14 } 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 18 import { toList, prepend as listPrepend } from "../gleam.mjs"; 17 19 18 - function go(x) { 20 + export function go(x) { 19 21 toList([]); 20 22 toList([1]); 21 23 toList([1, 2]);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__lists__long_list_literals.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/lists.rs 3 - expression: "\nfn go() {\n [111111111111111111111111111111111111111111111111111111111111111111111111]\n [11111111111111111111111111111111111111111111, 1111111111111111111111111111111111111111111]\n}\n" 3 + assertion_line: 19 4 + expression: "\npub fn go() {\n [111111111111111111111111111111111111111111111111111111111111111111111111]\n [11111111111111111111111111111111111111111111, 1111111111111111111111111111111111111111111]\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 [111111111111111111111111111111111111111111111111111111111111111111111111] 9 11 [11111111111111111111111111111111111111111111, 1111111111111111111111111111111111111111111] 10 12 } ··· 13 15 ----- COMPILED JAVASCRIPT 14 16 import { toList } from "../gleam.mjs"; 15 17 16 - function go() { 18 + export function go() { 17 19 toList([ 18 20 111111111111111111111111111111111111111111111111111111111111111111111111, 19 21 ]);
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__lists__multi_line_list_literals.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/lists.rs 3 - expression: "\nfn go(x) {\n [{True 1}]\n}\n" 3 + assertion_line: 31 4 + expression: "\npub fn go(x) {\n [{True 1}]\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 [{True 1}] 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toList } from "../gleam.mjs"; 14 16 15 - function go(x) { 17 + export function go(x) { 16 18 return toList([ 17 19 (() => { 18 20 true;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__lists__tight_empty_list.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/lists.rs 3 - expression: "\nfn go(func) {\n let huuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuge_variable = []\n}\n" 3 + assertion_line: 106 4 + expression: "\npub fn go(func) {\n let huuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuge_variable = []\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(func) { 9 + pub fn go(func) { 8 10 let huuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuge_variable = [] 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { toList } from "../gleam.mjs"; 14 16 15 - function go(func) { 17 + export function go(func) { 16 18 let huuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuge_variable = toList([]); 17 19 return huuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuge_variable; 18 20 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__modules__alias_aliased_constant.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/modules.rs 3 - expression: "\nimport rocket_ship.{ x as y }\nconst z = y\n" 3 + assertion_line: 59 4 + expression: "\nimport rocket_ship.{ x as y }\npub const z = y\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 -- rocket_ship.gleam ··· 9 11 -- main.gleam 10 12 11 13 import rocket_ship.{ x as y } 12 - const z = y 14 + pub const z = y 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 18 import * as $rocket_ship from "../rocket_ship.mjs"; 17 19 import { x as y } from "../rocket_ship.mjs"; 18 20 19 - const z = y; 21 + export const z = y;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__modules__renamed_module.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/modules.rs 3 - expression: "\nimport x as y\nconst z = y.v\n" 3 + assertion_line: 70 4 + expression: "\nimport x as y\npub const z = y.v\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 -- x.gleam ··· 9 11 -- main.gleam 10 12 11 13 import x as y 12 - const z = y.v 14 + pub const z = y.v 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 18 import * as $y from "../x.mjs"; 17 19 18 - const z = $y.v; 20 + export const z = $y.v;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__float_divide_complex_expr.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n case 1.0 >=. 0.0 {\n True -> 2.0\n False -> 4.0\n } /. 2.0\n}\n" 3 + assertion_line: 121 4 + expression: "\npub fn go() {\n case 1.0 >=. 0.0 {\n True -> 2.0\n False -> 4.0\n } /. 2.0\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 case 1.0 >=. 0.0 { 9 11 True -> 2.0 10 12 False -> 4.0 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { divideFloat } from "../gleam.mjs"; 17 19 18 - function go() { 20 + export function go() { 19 21 return divideFloat( 20 22 (() => { 21 23 let $ = 1.0 >= 0.0;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__float_equality.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n 1.0 != 2.0\n 1.0 == 2.0\n}\n" 3 + assertion_line: 181 4 + expression: "\npub fn go() {\n 1.0 != 2.0\n 1.0 == 2.0\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 1.0 != 2.0 9 11 1.0 == 2.0 10 12 } 11 13 12 14 13 15 ----- COMPILED JAVASCRIPT 14 - function go() { 16 + export function go() { 15 17 1.0 !== 2.0; 16 18 return 1.0 === 2.0; 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__float_equality1.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go(y) {\n let x = 1.0\n x == y\n}\n" 3 + assertion_line: 193 4 + expression: "\npub fn go(y) {\n let x = 1.0\n x == y\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(y) { 9 + pub fn go(y) { 8 10 let x = 1.0 9 11 x == y 10 12 } 11 13 12 14 13 15 ----- COMPILED JAVASCRIPT 14 - function go(y) { 16 + export function go(y) { 15 17 let x = 1.0; 16 18 return x === y; 17 19 }
+9 -7
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__float_literals.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n 1.5\n 2.0\n -0.1\n 1.\n}\n" 3 + assertion_line: 23 4 + expression: "\npub fn go() {\n 1.5\n 2.0\n -0.1\n 1.\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 8 - 1.5 9 - 2.0 10 - -0.1 11 - 1. 9 + pub fn go() { 10 + 1.5 11 + 2.0 12 + -0.1 13 + 1. 12 14 } 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go() { 18 + export function go() { 17 19 1.5; 18 20 2.0; 19 21 -0.1;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__float_operators.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n 1.0 +. 1.4 // => 2.4\n 5.0 -. 1.5 // => 3.5\n 5.0 /. 2.0 // => 2.5\n 3.0 *. 3.1 // => 9.3\n\n 2.0 >. 1.0 // => True\n 2.0 <. 1.0 // => False\n 2.0 >=. 1.0 // => True\n 2.0 <=. 1.0 // => False\n}\n" 3 + assertion_line: 102 4 + expression: "\npub fn go() {\n 1.0 +. 1.4 // => 2.4\n 5.0 -. 1.5 // => 3.5\n 5.0 /. 2.0 // => 2.5\n 3.0 *. 3.1 // => 9.3\n\n 2.0 >. 1.0 // => True\n 2.0 <. 1.0 // => False\n 2.0 >=. 1.0 // => True\n 2.0 <=. 1.0 // => False\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 1.0 +. 1.4 // => 2.4 9 11 5.0 -. 1.5 // => 3.5 10 12 5.0 /. 2.0 // => 2.5 ··· 20 22 ----- COMPILED JAVASCRIPT 21 23 import { divideFloat } from "../gleam.mjs"; 22 24 23 - function go() { 25 + export function go() { 24 26 1.0 + 1.4; 25 27 5.0 - 1.5; 26 28 divideFloat(5.0, 2.0);
+13 -11
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__float_scientific_literals.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n 0.01e-1\n 0.01e-0\n -10.01e-1\n -10.01e-0\n 100.001e523\n -100.001e-523\n 100.001e123_456_789\n -100.001e-123_456_789\n}\n" 3 + assertion_line: 37 4 + expression: "\npub fn go() {\n 0.01e-1\n 0.01e-0\n -10.01e-1\n -10.01e-0\n 100.001e523\n -100.001e-523\n 100.001e123_456_789\n -100.001e-123_456_789\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 8 - 0.01e-1 9 - 0.01e-0 10 - -10.01e-1 11 - -10.01e-0 12 - 100.001e523 13 - -100.001e-523 14 - 100.001e123_456_789 15 - -100.001e-123_456_789 9 + pub fn go() { 10 + 0.01e-1 11 + 0.01e-0 12 + -10.01e-1 13 + -10.01e-0 14 + 100.001e523 15 + -100.001e-523 16 + 100.001e123_456_789 17 + -100.001e-123_456_789 16 18 } 17 19 18 20 19 21 ----- COMPILED JAVASCRIPT 20 - function go() { 22 + export function go() { 21 23 0.01e-1; 22 24 0.01e-0; 23 25 -10.01e-1;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__int_divide_complex_expr.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n case 1 >= 0 {\n True -> 2\n False -> 4\n } / 2\n}\n" 3 + assertion_line: 74 4 + expression: "\npub fn go() {\n case 1 >= 0 {\n True -> 2\n False -> 4\n } / 2\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 case 1 >= 0 { 9 11 True -> 2 10 12 False -> 4 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { divideInt } from "../gleam.mjs"; 17 19 18 - function go() { 20 + export function go() { 19 21 return divideInt( 20 22 (() => { 21 23 let $ = 1 >= 0;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__int_equality.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n 1 != 2\n 1 == 2\n}\n" 3 + assertion_line: 157 4 + expression: "\npub fn go() {\n 1 != 2\n 1 == 2\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 1 != 2 9 11 1 == 2 10 12 } 11 13 12 14 13 15 ----- COMPILED JAVASCRIPT 14 - function go() { 16 + export function go() { 15 17 1 !== 2; 16 18 return 1 === 2; 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__int_equality1.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go(y) {\n let x = 1\n x == y\n}\n" 3 + assertion_line: 169 4 + expression: "\npub fn go(y) {\n let x = 1\n x == y\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(y) { 9 + pub fn go(y) { 8 10 let x = 1 9 11 x == y 10 12 } 11 13 12 14 13 15 ----- COMPILED JAVASCRIPT 14 - function go(y) { 16 + export function go(y) { 15 17 let x = 1; 16 18 return x === y; 17 19 }
+13 -11
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__int_literals.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n 1\n 2\n -3\n 4001\n 0b00001111\n 0o17\n 0xF\n 1_000\n}\n" 3 + assertion_line: 5 4 + expression: "\npub fn go() {\n 1\n 2\n -3\n 4001\n 0b00001111\n 0o17\n 0xF\n 1_000\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 8 - 1 9 - 2 10 - -3 11 - 4001 12 - 0b00001111 13 - 0o17 14 - 0xF 15 - 1_000 9 + pub fn go() { 10 + 1 11 + 2 12 + -3 13 + 4001 14 + 0b00001111 15 + 0o17 16 + 0xF 17 + 1_000 16 18 } 17 19 18 20 19 21 ----- COMPILED JAVASCRIPT 20 - function go() { 22 + export function go() { 21 23 1; 22 24 2; 23 25 -3;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__int_mod_complex_expr.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n case 1 >= 0 {\n True -> 2\n False -> 4\n } % 2\n}\n" 3 + assertion_line: 88 4 + expression: "\npub fn go() {\n case 1 >= 0 {\n True -> 2\n False -> 4\n } % 2\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 case 1 >= 0 { 9 11 True -> 2 10 12 False -> 4 ··· 15 17 ----- COMPILED JAVASCRIPT 16 18 import { remainderInt } from "../gleam.mjs"; 17 19 18 - function go() { 20 + export function go() { 19 21 return remainderInt( 20 22 (() => { 21 23 let $ = 1 >= 0;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__int_negation.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n let a = 3\n let b = -a\n}\n" 3 + assertion_line: 227 4 + expression: "\npub fn go() {\n let a = 3\n let b = -a\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 let a = 3 9 11 let b = -a 10 12 } 11 13 12 14 13 15 ----- COMPILED JAVASCRIPT 14 - function go() { 16 + export function go() { 15 17 let a = 3; 16 18 let b = - a; 17 19 return b;
+14 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__int_operators.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n 1 + 1 // => 2\n 5 - 1 // => 4\n 5 / 2 // => 2\n 3 * 3 // => 9\n 5 % 2 // => 1\n 2 > 1 // => True\n 2 < 1 // => False\n 2 >= 1 // => True\n 2 <= 1 // => False\n}\n" 3 + assertion_line: 55 4 + expression: "\npub fn go() {\n 1 + 1 // => 2\n 5 - 1 // => 4\n 5 / 2 // => 2\n 3 * 3 // => 9\n 5 % 2 // => 1\n 2 > 1 // => True\n 2 < 1 // => False\n 2 >= 1 // => True\n 2 <= 1 // => False\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 8 - 1 + 1 // => 2 9 - 5 - 1 // => 4 10 - 5 / 2 // => 2 11 - 3 * 3 // => 9 12 - 5 % 2 // => 1 13 - 2 > 1 // => True 14 - 2 < 1 // => False 15 - 2 >= 1 // => True 16 - 2 <= 1 // => False 9 + pub fn go() { 10 + 1 + 1 // => 2 11 + 5 - 1 // => 4 12 + 5 / 2 // => 2 13 + 3 * 3 // => 9 14 + 5 % 2 // => 1 15 + 2 > 1 // => True 16 + 2 < 1 // => False 17 + 2 >= 1 // => True 18 + 2 <= 1 // => False 17 19 } 18 20 19 21 20 22 ----- COMPILED JAVASCRIPT 21 23 import { remainderInt, divideInt } from "../gleam.mjs"; 22 24 23 - function go() { 25 + export function go() { 24 26 1 + 1; 25 27 5 - 1; 26 28 divideInt(5, 2);
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__int_patterns.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 3 assertion_line: 146 4 - expression: "\nfn go(x) {\n let assert 4 = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert 4 = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert 4 = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x !== 4) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 30, pattern_start: 25, pattern_end: 26 } 28 + { value: x, start: 18, end: 34, pattern_start: 29, pattern_end: 30 } 29 29 ) 30 30 } 31 31 return x;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__operator_precedence.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n 2.4 *. { 3.5 +. 6.0 }\n}\n" 3 + assertion_line: 205 4 + expression: "\npub fn go() {\n 2.4 *. { 3.5 +. 6.0 }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 2.4 *. { 3.5 +. 6.0 } 9 11 } 10 12 11 13 12 14 ----- COMPILED JAVASCRIPT 13 - function go() { 15 + export function go() { 14 16 return 2.4 * (3.5 + 6.0); 15 17 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__preceeding_zeros_float.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn main() {\n 09_179.1\n}\n" 3 + assertion_line: 264 4 + expression: "\npub fn main() {\n 09_179.1\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn main() { 9 + pub fn main() { 8 10 09_179.1 9 11 } 10 12 11 13 12 14 ----- COMPILED JAVASCRIPT 13 - function main() { 15 + export function main() { 14 16 return 9_179.1; 15 17 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__preceeding_zeros_float_const.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nconst x = 09_179.1\n" 3 + assertion_line: 286 4 + expression: "\npub const x = 09_179.1\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - const x = 09_179.1 9 + pub const x = 09_179.1 8 10 9 11 10 12 ----- COMPILED JAVASCRIPT 11 - const x = 9_179.1; 13 + export const x = 9_179.1;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__preceeding_zeros_float_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 3 assertion_line: 308 4 - expression: "\nfn main(x) {\n let assert 09_179.1 = x\n}\n" 4 + expression: "\npub fn main(x) {\n let assert 09_179.1 = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn main(x) { 9 + pub fn main(x) { 10 10 let assert 09_179.1 = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function main(x) { 19 + export function main(x) { 20 20 if (x !== 9_179.1) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "main", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 16, end: 39, pattern_start: 27, pattern_end: 35 } 28 + { value: x, start: 20, end: 43, pattern_start: 31, pattern_end: 39 } 29 29 ) 30 30 } 31 31 return x;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__preceeding_zeros_int.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn main() {\n 09_179\n}\n" 3 + assertion_line: 252 4 + expression: "\npub fn main() {\n 09_179\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn main() { 9 + pub fn main() { 8 10 09_179 9 11 } 10 12 11 13 12 14 ----- COMPILED JAVASCRIPT 13 - function main() { 15 + export function main() { 14 16 return 9_179; 15 17 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__preceeding_zeros_int_const.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nconst x = 09_179\n" 3 + assertion_line: 276 4 + expression: "\npub const x = 09_179\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - const x = 09_179 9 + pub const x = 09_179 8 10 9 11 10 12 ----- COMPILED JAVASCRIPT 11 - const x = 9_179; 13 + export const x = 9_179;
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__preceeding_zeros_int_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 3 assertion_line: 296 4 - expression: "\nfn main(x) {\n let assert 09_179 = x\n}\n" 4 + expression: "\npub fn main(x) {\n let assert 09_179 = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn main(x) { 9 + pub fn main(x) { 10 10 let assert 09_179 = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function main(x) { 19 + export function main(x) { 20 20 if (x !== 9_179) { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "main", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 16, end: 37, pattern_start: 27, pattern_end: 33 } 28 + { value: x, start: 20, end: 41, pattern_start: 31, pattern_end: 37 } 29 29 ) 30 30 } 31 31 return x;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__remainder.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n 5 % 0 // => 0\n}\n" 3 + assertion_line: 216 4 + expression: "\npub fn go() {\n 5 % 0 // => 0\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 5 % 0 // => 0 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { remainderInt } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return remainderInt(5, 0); 17 19 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__repeated_int_negation.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n let a = 3\n let b = --a\n}\n" 3 + assertion_line: 239 4 + expression: "\npub fn go() {\n let a = 3\n let b = --a\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 let a = 3 9 11 let b = --a 10 12 } 11 13 12 14 13 15 ----- COMPILED JAVASCRIPT 14 - function go() { 16 + export function go() { 15 17 let a = 3; 16 18 let b = - - a; 17 19 return b;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__numbers__wide_float_div.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/numbers.rs 3 - expression: "\nfn go() {\n 111111111111111111111111111111. /. 22222222222222222222222222222222222.\n}\n" 3 + assertion_line: 135 4 + expression: "\npub fn go() {\n 111111111111111111111111111111. /. 22222222222222222222222222222222222.\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 111111111111111111111111111111. /. 22222222222222222222222222222222222. 9 11 } 10 12 ··· 12 14 ----- COMPILED JAVASCRIPT 13 15 import { divideFloat } from "../gleam.mjs"; 14 16 15 - function go() { 17 + export function go() { 16 18 return divideFloat( 17 19 111111111111111111111111111111., 18 20 22222222222222222222222222222222222.
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__panic__as_expression.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/panic.rs 3 3 assertion_line: 39 4 - expression: "\nfn go(f) {\n let boop = panic\n f(panic)\n}\n" 4 + expression: "\npub fn go(f) {\n let boop = panic\n f(panic)\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(f) { 9 + pub fn go(f) { 10 10 let boop = panic 11 11 f(panic) 12 12 } ··· 17 17 18 18 const FILEPATH = "src/module.gleam"; 19 19 20 - function go(f) { 20 + export function go(f) { 21 21 let _block; 22 22 throw makeError( 23 23 "panic",
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__panic__bare.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/panic.rs 3 3 assertion_line: 5 4 - expression: "\nfn go() {\n panic\n}\n" 4 + expression: "\npub fn go() {\n panic\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go() { 9 + pub fn go() { 10 10 panic 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go() { 19 + export function go() { 20 20 throw makeError( 21 21 "panic", 22 22 FILEPATH,
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__panic__case.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/panic.rs 3 3 assertion_line: 74 4 - expression: "\nfn go(x) {\n case x {\n _ -> panic\n }\n}\n" 4 + expression: "\npub fn go(x) {\n case x {\n _ -> panic\n }\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 case x { 11 11 _ -> panic 12 12 } ··· 18 18 19 19 const FILEPATH = "src/module.gleam"; 20 20 21 - function go(x) { 21 + export function go(x) { 22 22 throw makeError( 23 23 "panic", 24 24 FILEPATH,
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__panic__panic_as.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/panic.rs 3 3 assertion_line: 16 4 - expression: "\nfn go() {\n let x = \"wibble\"\n panic as x\n}\n" 4 + expression: "\npub fn go() {\n let x = \"wibble\"\n panic as x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go() { 9 + pub fn go() { 10 10 let x = "wibble" 11 11 panic as x 12 12 } ··· 17 17 18 18 const FILEPATH = "src/module.gleam"; 19 19 20 - function go() { 20 + export function go() { 21 21 let x = "wibble"; 22 22 throw makeError("panic", FILEPATH, "my/mod", 4, "go", x, {}) 23 23 }
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__panic__pipe.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/panic.rs 3 3 assertion_line: 51 4 - expression: "\nfn go(f) {\n f |> panic\n}\n" 4 + expression: "\npub fn go(f) {\n f |> panic\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(f) { 9 + pub fn go(f) { 10 10 f |> panic 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(f) { 19 + export function go(f) { 20 20 let _pipe = f; 21 21 let _block; 22 22 throw makeError(
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__panic__sequence.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/panic.rs 3 3 assertion_line: 62 4 - expression: "\nfn go(at_the_disco) {\n panic\n at_the_disco\n}\n" 4 + expression: "\npub fn go(at_the_disco) {\n panic\n at_the_disco\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(at_the_disco) { 9 + pub fn go(at_the_disco) { 10 10 panic 11 11 at_the_disco 12 12 } ··· 17 17 18 18 const FILEPATH = "src/module.gleam"; 19 19 20 - function go(at_the_disco) { 20 + export function go(at_the_disco) { 21 21 throw makeError( 22 22 "panic", 23 23 FILEPATH,
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__strings__case.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/strings.rs 3 - expression: "\nfn go(a) {\n case a {\n \"\" -> 0\n \"one\" -> 1\n \"two\" -> 2\n _ -> 3\n }\n}\n" 3 + assertion_line: 84 4 + expression: "\npub fn go(a) {\n case a {\n \"\" -> 0\n \"one\" -> 1\n \"two\" -> 2\n _ -> 3\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(a) { 9 + pub fn go(a) { 8 10 case a { 9 11 "" -> 0 10 12 "one" -> 1 ··· 15 17 16 18 17 19 ----- COMPILED JAVASCRIPT 18 - function go(a) { 20 + export function go(a) { 19 21 if (a === "") { 20 22 return 0; 21 23 } else if (a === "one") {
+7 -5
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__strings__const_concat.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/strings.rs 3 - expression: "\nconst cute = \"cute\"\nconst cute_bee = cute <> \"bee\"\n\npub fn main() {\n cute_bee\n}\n" 3 + assertion_line: 230 4 + expression: "\npub const cute = \"cute\"\npub const cute_bee = cute <> \"bee\"\n\npub fn main() {\n cute_bee\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - const cute = "cute" 8 - const cute_bee = cute <> "bee" 9 + pub const cute = "cute" 10 + pub const cute_bee = cute <> "bee" 9 11 10 12 pub fn main() { 11 13 cute_bee ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - const cute = "cute"; 18 + export const cute = "cute"; 17 19 18 - const cute_bee = cute + "bee"; 20 + export const cute_bee = cute + "bee"; 19 21 20 22 export function main() { 21 23 return cute_bee;
+9 -7
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__strings__const_concat_multiple.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/strings.rs 3 - expression: "\nconst cute = \"cute\"\nconst cute_bee = cute <> \"bee\"\nconst cute_cute_bee_buzz = cute <> cute_bee <> \"buzz\"\n\npub fn main() {\n cute_cute_bee_buzz\n}\n" 3 + assertion_line: 244 4 + expression: "\npub const cute = \"cute\"\npub const cute_bee = cute <> \"bee\"\npub const cute_cute_bee_buzz = cute <> cute_bee <> \"buzz\"\n\npub fn main() {\n cute_cute_bee_buzz\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - const cute = "cute" 8 - const cute_bee = cute <> "bee" 9 - const cute_cute_bee_buzz = cute <> cute_bee <> "buzz" 9 + pub const cute = "cute" 10 + pub const cute_bee = cute <> "bee" 11 + pub const cute_cute_bee_buzz = cute <> cute_bee <> "buzz" 10 12 11 13 pub fn main() { 12 14 cute_cute_bee_buzz ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - const cute = "cute"; 19 + export const cute = "cute"; 18 20 19 - const cute_bee = cute + "bee"; 21 + export const cute_bee = cute + "bee"; 20 22 21 - const cute_cute_bee_buzz = cute + cute_bee + "buzz"; 23 + export const cute_cute_bee_buzz = cute + cute_bee + "buzz"; 22 24 23 25 export function main() { 24 26 return cute_cute_bee_buzz;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__strings__equality.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/strings.rs 3 - expression: "\nfn go(a) {\n a == \"ok\"\n a != \"ok\"\n a == a\n}\n" 3 + assertion_line: 71 4 + expression: "\npub fn go(a) {\n a == \"ok\"\n a != \"ok\"\n a == a\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(a) { 9 + pub fn go(a) { 8 10 a == "ok" 9 11 a != "ok" 10 12 a == a ··· 12 14 13 15 14 16 ----- COMPILED JAVASCRIPT 15 - function go(a) { 17 + export function go(a) { 16 18 a === "ok"; 17 19 a !== "ok"; 18 20 return a === a;
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__strings__string_concat.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/strings.rs 3 - expression: "\nfn go() {\n \"Hello, \" <> \"Joe\"\n}\n" 3 + assertion_line: 100 4 + expression: "\npub fn go() {\n \"Hello, \" <> \"Joe\"\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 "Hello, " <> "Joe" 9 11 } 10 12 11 13 12 14 ----- COMPILED JAVASCRIPT 13 - function go() { 15 + export function go() { 14 16 return "Hello, " + "Joe"; 15 17 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__strings__string_literals.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/strings.rs 3 - expression: "\nfn go() {\n \"Hello, Gleam!\"\n}\n" 3 + assertion_line: 49 4 + expression: "\npub fn go() {\n \"Hello, Gleam!\"\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 "Hello, Gleam!" 9 11 } 10 12 11 13 12 14 ----- COMPILED JAVASCRIPT 13 - function go() { 15 + export function go() { 14 16 return "Hello, Gleam!"; 15 17 }
+4 -4
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__strings__string_patterns.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/strings.rs 3 3 assertion_line: 60 4 - expression: "\nfn go(x) {\n let assert \"Hello\" = x\n}\n" 4 + expression: "\npub fn go(x) {\n let assert \"Hello\" = x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(x) { 9 + pub fn go(x) { 10 10 let assert "Hello" = x 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go(x) { 19 + export function go(x) { 20 20 if (x !== "Hello") { 21 21 throw makeError( 22 22 "let_assert", ··· 25 25 3, 26 26 "go", 27 27 "Pattern match failed, no pattern matched the value.", 28 - { value: x, start: 14, end: 36, pattern_start: 25, pattern_end: 32 } 28 + { value: x, start: 18, end: 40, pattern_start: 29, pattern_end: 36 } 29 29 ) 30 30 } 31 31 return x;
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__todo__as_expression.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/todo.rs 3 3 assertion_line: 51 4 - expression: "\nfn go(f) {\n let boop = todo as \"I should do this\"\n f(todo as \"Boom\")\n}\n" 4 + expression: "\npub fn go(f) {\n let boop = todo as \"I should do this\"\n f(todo as \"Boom\")\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go(f) { 9 + pub fn go(f) { 10 10 let boop = todo as "I should do this" 11 11 f(todo as "Boom") 12 12 } ··· 17 17 18 18 const FILEPATH = "src/module.gleam"; 19 19 20 - function go(f) { 20 + export function go(f) { 21 21 let _block; 22 22 throw makeError("todo", FILEPATH, "my/mod", 3, "go", "I should do this", {}) 23 23 let boop = _block;
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__todo__with_message.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/todo.rs 3 3 assertion_line: 27 4 - expression: "\nfn go() {\n todo as \"I should do this\"\n}\n" 4 + expression: "\npub fn go() {\n todo as \"I should do this\"\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go() { 9 + pub fn go() { 10 10 todo as "I should do this" 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go() { 19 + export function go() { 20 20 throw makeError("todo", FILEPATH, "my/mod", 3, "go", "I should do this", {}) 21 21 }
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__todo__with_message_expr.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/todo.rs 3 3 assertion_line: 38 4 - expression: "\nfn go() {\n let x = \"I should \" <> \"do this\"\n todo as x\n}\n" 4 + expression: "\npub fn go() {\n let x = \"I should \" <> \"do this\"\n todo as x\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go() { 9 + pub fn go() { 10 10 let x = "I should " <> "do this" 11 11 todo as x 12 12 } ··· 17 17 18 18 const FILEPATH = "src/module.gleam"; 19 19 20 - function go() { 20 + export function go() { 21 21 let x = "I should " + "do this"; 22 22 throw makeError("todo", FILEPATH, "my/mod", 4, "go", x, {}) 23 23 }
+3 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__todo__without_message.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/todo.rs 3 3 assertion_line: 5 4 - expression: "\nfn go() {\n todo\n}\n" 4 + expression: "\npub fn go() {\n todo\n}\n" 5 5 snapshot_kind: text 6 6 --- 7 7 ----- SOURCE CODE 8 8 9 - fn go() { 9 + pub fn go() { 10 10 todo 11 11 } 12 12 ··· 16 16 17 17 const FILEPATH = "src/module.gleam"; 18 18 19 - function go() { 19 + export function go() { 20 20 throw makeError( 21 21 "todo", 22 22 FILEPATH,
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__tuples__case.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/tuples.rs 3 - expression: "\nfn go(a) {\n case a {\n #(2, a) -> a\n #(1, 1) -> 1\n #(a, b) -> a + b\n }\n}\n" 3 + assertion_line: 122 4 + expression: "\npub fn go(a) {\n case a {\n #(2, a) -> a\n #(1, 1) -> 1\n #(a, b) -> a + b\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(a) { 9 + pub fn go(a) { 8 10 case a { 9 11 #(2, a) -> a 10 12 #(1, 1) -> 1 ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - function go(a) { 19 + export function go(a) { 18 20 let $ = a[0]; 19 21 if ($ === 2) { 20 22 let a$1 = a[1];
+11 -9
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__tuples__constant_tuples.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/tuples.rs 3 - expression: "\nconst a = \"Hello\"\nconst b = 1\nconst c = 2.0\nconst e = #(\"bob\", \"dug\")\n " 3 + assertion_line: 85 4 + expression: "\npub const a = \"Hello\"\npub const b = 1\npub const c = 2.0\npub const e = #(\"bob\", \"dug\")\n " 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - const a = "Hello" 8 - const b = 1 9 - const c = 2.0 10 - const e = #("bob", "dug") 9 + pub const a = "Hello" 10 + pub const b = 1 11 + pub const c = 2.0 12 + pub const e = #("bob", "dug") 11 13 12 14 13 15 ----- COMPILED JAVASCRIPT 14 - const a = "Hello"; 16 + export const a = "Hello"; 15 17 16 - const b = 1; 18 + export const b = 1; 17 19 18 - const c = 2.0; 20 + export const c = 2.0; 19 21 20 - const e = ["bob", "dug"]; 22 + export const e = ["bob", "dug"];
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__tuples__constant_tuples1.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/tuples.rs 3 - expression: "\nconst e = #(\n \"loooooooooooooong\", \"loooooooooooong\", \"loooooooooooooong\",\n \"loooooooooooooong\", \"loooooooooooong\", \"loooooooooooooong\",\n)\n" 3 + assertion_line: 97 4 + expression: "\npub const e = #(\n \"loooooooooooooong\", \"loooooooooooong\", \"loooooooooooooong\",\n \"loooooooooooooong\", \"loooooooooooong\", \"loooooooooooooong\",\n)\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - const e = #( 9 + pub const e = #( 8 10 "loooooooooooooong", "loooooooooooong", "loooooooooooooong", 9 11 "loooooooooooooong", "loooooooooooong", "loooooooooooooong", 10 12 ) 11 13 12 14 13 15 ----- COMPILED JAVASCRIPT 14 - const e = [ 16 + export const e = [ 15 17 "loooooooooooooong", 16 18 "loooooooooooong", 17 19 "loooooooooooooong",
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__tuples__nested_pattern.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/tuples.rs 3 - expression: "\nfn go(x) {\n case x {\n #(2, #(a, b)) -> a + b\n _ -> 1\n }\n}\n" 3 + assertion_line: 137 4 + expression: "\npub fn go(x) {\n case x {\n #(2, #(a, b)) -> a + b\n _ -> 1\n }\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go(x) { 9 + pub fn go(x) { 8 10 case x { 9 11 #(2, #(a, b)) -> a + b 10 12 _ -> 1 ··· 13 15 14 16 15 17 ----- COMPILED JAVASCRIPT 16 - function go(x) { 18 + export function go(x) { 17 19 let $ = x[0]; 18 20 if ($ === 2) { 19 21 let a = x[1][0];
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__tuples__tuple.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/tuples.rs 3 - expression: "\nfn go() {\n #(\"1\", \"2\", \"3\")\n}\n" 3 + assertion_line: 5 4 + expression: "\npub fn go() {\n #(\"1\", \"2\", \"3\")\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 #("1", "2", "3") 9 11 } 10 12 11 13 12 14 ----- COMPILED JAVASCRIPT 13 - function go() { 15 + export function go() { 14 16 return ["1", "2", "3"]; 15 17 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__tuples__tuple1.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/tuples.rs 3 - expression: "\nfn go() {\n #(\n \"1111111111111111111111111111111\",\n #(\"1111111111111111111111111111111\", \"2\", \"3\"),\n \"3\",\n )\n}\n" 3 + assertion_line: 16 4 + expression: "\npub fn go() {\n #(\n \"1111111111111111111111111111111\",\n #(\"1111111111111111111111111111111\", \"2\", \"3\"),\n \"3\",\n )\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 #( 9 11 "1111111111111111111111111111111", 10 12 #("1111111111111111111111111111111", "2", "3"), ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - function go() { 19 + export function go() { 18 20 return [ 19 21 "1111111111111111111111111111111", 20 22 ["1111111111111111111111111111111", "2", "3"],
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__tuples__tuple_access.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/tuples.rs 3 - expression: "\nfn go() {\n #(1, 2).0\n}\n" 3 + assertion_line: 42 4 + expression: "\npub fn go() {\n #(1, 2).0\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 #(1, 2).0 9 11 } 10 12 11 13 12 14 ----- COMPILED JAVASCRIPT 13 - function go() { 15 + export function go() { 14 16 return [1, 2][0]; 15 17 }
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__tuples__tuple_with_block_element.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/tuples.rs 3 - expression: "\nfn go() {\n #(\n \"1\",\n {\n \"2\"\n \"3\"\n },\n )\n}\n" 3 + assertion_line: 53 4 + expression: "\npub fn go() {\n #(\n \"1\",\n {\n \"2\"\n \"3\"\n },\n )\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 #( 9 11 "1", 10 12 { ··· 16 18 17 19 18 20 ----- COMPILED JAVASCRIPT 19 - function go() { 21 + export function go() { 20 22 return [ 21 23 "1", 22 24 (() => {
+5 -3
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__tuples__tuple_with_block_element1.snap
··· 1 1 --- 2 2 source: compiler-core/src/javascript/tests/tuples.rs 3 - expression: "\nfn go() {\n #(\n \"1111111111111111111111111111111\",\n #(\"1111111111111111111111111111111\", \"2\", \"3\"),\n \"3\",\n )\n}\n" 3 + assertion_line: 70 4 + expression: "\npub fn go() {\n #(\n \"1111111111111111111111111111111\",\n #(\"1111111111111111111111111111111\", \"2\", \"3\"),\n \"3\",\n )\n}\n" 5 + snapshot_kind: text 4 6 --- 5 7 ----- SOURCE CODE 6 8 7 - fn go() { 9 + pub fn go() { 8 10 #( 9 11 "1111111111111111111111111111111", 10 12 #("1111111111111111111111111111111", "2", "3"), ··· 14 16 15 17 16 18 ----- COMPILED JAVASCRIPT 17 - function go() { 19 + export function go() { 18 20 return [ 19 21 "1111111111111111111111111111111", 20 22 ["1111111111111111111111111111111", "2", "3"],
+10 -10
compiler-core/src/javascript/tests/strings.rs
··· 48 48 fn string_literals() { 49 49 assert_js!( 50 50 r#" 51 - fn go() { 51 + pub fn go() { 52 52 "Hello, Gleam!" 53 53 } 54 54 "#, ··· 59 59 fn string_patterns() { 60 60 assert_js!( 61 61 r#" 62 - fn go(x) { 62 + pub fn go(x) { 63 63 let assert "Hello" = x 64 64 } 65 65 "#, ··· 70 70 fn equality() { 71 71 assert_js!( 72 72 r#" 73 - fn go(a) { 73 + pub fn go(a) { 74 74 a == "ok" 75 75 a != "ok" 76 76 a == a ··· 83 83 fn case() { 84 84 assert_js!( 85 85 r#" 86 - fn go(a) { 86 + pub fn go(a) { 87 87 case a { 88 88 "" -> 0 89 89 "one" -> 1 ··· 99 99 fn string_concat() { 100 100 assert_js!( 101 101 r#" 102 - fn go() { 102 + pub fn go() { 103 103 "Hello, " <> "Joe" 104 104 } 105 105 "#, ··· 229 229 fn const_concat() { 230 230 assert_js!( 231 231 r#" 232 - const cute = "cute" 233 - const cute_bee = cute <> "bee" 232 + pub const cute = "cute" 233 + pub const cute_bee = cute <> "bee" 234 234 235 235 pub fn main() { 236 236 cute_bee ··· 243 243 fn const_concat_multiple() { 244 244 assert_js!( 245 245 r#" 246 - const cute = "cute" 247 - const cute_bee = cute <> "bee" 248 - const cute_cute_bee_buzz = cute <> cute_bee <> "buzz" 246 + pub const cute = "cute" 247 + pub const cute_bee = cute <> "bee" 248 + pub const cute_cute_bee_buzz = cute <> cute_bee <> "buzz" 249 249 250 250 pub fn main() { 251 251 cute_cute_bee_buzz
+4 -4
compiler-core/src/javascript/tests/todo.rs
··· 4 4 fn without_message() { 5 5 assert_js!( 6 6 r#" 7 - fn go() { 7 + pub fn go() { 8 8 todo 9 9 } 10 10 "#, ··· 26 26 fn with_message() { 27 27 assert_js!( 28 28 r#" 29 - fn go() { 29 + pub fn go() { 30 30 todo as "I should do this" 31 31 } 32 32 "#, ··· 37 37 fn with_message_expr() { 38 38 assert_js!( 39 39 r#" 40 - fn go() { 40 + pub fn go() { 41 41 let x = "I should " <> "do this" 42 42 todo as x 43 43 } ··· 50 50 fn as_expression() { 51 51 assert_js!( 52 52 r#" 53 - fn go(f) { 53 + pub fn go(f) { 54 54 let boop = todo as "I should do this" 55 55 f(todo as "Boom") 56 56 }
+12 -12
compiler-core/src/javascript/tests/tuples.rs
··· 4 4 fn tuple() { 5 5 assert_js!( 6 6 r#" 7 - fn go() { 7 + pub fn go() { 8 8 #("1", "2", "3") 9 9 } 10 10 "#, ··· 15 15 fn tuple1() { 16 16 assert_js!( 17 17 r#" 18 - fn go() { 18 + pub fn go() { 19 19 #( 20 20 "1111111111111111111111111111111", 21 21 #("1111111111111111111111111111111", "2", "3"), ··· 41 41 fn tuple_access() { 42 42 assert_js!( 43 43 r#" 44 - fn go() { 44 + pub fn go() { 45 45 #(1, 2).0 46 46 } 47 47 "#, ··· 52 52 fn tuple_with_block_element() { 53 53 assert_js!( 54 54 r#" 55 - fn go() { 55 + pub fn go() { 56 56 #( 57 57 "1", 58 58 { ··· 69 69 fn tuple_with_block_element1() { 70 70 assert_js!( 71 71 r#" 72 - fn go() { 72 + pub fn go() { 73 73 #( 74 74 "1111111111111111111111111111111", 75 75 #("1111111111111111111111111111111", "2", "3"), ··· 84 84 fn constant_tuples() { 85 85 assert_js!( 86 86 r#" 87 - const a = "Hello" 88 - const b = 1 89 - const c = 2.0 90 - const e = #("bob", "dug") 87 + pub const a = "Hello" 88 + pub const b = 1 89 + pub const c = 2.0 90 + pub const e = #("bob", "dug") 91 91 "#, 92 92 ); 93 93 } ··· 96 96 fn constant_tuples1() { 97 97 assert_js!( 98 98 r#" 99 - const e = #( 99 + pub const e = #( 100 100 "loooooooooooooong", "loooooooooooong", "loooooooooooooong", 101 101 "loooooooooooooong", "loooooooooooong", "loooooooooooooong", 102 102 ) ··· 121 121 fn case() { 122 122 assert_js!( 123 123 r#" 124 - fn go(a) { 124 + pub fn go(a) { 125 125 case a { 126 126 #(2, a) -> a 127 127 #(1, 1) -> 1 ··· 136 136 fn nested_pattern() { 137 137 assert_js!( 138 138 r#" 139 - fn go(x) { 139 + pub fn go(x) { 140 140 case x { 141 141 #(2, #(a, b)) -> a + b 142 142 _ -> 1