Skip to content

Commit

Permalink
Large expression test
Browse files Browse the repository at this point in the history
  • Loading branch information
BalaM314 committed Nov 30, 2023
1 parent b1feb36 commit 3ca5de3
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 0 deletions.
88 changes: 88 additions & 0 deletions spec/parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,94 @@ const sampleExpressions = Object.entries({
{
operatorToken: { type: "operator.or", text: "OR" }, operator: operators.or, nodes: [{ operatorToken: { type: "operator.or", text: "OR" }, operator: operators.or, nodes: [{ operatorToken: { type: "operator.not_equal_to", text: "<>" }, operator: operators.not_equal_to, nodes: [{ operatorToken: { type: "operator.equal_to", text: "=" }, operator: operators.equal_to, nodes: [{ operatorToken: { type: "operator.less_than_equal", text: "<=" }, operator: operators.less_than_equal, nodes: [{ operatorToken: { type: "operator.less_than", text: "<" }, operator: operators.less_than, nodes: [{ operatorToken: { type: "operator.greater_than_equal", text: ">=" }, operator: operators.greater_than_equal, nodes: [{ type: "name", text: "a" }, { operatorToken: { type: "operator.subtract", text: "-" }, operator: operators.subtract, nodes: [{ type: "name", text: "b" }, { operatorToken: { type: "operator.mod", text: "MOD" }, operator: operators.mod, nodes: [{ type: "name", text: "c" }, { type: "name", text: "d" }] }] }] }, { operatorToken: { type: "operator.add", text: "+" }, operator: operators.add, nodes: [{ type: "name", text: "e" }, { type: "name", text: "f" }] }] }, { type: "name", text: "g" }] }, { operatorToken: { type: "operator.greater_than", text: ">" }, operator: operators.greater_than, nodes: [{ operatorToken: { type: "operator.divide", text: "/" }, operator: operators.divide, nodes: [{ operatorToken: { type: "operator.multiply", text: "*" }, operator: operators.multiply, nodes: [{ type: "name", text: "h" }, { type: "name", text: "i" }] }, { type: "name", text: "j" }] }, { operatorToken: { type: "operator.integer_divide", text: "DIV" }, operator: operators.integer_divide, nodes: [{ type: "name", text: "k" }, { type: "name", text: "l" }] }] }] }, { type: "name", text: "m" }] }, { operatorToken: { type: "operator.and", text: "AND" }, operator: operators.and, nodes: [{ type: "name", text: "n" }, { operatorToken: { type: "operator.not", text: "NOT" }, operator: operators.not, nodes: [{ type: "name", text: "o" }] }] }] }, { operatorToken: { type: "operator.and", text: "AND" }, operator: operators.and, nodes: [{ operatorToken: { type: "operator.greater_than_equal", text: ">=" }, operator: operators.greater_than_equal, nodes: [{ type: "name", text: "a" }, { operatorToken: { type: "operator.mod", text: "MOD" }, operator: operators.mod, nodes: [{ operatorToken: { type: "operator.subtract", text: "-" }, operator: operators.subtract, nodes: [{ type: "name", text: "b" }, { type: "name", text: "c" }] }, { operatorToken: { type: "operator.or", text: "OR" }, operator: operators.or, nodes: [{ operatorToken: { type: "operator.not_equal_to", text: "<>" }, operator: operators.not_equal_to, nodes: [{ operatorToken: { type: "operator.greater_than", text: ">" }, operator: operators.greater_than, nodes: [{ operatorToken: { type: "operator.less_than", text: "<" }, operator: operators.less_than, nodes: [{ type: "name", text: "d" }, { operatorToken: { type: "operator.divide", text: "/" }, operator: operators.divide, nodes: [{ operatorToken: { type: "operator.equal_to", text: "=" }, operator: operators.equal_to, nodes: [{ operatorToken: { type: "operator.add", text: "+" }, operator: operators.add, nodes: [{ type: "name", text: "e" }, { operatorToken: { type: "operator.less_than_equal", text: "<=" }, operator: operators.less_than_equal, nodes: [{ type: "name", text: "f" }, { type: "name", text: "g" }] }] }, { operatorToken: { type: "operator.multiply", text: "*" }, operator: operators.multiply, nodes: [{ type: "name", text: "h" }, { type: "name", text: "i" }] }] }, { type: "name", text: "j" }] }] }, { operatorToken: { type: "operator.integer_divide", text: "DIV" }, operator: operators.integer_divide, nodes: [{ type: "name", text: "k" }, { type: "name", text: "l" }] }] }, { type: "name", text: "m" }] }, { type: "name", text: "n" }] }] }] }, { operatorToken: { type: "operator.not", text: "NOT" }, operator: operators.not, nodes: [{ type: "name", text: "o" }] }] }]
}
],
SussyBaka2: [
[
{ text: "(", type: "parentheses.open" },
{ text: "amogus", type: "name" },
{ text: "(", type: "parentheses.open" },
{ text: "1", type: "number.decimal" },
{ text: "+", type: "operator.add" },
{ text: "(", type: "parentheses.open" },
{ text: "(", type: "parentheses.open" },
{ text: "2", type: "number.decimal" },
{ text: ")", type: "parentheses.close" },
{ text: ")", type: "parentheses.close" },
{ text: "-", type: "operator.subtract" },
{ text: "3", type: "number.decimal" },
{ text: "*", type: "operator.multiply" },
{ text: "4", type: "number.decimal" },
{ text: "/", type: "operator.divide" },
{ text: "5", type: "number.decimal" },
{ text: "MOD", type: "operator.mod" },
{ text: "6", type: "number.decimal" },
{ text: "DIV", type: "operator.integer_divide" },
{ text: "7", type: "number.decimal" },
{ text: ">", type: "operator.greater_than" },
{ text: "8", type: "number.decimal" },
{ text: ">", type: "operator.greater_than" },
{ text: "(", type: "parentheses.open" },
{ text: "9", type: "number.decimal" },
{ text: "=", type: "operator.equal_to" },
{ text: "10", type: "number.decimal" },
{ text: ")", type: "parentheses.close" },
{ text: "AND", type: "operator.and" },
{ text: "NOT", type: "operator.not" },
{ text: "12", type: "number.decimal" },
{ text: ",", type: "punctuation.comma" },
{ text: `"sus"`, type: "string" },
{ text: ",", type: "punctuation.comma" },
{ text: "x", type: "name" },
{ text: "[", type: "bracket.open" },
{ text: "5", type: "number.decimal" },
{ text: "]", type: "bracket.close" },
{ text: ",", type: "punctuation.comma" },
{ text: "amogus", type: "name" },
{ text: "(", type: "parentheses.open" },
{ text: "arr", type: "name" },
{ text: "[", type: "bracket.open" },
{ text: "1", type: "number.decimal" },
{ text: ",", type: "punctuation.comma" },
{ text: "5", type: "number.decimal" },
{ text: "]", type: "bracket.close" },
{ text: ",", type: "punctuation.comma" },
{ text: "bigarr", type: "name" },
{ text: "[", type: "bracket.open" },
{ text: "sussy", type: "name" },
{ text: "(", type: "parentheses.open" },
{ text: ")", type: "parentheses.close" },
{ text: ",", type: "punctuation.comma" },
{ text: "sussier", type: "name" },
{ text: "(", type: "parentheses.open" },
{ text: "37", type: "number.decimal" },
{ text: ",", type: "punctuation.comma" },
{ text: "y", type: "name" },
{ text: "[", type: "bracket.open" },
{ text: "5", type: "number.decimal" },
{ text: "+", type: "operator.add" },
{ text: "z", type: "name" },
{ text: "[", type: "bracket.open" },
{ text: "0", type: "number.decimal" },
{ text: ",", type: "punctuation.comma" },
{ text: "(", type: "parentheses.open" },
{ text: "(", type: "parentheses.open" },
{ text: "0", type: "number.decimal" },
{ text: ")", type: "parentheses.close" },
{ text: ")", type: "parentheses.close" },
{ text: "]", type: "bracket.close" },
{ text: "]", type: "bracket.close" },
{ text: ")", type: "parentheses.close" },
{ text: "]", type: "bracket.close" },
{ text: ",", type: "punctuation.comma" },
{ text: "5", type: "number.decimal" },
{ text: ")", type: "parentheses.close" },
{ text: ")", type: "parentheses.close" },
{ text: "+", type: "operator.add" },
{ text: "0", type: "number.decimal" },
{ text: ")", type: "parentheses.close" },
],
//yet another huge tree
{ operatorToken: { type: "operator.add", text: "+" }, operator: { type: "operator.add", unary: false }, nodes: [{ operatorToken: { type: "name", text: "amogus" }, operator: "function call", nodes: [{ operatorToken: { type: "operator.and", text: "AND" }, operator: { type: "operator.and", unary: false }, nodes: [{ operatorToken: { type: "operator.greater_than", text: ">" }, operator: { type: "operator.greater_than", unary: false }, nodes: [{ operatorToken: { type: "operator.greater_than", text: ">" }, operator: { type: "operator.greater_than", unary: false }, nodes: [{ operatorToken: { type: "operator.subtract", text: "-" }, operator: { type: "operator.subtract", unary: false }, nodes: [{ operatorToken: { type: "operator.add", text: "+" }, operator: { type: "operator.add", unary: false }, nodes: [{ type: "number.decimal", text: "1" }, { type: "number.decimal", text: "2" }] }, { operatorToken: { type: "operator.integer_divide", text: "DIV" }, operator: { type: "operator.integer_divide", unary: false }, nodes: [{ operatorToken: { type: "operator.mod", text: "MOD" }, operator: { type: "operator.mod", unary: false }, nodes: [{ operatorToken: { type: "operator.divide", text: "/" }, operator: { type: "operator.divide", unary: false }, nodes: [{ operatorToken: { type: "operator.multiply", text: "*" }, operator: { type: "operator.multiply", unary: false }, nodes: [{ type: "number.decimal", text: "3" }, { type: "number.decimal", text: "4" }] }, { type: "number.decimal", text: "5" }] }, { type: "number.decimal", text: "6" }] }, { type: "number.decimal", text: "7" }] }] }, { type: "number.decimal", text: "8" }] }, { operatorToken: { type: "operator.equal_to", text: "=" }, operator: { type: "operator.equal_to", unary: false }, nodes: [{ type: "number.decimal", text: "9" }, { type: "number.decimal", text: "10" }] }] }, { operatorToken: { type: "operator.not", text: "NOT" }, operator: { type: "operator.not", unary: true }, nodes: [{ type: "number.decimal", text: "12" }] }] }, { text: "\"sus\"", type: "string" }, { operatorToken: { type: "name", text: "x" }, operator: "array access", nodes: [{ type: "number.decimal", text: "5" }] }, { operatorToken: { type: "name", text: "amogus" }, operator: "function call", nodes: [{ operatorToken: { type: "name", text: "arr" }, operator: "array access", nodes: [{ type: "number.decimal", text: "1" }, { type: "number.decimal", text: "5" }] }, { operatorToken: { type: "name", text: "bigarr" }, operator: "array access", nodes: [{ operatorToken: { type: "name", text: "sussy" }, operator: "function call", nodes: [] }, { operatorToken: { type: "name", text: "sussier" }, operator: "function call", nodes: [{ type: "number.decimal", text: "37" }, { operatorToken: { type: "name", text: "y" }, operator: "array access", nodes: [{ operatorToken: { type: "operator.add", text: "+" }, operator: { type: "operator.add", unary: false }, nodes: [{ type: "number.decimal", text: "5" }, { operatorToken: { type: "name", text: "z" }, operator: "array access", nodes: [{ type: "number.decimal", text: "0" }, { type: "number.decimal", text: "0" }] }] }] }] }] }, { type: "number.decimal", text: "5" }] }] }, { type: "number.decimal", text: "0" }] }
]
}).map(p => [p[0], p[1][0], p[1][1]]);
const sampleStatements = Object.entries({
Expand Down
Loading

0 comments on commit 3ca5de3

Please sign in to comment.