Skip to content
Snippets Groups Projects
Unverified Commit d9265af2 authored by KoyaS's avatar KoyaS Committed by GitHub
Browse files

Merge pull request #13 from yakomaxa/molql_integration_PR

Added transpilers/_spec and checked that they pass the test
parents e3e982c0 5877f6a6
No related branches found
No related tags found
No related merge requests found
......@@ -6,14 +6,13 @@
*/
import * as u from './utils';
import { parse } from '../../transpile';
// import { transpiler } from '../pymol/parser';
import { transpiler } from '../pymol/parser';
import { keywords } from '../pymol/keywords';
import { properties } from '../pymol/properties';
import { operators } from '../pymol/operators';
/* FAULTY IMPORTS */
// import compile from '../../compiler';
// import compile from '../../reference-implementation/molql/compiler';
const general = {
supported: [
......@@ -47,12 +46,13 @@ const general = {
describe('pymol general', () => {
general.supported.forEach(str => {
it(str, () => {
parse('pymol', str);
transpiler(str);
// compile(expr);
});
});
general.unsupported.forEach(str => {
it(str, () => {
const transpileStr = () => parse('pymol', str);
const transpileStr = () => transpiler(str);
expect(transpileStr).toThrow();
expect(transpileStr).not.toThrowError(RangeError);
});
......@@ -70,6 +70,6 @@ describe('pymol general', () => {
// 'b = 1',
// 'fc.=.1',
describe('pymol keywords', () => u.testKeywords(keywords, 'pymol'));
describe('pymol operators', () => u.testOperators(operators, 'pymol'));
describe('pymol properties', () => u.testProperties(properties, 'pymol'));
describe('pymol keywords', () => u.testKeywords(keywords, transpiler));
describe('pymol operators', () => u.testOperators(operators, transpiler));
describe('pymol properties', () => u.testProperties(properties, transpiler));
......@@ -5,22 +5,22 @@
* @author Panagiotis Tourlas <panangiot_tourlov@hotmail.com>
*/
import { parse } from '../../transpile';
import { Transpiler } from '../transpiler';
import { KeywordDict, PropertyDict, OperatorList } from '../types';
/* FAULTY IMPORTS */
// import compile from '../../compiler';
// import compile from '../../reference-implementation/molql/compiler';
export function testKeywords(keywords: KeywordDict, language: string) {
export function testKeywords(keywords: KeywordDict, transpiler: Transpiler) {
for (const name in keywords) {
it(name, () => {
const k = keywords[name];
if (k.map) {
const expr = parse(language, name);
const expr = transpiler(name);
// compile(expr);
expect(expr).toEqual(k.map());
} else {
const transpile = () => parse(language, name);
const transpile = () => transpiler(name);
expect(transpile).toThrow();
expect(transpile).not.toThrowError(RangeError);
}
......@@ -28,17 +28,16 @@ export function testKeywords(keywords: KeywordDict, language: string) {
}
}
export function testProperties(properties: PropertyDict, language: string) {
export function testProperties(properties: PropertyDict, transpiler: Transpiler) {
for (const name in properties) {
const p = properties[name];
p['@examples'].forEach(example => {
it(name, () => {
if (!p.isUnsupported) {
const expr = parse(language, example);
expect(expr).toBe(p);
transpiler(example);
// compile(expr);
} else {
const transpile = () => parse(language, example);
const transpile = () => transpiler(example);
expect(transpile).toThrow();
expect(transpile).not.toThrowError(RangeError);
}
......@@ -52,15 +51,15 @@ export function testProperties(properties: PropertyDict, language: string) {
}
}
export function testOperators(operators: OperatorList, language: string) {
export function testOperators(operators: OperatorList, transpiler: Transpiler) {
operators.forEach(o => {
o['@examples'].forEach(example => {
it(o.name, () => {
if (!o.isUnsupported) {
const expr = parse(language, example);
expect(expr).toBe(o);
transpiler(example);
// compile(expr);
} else {
const transpile = () => parse(language, example);
const transpile = () => transpiler(example);
expect(transpile).toThrow();
expect(transpile).not.toThrowError(RangeError);
}
......
/**
* Copyright (c) 2020-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
......@@ -7,14 +6,13 @@
*/
import * as u from './utils';
// import { transpiler } from '../vmd/parser';
import { parse } from '../../transpile';
import { transpiler } from '../vmd/parser';
import { keywords } from '../vmd/keywords';
import { properties } from '../vmd/properties';
import { operators } from '../vmd/operators';
/* FAULTY IMPORTS */
// import compile from '../../compiler';
// import compile from '../../reference-implementation/molql/compiler';
const general = {
supported: [
......@@ -46,18 +44,19 @@ const general = {
describe('vmd general', () => {
general.supported.forEach(str => {
it(str, () => {
parse('vmd', str);
transpiler(str);
// compile(expr);
});
});
general.unsupported.forEach(str => {
it(str, () => {
const transpileStr = () => parse('vmd', str);
const transpileStr = () => transpiler(str);
expect(transpileStr).toThrow();
expect(transpileStr).not.toThrowError(RangeError);
});
});
});
describe('vmd keywords', () => u.testKeywords(keywords, 'vmd'));
describe('vmd operators', () => u.testOperators(operators, 'vmd'));
describe('vmd properties', () => u.testProperties(properties, 'vmd'));
describe('vmd keywords', () => u.testKeywords(keywords, transpiler));
describe('vmd operators', () => u.testOperators(operators, transpiler));
describe('vmd properties', () => u.testProperties(properties, transpiler));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment