mirror of
https://gitlab.com/nightlycommit/twing.git
synced 2025-01-18 08:46:50 +02:00
Improve TwingLexer test
This commit is contained in:
parent
4e24952608
commit
0f3064d17b
@ -22,7 +22,7 @@ import {createSourceMapRuntime} from "./source-map-runtime";
|
||||
import {createSandboxSecurityPolicy, TwingSandboxSecurityPolicy} from "./sandbox/security-policy";
|
||||
import {TwingTemplate} from "./template";
|
||||
import {Settings as DateTimeSettings} from "luxon";
|
||||
import {createLexer, TwingLexer} from "./lexer";
|
||||
import {createLexer, type TwingLexer} from "./lexer";
|
||||
import {TwingCache} from "./cache";
|
||||
import {createCoreExtension} from "./extension/core";
|
||||
import {createAutoEscapeNode, createTemplateLoadingError, type TwingContext} from "../lib";
|
||||
@ -102,7 +102,7 @@ export interface TwingEnvironment {
|
||||
* @param name The name of the template to load
|
||||
* @param from The name of the template that requested the load
|
||||
*
|
||||
* @throws {TwingTemplateLoadingError} When the template cannot be found
|
||||
* @throws {Error} When the template cannot be found
|
||||
* @throws {TwingParsingError} When an error occurred during the parsing of the source
|
||||
*
|
||||
* @return
|
||||
|
@ -85,11 +85,11 @@ export const createLexer = (
|
||||
binaryOperators: Array<TwingOperator>,
|
||||
unaryOperators: Array<TwingOperator>
|
||||
): TwingLexer => {
|
||||
const keepCompatibleOperators = (operator: TwingOperator) => operator.specificationLevel <= level;
|
||||
const keepCompatibleOperator = (operator: TwingOperator) => operator.specificationLevel <= level;
|
||||
|
||||
return new TwingLexer(
|
||||
level,
|
||||
binaryOperators.filter(keepCompatibleOperators),
|
||||
unaryOperators.filter(keepCompatibleOperators)
|
||||
binaryOperators.filter(keepCompatibleOperator),
|
||||
unaryOperators.filter(keepCompatibleOperator)
|
||||
);
|
||||
};
|
||||
|
@ -1,11 +1,11 @@
|
||||
import * as tape from 'tape';
|
||||
import {TwingLexer, typeToEnglish} from "../../../../../main/lib/lexer";
|
||||
import {createLexer, typeToEnglish} from "../../../../../main/lib/lexer";
|
||||
import {createOperator} from "../../../../../main/lib/operator";
|
||||
|
||||
tape('lexer', (test) => {
|
||||
test.test('constructor', (test) => {
|
||||
test.test('support custom operators', (test) => {
|
||||
let lexer = new TwingLexer(
|
||||
let lexer = createLexer(
|
||||
2,
|
||||
[
|
||||
createOperator('foo', "BINARY", 0, () => {
|
||||
|
Loading…
Reference in New Issue
Block a user