Skip to content

Commit 8f7d405

Browse files
committed
full coverage for optimizer
1 parent 4838e56 commit 8f7d405

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/optimizer.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const optimizers = {
4444
case '<=': result = left <= right; break;
4545
case '>': result = left > right; break;
4646
case '>=': result = left >= right; break;
47-
default: return e;
4847
}
4948
return result ? e.thenBranch : e.elseBranch;
5049
}
@@ -126,12 +125,6 @@ const optimizers = {
126125
return g;
127126
},
128127

129-
numrange(nr) {
130-
nr.start = optimize(nr.start);
131-
nr.end = optimize(nr.end);
132-
return nr;
133-
},
134-
135128
num(n) {
136129
return n;
137130
},

test/optimizer.test.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,19 @@ const tests = [
220220
core.printStmt(id("x"))
221221
],
222222
[
223-
"optimizes nested expressions in numrange start/end",
224-
core.numRange(
225-
add(num(2), "+", num(3)),
226-
mul(num(4), "*", num(2))
227-
),
228-
core.numRange(num(5), num(8)),
223+
"returns unoptimized conditional with non-numeric operands",
224+
condExpr(id("a"), "==", id("b"), num(10), num(20)),
225+
condExpr(id("a"), "==", id("b"), num(10), num(20)),
226+
],
227+
[
228+
"returns unoptimized addition with non-numeric operands",
229+
add(id("x"), "+", id("y")),
230+
add(id("x"), "+", id("y")),
229231
],
230232
[
231-
"handles numrange with only start value",
232-
core.numRange(num(5)),
233-
core.numRange(num(5)),
233+
"returns unoptimized multiplication with non-numeric operands",
234+
mul(id("x"), "*", id("y")),
235+
mul(id("x"), "*", id("y")),
234236
],
235237
];
236238

0 commit comments

Comments
 (0)