import * as assert from 'assert'; import { Builder } from 'llparse-builder'; import { Container, ContainerWrap, Frontend, node } from '../src/frontend'; import implementation from './fixtures/a-implementation'; import { Node } from './fixtures/implementation/node/base'; describe('llparse-frontend/Container', () => { let b: Builder; beforeEach(() => { b = new Builder(); }); it('should translate nodes to implementation', () => { const comb = new Container(); comb.add('a', implementation); comb.add('b', implementation); const f = new Frontend('llparse', comb.build()); const root = b.node('root'); root.match('ab', root); root.match('acd', root); root.match('efg', root); root.otherwise(b.error(123, 'hello')); const fRoot = f.compile(root, []).root as ContainerWrap; const out: string[] = []; (fRoot.get('a') as Node).build(out); assert.deepStrictEqual(out, [ '', '', '', '', '', ]); }); });