test watcher... test link parsing
parent
23925a030f
commit
95bafd4058
|
|
@ -9,6 +9,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"test": "mocha tests",
|
||||
"test:watch": "supervisor -n exit -w out,tests --exec mocha -- tests",
|
||||
"debug": "cross-env DEBUG=vogue:* yarn node --enable-source-maps --unhandled-rejections=strict out/run.js test",
|
||||
"debug:watch": "cross-env DEBUG=vogue:* supervisor -w out,test/**/*.v,lib -n exit --exec yarn -- test",
|
||||
"postinstall": "yarn compile && cd test && yarn",
|
||||
|
|
|
|||
|
|
@ -1,20 +1,39 @@
|
|||
import { createAst } from './../out/createAst.js';
|
||||
import { readFileSync } from 'fs';
|
||||
import { resolve, parse } from 'path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { expect } from 'chai';
|
||||
import * as ModuleFiles from './lib/ModuleFiles.js'
|
||||
|
||||
describe('Lexer', () => {
|
||||
it('parses namespaces without dots', () => {
|
||||
const ast = createAst(resolve(parse(fileURLToPath(import.meta.url)).dir, 'modules', 'namespaceX.v'));
|
||||
expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x'}]);
|
||||
});
|
||||
it('parses namespaces with a single dot', () => {
|
||||
const ast = createAst(resolve(parse(fileURLToPath(import.meta.url)).dir, 'modules', 'namespaceXY.v'));
|
||||
expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x.y'}]);
|
||||
});
|
||||
it('parses namespaces two dots', () => {
|
||||
const ast = createAst(resolve(parse(fileURLToPath(import.meta.url)).dir, 'modules', 'namespaceXYZ.v'));
|
||||
expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x.y.z'}]);
|
||||
});
|
||||
describe('namespaces', () => {
|
||||
it('parses namespaces without dots', () => {
|
||||
const ast = createAst(ModuleFiles.namespaceX);
|
||||
expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x'}]);
|
||||
});
|
||||
it('parses namespaces with a single dot', () => {
|
||||
const ast = createAst(ModuleFiles.namespaceXY);
|
||||
expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x.y'}]);
|
||||
});
|
||||
it('parses namespaces two dots', () => {
|
||||
const ast = createAst(ModuleFiles.namespaceXYZ);
|
||||
expect(ast).to.deep.equal([{type: 'namespace', namespace: 'x.y.z'}]);
|
||||
});
|
||||
})
|
||||
|
||||
describe('links', () => {
|
||||
it('parses link', () => {
|
||||
const ast = 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);
|
||||
expect(ast).to.deep.equal([{type: 'link', array: false, required: true, name: 'test'}]);
|
||||
});
|
||||
it('parses link array', () => {
|
||||
const ast = 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);
|
||||
expect(ast).to.deep.equal([{type: 'link', array: true, required: true, name: 'test'}]);
|
||||
});
|
||||
})
|
||||
})
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
import { resolve, parse } from 'path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
function file(str) {
|
||||
return resolve(parse(fileURLToPath(import.meta.url)).dir, '..', 'modules', str + '.v')
|
||||
}
|
||||
|
||||
export const namespaceX = file('namespaceX');
|
||||
export const namespaceXY = file('namespaceXY');
|
||||
export const namespaceXYZ = file('namespaceXYZ');
|
||||
|
||||
export const link = file('link');
|
||||
export const linkArray = file('linkArray');
|
||||
export const requiredLink = file('requiredLink');
|
||||
export const requiredLinkArray = file('requiredLinkArray');
|
||||
|
|
@ -0,0 +1 @@
|
|||
link test;
|
||||
|
|
@ -0,0 +1 @@
|
|||
link[] test;
|
||||
|
|
@ -0,0 +1 @@
|
|||
required link test;
|
||||
|
|
@ -0,0 +1 @@
|
|||
required link[] test;
|
||||
Reference in New Issue