Skip to content
Snippets Groups Projects
Select Git revision
  • 6c5224f33e9de20fe9967a82536c269bacf29738
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

string-builder.ts

Blame
  • utils.ts 2.53 KiB
    /**
     * Copyright (c) 2020-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author Alexander Rose <alexander.rose@weirdbyte.de>
     * @author Panagiotis Tourlas <panangiot_tourlov@hotmail.com>
     * @author Koya Sakuma <koya.sakuma.work@gmail.com>
     */
    
    import { Transpiler } from '../transpiler';
    import { KeywordDict, PropertyDict, OperatorList } from '../types';
    
    /* FAULTY IMPORTS */
    // import compile from '../../reference-implementation/molql/compiler';
    
    export function testKeywords(keywords: KeywordDict, transpiler: Transpiler) {
        for (const name in keywords) {
            it(name, () => {
                const k = keywords[name];
                if (k.map) {
                    const expr = transpiler(name);
                    //                compile(expr);
                    expect(expr).toEqual(k.map());
                } else {
                    const transpile = () => transpiler(name);
                    expect(transpile).toThrow();
                    expect(transpile).not.toThrowError(RangeError);
                }
            });
        }
    }
    
    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) {
                        transpiler(example);
                        //                  compile(expr);
                    } else {
                        const transpile = () => transpiler(example);
                        expect(transpile).toThrow();
                        expect(transpile).not.toThrowError(RangeError);
                    }
                });
            });
            it(name, () => {
                if (!p['@examples'].length) {
                    throw Error(`'${name}' property has no example(s)`);
                }
            });
        }
    }
    
    export function testOperators(operators: OperatorList, transpiler: Transpiler) {
        operators.forEach(o => {
            o['@examples'].forEach(example => {
                it(o.name, () => {
                    if (!o.isUnsupported) {
                        transpiler(example);
                        //                compile(expr);
                    } else {
                        const transpile = () => transpiler(example);
                        expect(transpile).toThrow();
                        expect(transpile).not.toThrowError(RangeError);
                    }
                });
            });
            it(o.name, () => {
                if (!o['@examples'].length) {
                    throw Error(`'${o.name}' operator has no example(s)`);
                }
            });
        });
    }