From 35d62d94c356a04419d3fac757ffb519582d8ad3 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Wed, 7 Sep 2022 08:55:01 -0700 Subject: [PATCH] add test --- test/lint-variable-use-def.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/lint-variable-use-def.js b/test/lint-variable-use-def.js index 4db11e91..ea7029c7 100644 --- a/test/lint-variable-use-def.js +++ b/test/lint-variable-use-def.js @@ -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` + + 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. + + `, + { + ruleId: 'use-before-def', + nodeType: 'emu-alg', + message: 'could not find a preceding declaration for "b"', + } + ); + + await assertLint( + positioned` + + 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. + + `, + { + 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`