[IMP] qweb: add support for arrow functions in expression parser

closes #542
This commit is contained in:
Géry Debongnie
2019-12-04 20:57:59 +01:00
committed by aab-odoo
parent 7ec05ff8cf
commit e162a6fb6c
2 changed files with 41 additions and 13 deletions
+9
View File
@@ -163,4 +163,13 @@ describe("expression evaluation", () => {
"'x'.toUpperCase({b:_v5})"
);
});
test("arrow functions", () => {
expect(compileExpr("list.map(e => e.val)", {})).toBe("context['list'].map(e=>e.val)");
expect(compileExpr("list.map(e => a + e)", {})).toBe("context['list'].map(e=>context['a']+e)");
expect(compileExpr("list.map((e) => e)", {})).toBe("context['list'].map((e)=>e)");
expect(compileExpr("list.map((elem, index) => elem + index)", {})).toBe(
"context['list'].map((elem,index)=>elem+index)"
);
});
});