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

Configure Feed

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

Add tests

+82
+32
compiler-core/src/javascript/tests/bit_arrays.rs
··· 2494 2494 "# 2495 2495 ); 2496 2496 } 2497 + 2498 + #[test] 2499 + fn unit_with_bits_option() { 2500 + assert_js!( 2501 + " 2502 + pub fn go(x) { 2503 + <<x:bits-size(4)-unit(8)>> 2504 + } 2505 + " 2506 + ); 2507 + } 2508 + 2509 + #[test] 2510 + fn unit_with_bits_option_constant() { 2511 + assert_js!( 2512 + " 2513 + pub const bits = <<1, 2, 3>> 2514 + pub const more_bits = <<bits:bits-size(3)-unit(8)>> 2515 + " 2516 + ); 2517 + } 2518 + 2519 + #[test] 2520 + fn operator_in_size_for_bit_array_segment() { 2521 + assert_js!( 2522 + " 2523 + pub fn go(x) { 2524 + <<x:bits-size(4 + 1)>> 2525 + } 2526 + " 2527 + ); 2528 + }
+17
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__operator_in_size_for_bit_array_segment.snap
··· 1 + --- 2 + source: compiler-core/src/javascript/tests/bit_arrays.rs 3 + expression: "\npub fn go(x) {\n <<x:bits-size(4 + 1)>>\n}\n" 4 + --- 5 + ----- SOURCE CODE 6 + 7 + pub fn go(x) { 8 + <<x:bits-size(4 + 1)>> 9 + } 10 + 11 + 12 + ----- COMPILED JAVASCRIPT 13 + import { toBitArray, bitArraySlice } from "../gleam.mjs"; 14 + 15 + export function go(x) { 16 + return toBitArray([bitArraySlice(x, 0, 4 + 1)]); 17 + }
+17
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__unit_with_bits_option.snap
··· 1 + --- 2 + source: compiler-core/src/javascript/tests/bit_arrays.rs 3 + expression: "\npub fn go(x) {\n <<x:bits-size(4)-unit(8)>>\n}\n" 4 + --- 5 + ----- SOURCE CODE 6 + 7 + pub fn go(x) { 8 + <<x:bits-size(4)-unit(8)>> 9 + } 10 + 11 + 12 + ----- COMPILED JAVASCRIPT 13 + import { toBitArray, bitArraySlice } from "../gleam.mjs"; 14 + 15 + export function go(x) { 16 + return toBitArray([bitArraySlice(x, 0, 32)]); 17 + }
+16
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bit_arrays__unit_with_bits_option_constant.snap
··· 1 + --- 2 + source: compiler-core/src/javascript/tests/bit_arrays.rs 3 + expression: "\npub const bits = <<1, 2, 3>>\npub const more_bits = <<bits:bits-size(3)-unit(8)>>\n" 4 + --- 5 + ----- SOURCE CODE 6 + 7 + pub const bits = <<1, 2, 3>> 8 + pub const more_bits = <<bits:bits-size(3)-unit(8)>> 9 + 10 + 11 + ----- COMPILED JAVASCRIPT 12 + import { toBitArray, bitArraySlice } from "../gleam.mjs"; 13 + 14 + export const bits = /* @__PURE__ */ toBitArray([1, 2, 3]); 15 + 16 + export const more_bits = /* @__PURE__ */ toBitArray([bitArraySlice(bits, 0, 24)]);