tests dont test block (for line ending differences)

pull/26/head
Valerie 2021-05-23 18:21:09 -04:00
parent 8b6642e550
commit 6f8f279543
2 changed files with 49 additions and 25 deletions

View File

@ -10,7 +10,7 @@
"scripts": { "scripts": {
"dev": "multiview [ yarn test:watch ] [ yarn compile:watch ]", "dev": "multiview [ yarn test:watch ] [ yarn compile:watch ]",
"test": "c8 --all mocha", "test": "c8 --all mocha",
"test:watch": "supervisor -w src,test,.mocharc.json -n exit --extensions js,ts,node --exec yarn.cmd -- test", "test:watch": "supervisor -w src,test,.mocharc.json -n exit --extensions js,ts,node --exec yarn -- test",
"debug": "cross-env DEBUG=vogue:* yarn node --enable-source-maps --unhandled-rejections=strict out/run.js test", "debug": "cross-env DEBUG=vogue:* yarn node --enable-source-maps --unhandled-rejections=strict out/run.js test",
"debug:watch": "supervisor -w out,test/system/**/*.v,lib -n exit --exec yarn -- clear_and yarn debug", "debug:watch": "supervisor -w out,test/system/**/*.v,lib -n exit --exec yarn -- clear_and yarn debug",
"compile": "tsc", "compile": "tsc",

View File

@ -5,77 +5,101 @@ import * as ModuleFiles from './lib/ModuleFiles.js'
describe('Lexer', () => { describe('Lexer', () => {
it('parses blank file', () => { it('parses blank file', () => {
const ast = createAst(ModuleFiles.blank); const ast: any = createAst(ModuleFiles.blank);
expect(ast).to.deep.equal([]); expect(ast).to.deep.equal([]);
}); });
describe('namespaces', () => { describe('namespaces', () => {
it('parses namespaces without dots', () => { it('parses namespaces without dots', () => {
const ast = createAst(ModuleFiles.namespaceX); const ast: any = createAst(ModuleFiles.namespaceX);
expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x'}]); expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x'}]);
}); });
it('parses namespaces with a single dot', () => { it('parses namespaces with a single dot', () => {
const ast = createAst(ModuleFiles.namespaceXY); const ast: any = createAst(ModuleFiles.namespaceXY);
expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x.y'}]); expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x.y'}]);
}); });
it('parses namespaces two dots', () => { it('parses namespaces two dots', () => {
const ast = createAst(ModuleFiles.namespaceXYZ); const ast: any = createAst(ModuleFiles.namespaceXYZ);
expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x.y.z'}]); expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x.y.z'}]);
}); });
}); });
describe('links', () => { describe('links', () => {
it('parses link', () => { it('parses link', () => {
const ast = createAst(ModuleFiles.link); const ast: any = createAst(ModuleFiles.link);
expect(ast).to.deep.equal([{type: 'link', array: false, required: false, name: 'test'}]); expect(ast).to.deep.equal([{type: 'link', array: false, required: false, name: 'test'}]);
}); });
it('parses required link', () => { it('parses required link', () => {
const ast = createAst(ModuleFiles.requiredLink); const ast: any = createAst(ModuleFiles.requiredLink);
expect(ast).to.deep.equal([{type: 'link', array: false, required: true, name: 'test'}]); expect(ast).to.deep.equal([{type: 'link', array: false, required: true, name: 'test'}]);
}); });
it('parses link array', () => { it('parses link array', () => {
const ast = createAst(ModuleFiles.linkArray); const ast: any = createAst(ModuleFiles.linkArray);
expect(ast).to.deep.equal([{type: 'link', array: true, required: false, name: 'test'}]); expect(ast).to.deep.equal([{type: 'link', array: true, required: false, name: 'test'}]);
}); });
it('parses required link array', () => { it('parses required link array', () => {
const ast = createAst(ModuleFiles.requiredLinkArray); const ast: any = createAst(ModuleFiles.requiredLinkArray);
expect(ast).to.deep.equal([{type: 'link', array: true, required: true, name: 'test'}]); expect(ast).to.deep.equal([{type: 'link', array: true, required: true, name: 'test'}]);
}); });
}); });
describe('functions', () => { describe('functions', () => {
it('function with parameters omitted', () => { it('function with parameters omitted', () => {
const ast = createAst(ModuleFiles.functionNoParams); const ast: any = createAst(ModuleFiles.functionNoParams);
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: [], async: false}]); expect(ast).to.be.an('array').with.length(1);
expect(ast[0]).to.be.an('object');
expect(ast[0]).to.include({type: 'function', name: 'test', async: false});
expect(ast[0].parameters).to.be.an('array').of.length(0);
}); });
it('function with empty parameters', () => { it('function with empty parameters', () => {
const ast = createAst(ModuleFiles.functionEmptyParams); const ast: any = createAst(ModuleFiles.functionEmptyParams);
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: [], async: false}]); expect(ast).to.be.an('array').with.length(1);
expect(ast[0]).to.be.an('object');
expect(ast[0]).to.include({type: 'function', name: 'test', async: false});
expect(ast[0].parameters).to.be.an('array').of.length(0);
}); });
it('function with one parameter', () => { it('function with one parameter', () => {
const ast = createAst(ModuleFiles.functionOneParam); const ast: any = createAst(ModuleFiles.functionOneParam);
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: ["a"], async: false}]); expect(ast).to.be.an('array').with.length(1);
expect(ast[0]).to.be.an('object');
expect(ast[0]).to.include({type: 'function', name: 'test', async: false});
expect(ast[0].parameters).to.be.an('array').deep.equals(["a"]);
}); });
it('function with two parameters', () => { it('function with two parameters', () => {
const ast = createAst(ModuleFiles.functionTwoParams); const ast: any = createAst(ModuleFiles.functionTwoParams);
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: ["a", "b"], async: false}]); expect(ast).to.be.an('array').with.length(1);
expect(ast[0]).to.be.an('object');
expect(ast[0]).to.include({type: 'function', name: 'test', async: false});
expect(ast[0].parameters).to.be.an('array').deep.equals(["a", "b"]);
}); });
it('async function with parameters omitted', () => { it('async function with parameters omitted', () => {
const ast = createAst(ModuleFiles.asyncFunctionNoParams); const ast: any = createAst(ModuleFiles.asyncFunctionNoParams);
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: [], async: true}]); expect(ast).to.be.an('array').with.length(1);
expect(ast[0]).to.be.an('object');
expect(ast[0]).to.deep.include({type: 'function', name: 'test', async: true});
expect(ast[0].parameters).to.be.an('array').of.length(0);
}); });
it('async function with empty parameters', () => { it('async function with empty parameters', () => {
const ast = createAst(ModuleFiles.asyncFunctionEmptyParams); const ast: any = createAst(ModuleFiles.asyncFunctionEmptyParams);
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: [], async: true}]); expect(ast).to.be.an('array').with.length(1);
expect(ast[0]).to.be.an('object');
expect(ast[0]).to.deep.include({type: 'function', name: 'test', async: true});
expect(ast[0].parameters).to.be.an('array').of.length(0);
}); });
it('async function with one parameter', () => { it('async function with one parameter', () => {
const ast = createAst(ModuleFiles.asyncFunctionOneParam); const ast: any = createAst(ModuleFiles.asyncFunctionOneParam);
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: ["a"], async: true}]); expect(ast).to.be.an('array').with.length(1);
expect(ast[0]).to.be.an('object');
expect(ast[0]).to.deep.include({type: 'function', name: 'test', async: true});
expect(ast[0].parameters).to.be.an('array').deep.equals(["a"]);
}); });
it('async function with two parameters', () => { it('async function with two parameters', () => {
const ast = createAst(ModuleFiles.asyncFunctionTwoParams); const ast: any = createAst(ModuleFiles.asyncFunctionTwoParams);
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: ["a", "b"], async: true}]); expect(ast).to.be.an('array').with.length(1);
expect(ast[0]).to.be.an('object');
expect(ast[0]).to.deep.include({type: 'function', name: 'test', async: true});
expect(ast[0].parameters).to.be.an('array').deep.equals(["a", "b"]);
}); });
}); });