UNPKG

boolean-expressions

Version:

Boolean expression parser and evaluator. Makes use of the Ohm grammar package with grammar rules found [here](https://github.com/avadavat/boolean-expressions/blob/master/src/grammar/grammarRules.ts).

26 lines (25 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var util_1 = require("../util"); describe("extractVariables tests", function () { var exp1 = "p AND q"; it("extracts [p, q] from \"" + exp1 + "\"", function () { expect(util_1.extractVariables(exp1)).toEqual(["p", "q"]); }); var exp2 = "p AND q OR r"; it("extracts [p, q, r] from \"" + exp2 + "\"", function () { expect(util_1.extractVariables(exp2)).toEqual(["p", "q", "r"]); }); var exp3 = " ( p AND (q OR r))"; it("extracts [p, q, r] from \"" + exp3 + "\"", function () { expect(util_1.extractVariables(exp3)).toEqual(["p", "q", "r"]); }); var exp4 = " ( p AND (q OR r) AND p OR q)"; it("extracts [p, q, r] from \"" + exp4 + "\"", function () { expect(util_1.extractVariables(exp4)).toEqual(["p", "q", "r"]); }); var exp5 = " ( p xor (q OR r) xor p OR q)"; it("extracts [p, q, r] from \"" + exp5 + "\"", function () { expect(util_1.extractVariables(exp5)).toEqual(["p", "q", "r"]); }); });