tests dont test block (for line ending differences)
parent
8b6642e550
commit
6f8f279543
|
|
@ -10,7 +10,7 @@
|
|||
"scripts": {
|
||||
"dev": "multiview [ yarn test:watch ] [ yarn compile:watch ]",
|
||||
"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:watch": "supervisor -w out,test/system/**/*.v,lib -n exit --exec yarn -- clear_and yarn debug",
|
||||
"compile": "tsc",
|
||||
|
|
|
|||
|
|
@ -5,77 +5,101 @@ import * as ModuleFiles from './lib/ModuleFiles.js'
|
|||
describe('Lexer', () => {
|
||||
|
||||
it('parses blank file', () => {
|
||||
const ast = createAst(ModuleFiles.blank);
|
||||
const ast: any = createAst(ModuleFiles.blank);
|
||||
expect(ast).to.deep.equal([]);
|
||||
});
|
||||
|
||||
describe('namespaces', () => {
|
||||
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'}]);
|
||||
});
|
||||
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'}]);
|
||||
});
|
||||
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'}]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('links', () => {
|
||||
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'}]);
|
||||
});
|
||||
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'}]);
|
||||
});
|
||||
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'}]);
|
||||
});
|
||||
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'}]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('functions', () => {
|
||||
it('function with parameters omitted', () => {
|
||||
const ast = createAst(ModuleFiles.functionNoParams);
|
||||
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: [], async: false}]);
|
||||
const ast: any = createAst(ModuleFiles.functionNoParams);
|
||||
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', () => {
|
||||
const ast = createAst(ModuleFiles.functionEmptyParams);
|
||||
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: [], async: false}]);
|
||||
const ast: any = createAst(ModuleFiles.functionEmptyParams);
|
||||
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', () => {
|
||||
const ast = createAst(ModuleFiles.functionOneParam);
|
||||
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: ["a"], async: false}]);
|
||||
const ast: any = createAst(ModuleFiles.functionOneParam);
|
||||
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', () => {
|
||||
const ast = createAst(ModuleFiles.functionTwoParams);
|
||||
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: ["a", "b"], async: false}]);
|
||||
const ast: any = createAst(ModuleFiles.functionTwoParams);
|
||||
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', () => {
|
||||
const ast = createAst(ModuleFiles.asyncFunctionNoParams);
|
||||
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: [], async: true}]);
|
||||
const ast: any = createAst(ModuleFiles.asyncFunctionNoParams);
|
||||
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', () => {
|
||||
const ast = createAst(ModuleFiles.asyncFunctionEmptyParams);
|
||||
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: [], async: true}]);
|
||||
const ast: any = createAst(ModuleFiles.asyncFunctionEmptyParams);
|
||||
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', () => {
|
||||
const ast = createAst(ModuleFiles.asyncFunctionOneParam);
|
||||
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: ["a"], async: true}]);
|
||||
const ast: any = createAst(ModuleFiles.asyncFunctionOneParam);
|
||||
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', () => {
|
||||
const ast = createAst(ModuleFiles.asyncFunctionTwoParams);
|
||||
expect(ast).to.deep.equal([{type: 'function', name: 'test', block: '{\n\t\n}', parameters: ["a", "b"], async: true}]);
|
||||
const ast: any = createAst(ModuleFiles.asyncFunctionTwoParams);
|
||||
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"]);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Reference in New Issue