Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Sep 5, 2022
1 parent 28f81c5 commit 23e5a62
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 6 deletions.
21 changes: 20 additions & 1 deletion test/expr-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('expression parsing', () => {
it('calls', async () => {
await assertLintFree(`
<emu-alg>
1. Let _foo_ be a variable.
1. Let _x_ be _foo_().
1. Set _x_ to _foo_( ).
1. Set _x_ to _foo_.[[Bar]]().
Expand All @@ -41,8 +42,9 @@ describe('expression parsing', () => {
it('record-spec', async () => {
await assertLintFree(`
<emu-alg>
1. Let _entries_ be a List.
1. For each Record { [[Key]], [[Value]] } _p_ of _entries_, do
1. Something.
1. Use _p_.
</emu-alg>
`);
});
Expand All @@ -54,17 +56,20 @@ describe('expression parsing', () => {
0,
1,
».
1. Use _x_.
</emu-alg>
`);
});

it('trailing comma in multi-line call', async () => {
await assertLintFree(`
<emu-alg>
1. Let _foo_ be a function.
1. Let _x_ be _foo_(
0,
1,
).
1. Use _x_.
</emu-alg>
`);
});
Expand All @@ -76,6 +81,7 @@ describe('expression parsing', () => {
[[X]]: 0,
[[Y]]: 1,
}.
1. Use _x_.
</emu-alg>
`);
});
Expand All @@ -87,6 +93,7 @@ describe('expression parsing', () => {
1. Let _x_ be a new Record { [[Foo]]: 0, <ins>[[Bar]]: 1</ins> }.
1. Let _x_ be a new Record { [[Foo]]: 0, <ins>[[Bar]]: 1, [[Baz]]: 2</ins> }.
1. Let _x_ be a new Record { [[Foo]]: 0, <ins>[[Bar]]: 1,</ins> [[Baz]]: 2 }.
1. Use _x_.
</emu-alg>
`);
});
Expand Down Expand Up @@ -127,7 +134,9 @@ describe('expression parsing', () => {
await assertLint(
positioned`
<emu-alg>
1. Let _foo_ and _a_ be variables.
1. Let _x_ be «_foo_(_a_${M}»).
1. Use _x_.
</emu-alg>
`,
{
Expand All @@ -143,6 +152,7 @@ describe('expression parsing', () => {
positioned`
<emu-alg>
1. Let _x_ be «${M},».
1. Use _x_.
</emu-alg>
`,
{
Expand Down Expand Up @@ -170,7 +180,9 @@ describe('expression parsing', () => {
await assertLint(
positioned`
<emu-alg>
1. Let _foo_ be a function.
1. Let _x_ be _foo_(${M},)».
1. Use _x_.
</emu-alg>
`,
{
Expand All @@ -183,7 +195,9 @@ describe('expression parsing', () => {
await assertLint(
positioned`
<emu-alg>
1. Let _foo_ and _a_ be variables.
1. Let _x_ be _foo_(_a_, ${M}).
1. Use _x_.
</emu-alg>
`,
{
Expand All @@ -199,6 +213,7 @@ describe('expression parsing', () => {
positioned`
<emu-alg>
1. Let _x_ be the Record { ${M}}.
1. Use _x_.
</emu-alg>
`,
{
Expand All @@ -214,6 +229,7 @@ describe('expression parsing', () => {
positioned`
<emu-alg>
1. Let _x_ be the Record { ${M}[x]: 0 }.
1. Use _x_.
</emu-alg>
`,
{
Expand All @@ -229,6 +245,7 @@ describe('expression parsing', () => {
positioned`
<emu-alg>
1. Let _x_ be the Record { [[A]]: 0, [[${M}A]]: 0 }.
1. Use _x_.
</emu-alg>
`,
{
Expand All @@ -244,6 +261,7 @@ describe('expression parsing', () => {
positioned`
<emu-alg>
1. Let _x_ be the Record { [[A]], [[B]]${M}: 0 }.
1. Use _x_.
</emu-alg>
`,
{
Expand All @@ -257,6 +275,7 @@ describe('expression parsing', () => {
positioned`
<emu-alg>
1. Let _x_ be the Record { [[A]]: 0, [[B]]${M} }.
1. Use _x_.
</emu-alg>
`,
{
Expand Down
15 changes: 14 additions & 1 deletion test/lint-algorithms.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('linting algorithms', () => {
it('repeat', async () => {
await assertLint(
positioned`<emu-alg>
1. Let _x_ be a variable.
1. Repeat, while _x_ < 10${M}
1. Foo.
</emu-alg>`,
Expand All @@ -59,6 +60,7 @@ describe('linting algorithms', () => {
it('inline if', async () => {
await assertLint(
positioned`<emu-alg>
1. Let _x_ be a variable.
1. If _x_, then${M}
</emu-alg>`,
{
Expand All @@ -72,6 +74,7 @@ describe('linting algorithms', () => {
it('inline if-then', async () => {
await assertLint(
positioned`<emu-alg>
1. Let _x_ be a variable.
1. If _x_, ${M}then do something.
</emu-alg>`,
{
Expand All @@ -85,6 +88,7 @@ describe('linting algorithms', () => {
it('multiline if', async () => {
await assertLint(
positioned`<emu-alg>
1. Let _x_ be a variable.
1. If _x_,${M}
1. Foo.
</emu-alg>`,
Expand All @@ -97,6 +101,7 @@ describe('linting algorithms', () => {

await assertLint(
positioned`<emu-alg>
1. Let _x_ be a variable.
1. If _x_${M}; then
1. Foo.
</emu-alg>`,
Expand All @@ -112,6 +117,7 @@ describe('linting algorithms', () => {
it('else if', async () => {
await assertLint(
positioned`<emu-alg>
1. Let _x_ and _y_ be variables.
1. If _x_, foo.
1. Else${M}, if _y_, bar.
</emu-alg>`,
Expand Down Expand Up @@ -199,6 +205,7 @@ describe('linting algorithms', () => {
1. ${M}Let _constructorText_ be the source text
<pre><code class="javascript">constructor() {}</code></pre>
1. Foo.
1. Use _constructorText_.
</emu-alg>`,
{
ruleId,
Expand All @@ -219,6 +226,7 @@ describe('linting algorithms', () => {
it('negative', async () => {
await assertLintFree(`
<emu-alg>
1. Let _x_, _y_, and _z_ be variables.
1. If foo, bar.
1. Else if foo, bar.
1. Else, bar.
Expand Down Expand Up @@ -250,7 +258,9 @@ describe('linting algorithms', () => {
1. Substep.
1. Let _constructorText_ be the source text
<pre><code class="javascript">constructor() {}</code></pre>
1. Set _constructor_ to _parse_(_constructorText_, _methodDefinition_).
1. Let _parse_ be a method.
1. Let _constructor_ be a variable.
1. Set _constructor_ to _parse_(_constructorText_).
1. <mark>A highlighted line.</mark>
1. <ins>Amend the spec with this.</ins>
1. <del>Remove this from the spec.</del>
Expand Down Expand Up @@ -413,6 +423,7 @@ describe('linting algorithms', () => {
await assertLint(
positioned`
<emu-alg>
1. Let _y_ be a List.
1. For each ${M}_x_ of _y_, do foo.
</emu-alg>`,
{
Expand All @@ -426,6 +437,8 @@ describe('linting algorithms', () => {
it('negative', async () => {
await assertLintFree(`
<emu-alg>
1. Let _y_ be a List.
1. Let _S_ be a Set.
1. For each String _x_ of _y_, do foo.
1. For each element _x_ of _y_, do foo.
1. For each integer _x_ such that _x_ &in; _S_, do foo.
Expand Down
5 changes: 4 additions & 1 deletion test/lint-spelling.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ describe('spelling', () => {
it('*0*', async () => {
await assertLint(
positioned`
<emu-alg>1. If _x_ is ${M}*0*<sub>𝔽</sub>, do foo.</emu-alg>
<emu-alg>
1. Let _x_ be a value.
1. If _x_ is ${M}*0*<sub>𝔽</sub>, do foo.
</emu-alg>
`,
{
ruleId: 'spelling',
Expand Down
3 changes: 3 additions & 0 deletions test/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ describe('linting whole program', () => {
positioned`
<emu-alg>
1. Let _s_ be |${M}Example|.
1. Return _s_.
</emu-alg>
`,
{
Expand All @@ -503,6 +504,7 @@ describe('linting whole program', () => {
<emu-grammar>Statement: \`;\`</emu-grammar>
<emu-alg>
1. Let _s_ be |${M}Statements|.
1. Return _s_.
</emu-alg>
</emu-clause>
`,
Expand Down Expand Up @@ -554,6 +556,7 @@ describe('linting whole program', () => {
</emu-grammar>
<emu-alg>
1. Let _s_ be |Example1|.
1. Return _s_.
</emu-alg>
<p>Discuss: |Example1|.</p>
<p>Discuss: <emu-nt>Example1</emu-nt>.</p>
Expand Down
Loading

0 comments on commit 23e5a62

Please sign in to comment.