|
@@ -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);
|
|
|
- // compile(expr);
|
|
|
+ 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);
|
|
|
- // compile(expr);
|
|
|
+ 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);
|
|
|
}
|