- Unify test data for nonexistence of an object/string and collection. - Introduce more test through adding missing test data to existing tests. - Improve logic for checking absence of values to match tests. - Add missing tests for absent value validation. - Update documentation to include shared test functionality.
27 lines
808 B
TypeScript
27 lines
808 B
TypeScript
import { IExpression } from '../Expression/IExpression';
|
|
import { ParameterSubstitutionParser } from '../SyntaxParsers/ParameterSubstitutionParser';
|
|
import { WithParser } from '../SyntaxParsers/WithParser';
|
|
import { IExpressionParser } from './IExpressionParser';
|
|
|
|
const Parsers = [
|
|
new ParameterSubstitutionParser(),
|
|
new WithParser(),
|
|
];
|
|
|
|
export class CompositeExpressionParser implements IExpressionParser {
|
|
public constructor(private readonly leafs: readonly IExpressionParser[] = Parsers) {
|
|
if (!leafs) {
|
|
throw new Error('missing leafs');
|
|
}
|
|
if (leafs.some((leaf) => !leaf)) {
|
|
throw new Error('missing leaf');
|
|
}
|
|
}
|
|
|
|
public findExpressions(code: string): IExpression[] {
|
|
return this.leafs.flatMap(
|
|
(parser) => parser.findExpressions(code) || [],
|
|
);
|
|
}
|
|
}
|