Skip to content
Snippets Groups Projects
Select Git revision
  • 3bfeeb641cbab60578b9cb115273d36584b95e68
  • master default protected
  • devel
  • misp
  • stix
  • cejkat-pr
6 results

bench_idea.py

Blame
    • Jan Mach's avatar
      613d1da8
      DEPRECATION OF OLD PERL CODE, RESTRUCTURALIZATION OF REPOSITORY CONTENTS. · 613d1da8
      Jan Mach authored
      This commit deprecates old Perl library for handling IDEA messages, which will not be supported anymore. It also features restructuralization of the whole repository, because typedcols and ipranges libraries were moved into separate git repositories. Another reason for restructuralization is support of our automated build system.
      613d1da8
      History
      DEPRECATION OF OLD PERL CODE, RESTRUCTURALIZATION OF REPOSITORY CONTENTS.
      Jan Mach authored
      This commit deprecates old Perl library for handling IDEA messages, which will not be supported anymore. It also features restructuralization of the whole repository, because typedcols and ipranges libraries were moved into separate git repositories. Another reason for restructuralization is support of our automated build system.
    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) {