Skip to content

Commit

Permalink
test: add a test to prevent it from happening
Browse files Browse the repository at this point in the history
  • Loading branch information
iyxan23 committed Sep 14, 2024
1 parent f12f8b5 commit 82a46f8
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/sheet/expression/extractor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,72 @@ describe("extractHoistsAndBlocks", () => {
],
});
});

it("should be able to label overlapping repeatRow and repeatCol blocks", () => {
const sheet = new Sheet<ExpressionCell>([
[
parseExpressionCell("a"),
parseExpressionCell("b"),
parseExpressionCell("[#repeatCol [:stuff length] col]"),
],
[
parseExpressionCell("[#repeatRow [:stuff length] row]"),
parseExpressionCell("repeating row"),
parseExpressionCell(
"intersection [:row] [:col] [/#repeatRow][/#repeatCol]",
),
],
]);

const collected = extractHoistsAndBlocks(...sheetAdapter(sheet));

console.log(JSON.stringify(collected, null, 2));
expect(collected).toEqual({
variableHoists: [],
blocks: [
{
identifier: "repeatCol",
innerBlocks: [],
arg: {
type: "variableAccess",
identifier: "stuff",
args: ["length"],
},
indexVariableIdentifier: "col",
direction: "col",
start: {
col: 2,
row: 0,
startsAt: 0,
},
end: {
col: 2,
row: 1,
endsAt: 6,
},
},
{
identifier: "repeatRow",
innerBlocks: [],
arg: {
type: "variableAccess",
identifier: "stuff",
args: ['length']
},
indexVariableIdentifier: "row",
direction: 'row',
start: {
col: 0,
row: 1,
startsAt: 0,
},
end: {
col: 2,
row: 1,
endsAt: 5,
}
}
],
});
});
});

0 comments on commit 82a46f8

Please sign in to comment.