Skip to content

Commit

Permalink
feat: add test for SDBEGINSX and SDBEGINSXQ
Browse files Browse the repository at this point in the history
Fixes #35
  • Loading branch information
i582 committed Feb 16, 2025
1 parent 13f1206 commit 1356bc5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/test/e2e/__snapshots__/func.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@ PROGRAM{
}END>c"
`;

exports[`disassemble > should decompile SDBEGINSXQ correctly 1`] = `
""Asm.fif" include
PROGRAM{
DECLPROC recv_internal
recv_internal PROC:<{
NEWC
x{68656C6C6F20776F726C64} PUSHSLICE
STSLICER
ENDC
CTOS
NEWC
x{68656C6C6F} PUSHSLICE
STSLICER
ENDC
CTOS
DUP2
SDBEGINSX
ROTREV
SDBEGINSXQ
DROP2
}>
}END>c"
`;

exports[`disassemble > should decompile and compile back PUSHREF with bytes 1`] = `
""Asm.fif" include
PROGRAM{
Expand Down
23 changes: 23 additions & 0 deletions src/test/e2e/func.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@ describe("disassemble", () => {
`)
})

it("should decompile SDBEGINSXQ correctly", async () => {
await compileAndCheck(`
forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP";
builder begin_cell() asm "NEWC";
builder store_slice(builder b, slice s) asm "STSLICER";
cell end_cell(builder b) asm "ENDC";
slice begin_parse(cell c) asm "CTOS";
slice trim_prefix(slice where, slice prefix) asm "SDBEGINSX";
slice trim_prefix_quite(slice where, slice prefix) asm "SDBEGINSXQ";
() recv_internal() {
slice where = begin_cell().store_slice("hello world").end_cell().begin_parse();
slice prefix = begin_cell().store_slice("hello").end_cell().begin_parse();
slice result = trim_prefix(where, prefix);
slice result2 = trim_prefix_quite(where, prefix);
~impure_touch(result);
~impure_touch(result2);
}
`)
})

async function compileAndCheck(content: string) {
const funcRes = await compileFunc({
sources: [
Expand Down

0 comments on commit 1356bc5

Please sign in to comment.