(op: WriteOp, expected: number[], reads: SuccessfulRead[])
| 50 | } |
| 51 | |
| 52 | function applyExpected(op: WriteOp, expected: number[], reads: SuccessfulRead[]): void { |
| 53 | if (op.kind === "u8") { |
| 54 | expected.push(op.value & 0xff); |
| 55 | reads.push({ kind: "u8", value: op.value & 0xff }); |
| 56 | return; |
| 57 | } |
| 58 | if (op.kind === "u32") { |
| 59 | appendLeU32(expected, op.value); |
| 60 | reads.push({ kind: "u32", value: op.value >>> 0 }); |
| 61 | return; |
| 62 | } |
| 63 | if (op.kind === "i32") { |
| 64 | appendLeI32(expected, op.value); |
| 65 | reads.push({ kind: "i32", value: op.value | 0 }); |
| 66 | return; |
| 67 | } |
| 68 | if (op.kind === "bytes") { |
| 69 | expected.push(...op.bytes); |
| 70 | reads.push({ kind: "bytes", bytes: op.bytes }); |
| 71 | return; |
| 72 | } |
| 73 | |
| 74 | const before = expected.length; |
| 75 | const aligned = (before + 3) & ~3; |
| 76 | while (expected.length < aligned) expected.push(0); |
| 77 | if (aligned > before) reads.push({ kind: "skip", len: aligned - before }); |
| 78 | } |
| 79 | |
| 80 | function applyWriter(writer: BinaryWriter, op: WriteOp): void { |
| 81 | if (op.kind === "u8") { |
no test coverage detected