Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Sep 8, 2022
1 parent f4e0eb8 commit 35d62d9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/lint-variable-use-def.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,38 @@ describe('variables are declared and used appropriately', () => {
);
});

it('variables in a loop header other than the loop variable must be declared', async () => {
await assertLint(
positioned`
<emu-alg>
1. Let _c_ be a variable.
1. For each integer _a_ of ${M}_b_ such that _c_ relates to _a_ in some way, do
1. Something.
</emu-alg>
`,
{
ruleId: 'use-before-def',
nodeType: 'emu-alg',
message: 'could not find a preceding declaration for "b"',
}
);

await assertLint(
positioned`
<emu-alg>
1. Let _b_ be a variable.
1. For each integer _a_ of _b_ such that ${M}_c_ relates to _a_ in some way, do
1. Something.
</emu-alg>
`,
{
ruleId: 'use-before-def',
nodeType: 'emu-alg',
message: 'could not find a preceding declaration for "c"',
}
);
});

it('explicit "declared" annotations should not be redundant', async () => {
await assertLint(
positioned`
Expand Down

0 comments on commit 35d62d9

Please sign in to comment.