From b4e07b4f0586a5fd7f6ad737146d3bb940bf15d0 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 1 Apr 2022 18:07:01 -0700 Subject: [PATCH 1/2] add test for sdo defined over unknown productions --- test/errors.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/test/errors.js b/test/errors.js index b55c16d7..15d89219 100644 --- a/test/errors.js +++ b/test/errors.js @@ -3,7 +3,7 @@ let assert = require('assert'); let emu = require('../lib/ecmarkup'); -let { lintLocationMarker: M, positioned, assertError } = require('./utils.js'); +let { lintLocationMarker: M, positioned, assertError, assertErrorFree } = require('./utils.js'); describe('errors', () => { it('no contributors', async () => { @@ -932,4 +932,73 @@ ${M} { asImport: 'only' } ); }); + + describe('SDO defined over unknown production', () => { + it('unknown production', async () => { + await assertError( + positioned` + +

Static Semantics: Example

+
+ ${M} + Foo : \`a\` + + + 1. Return *true*. + +
+ `, + { + ruleId: 'grammar-shape', + nodeType: 'emu-grammar', + message: 'could not find definition corresponding to production Foo', + } + ); + }); + + it('unknown rhs', async () => { + await assertError( + positioned` + + Foo : \`b\` + + + +

Static Semantics: Example

+
+ ${M} + Foo : \`a\` + + + 1. Return *true*. + +
+ `, + { + ruleId: 'grammar-shape', + nodeType: 'emu-grammar', + message: 'could not find definition for rhs a', + } + ); + }); + + it('negative', async () => { + await assertErrorFree(` + + Foo : \`a\` + + + +

Static Semantics: Example

+
+ + Foo : \`a\` + + + 1. Return *true*. + +
+ `); + }); + }); }); From ae55b96c7f2c2a16430daf484a86e034016e8fcf Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 1 Apr 2022 18:07:53 -0700 Subject: [PATCH 2/2] suppress error for unknown productions which are defined in an external biblio --- src/Spec.ts | 6 ++++++ test/errors.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/Spec.ts b/src/Spec.ts index 11959311..1e3edebf 100644 --- a/src/Spec.ts +++ b/src/Spec.ts @@ -1624,6 +1624,12 @@ ${this.opts.multipage ? `
  • Navigate to/from multipagem `); }); + + it('negative: external biblio', async () => { + let upstream = await emu.build( + 'root.html', + () => ` + + Foo : \`a\` + + `, + { + copyright: false, + location: 'https://example.com/spec/', + warn: e => { + console.error('Error:', e); + throw new Error(e.message); + }, + } + ); + let upstreamBiblio = upstream.exportBiblio(); + + await assertErrorFree( + ` + +

    Static Semantics: Example

    +
    + + Foo : \`a\` + + + 1. Return *true*. + +
    + `, + { + extraBiblios: [upstreamBiblio], + } + ); + }); }); });