diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /js/src/tests/non262/reflect-parse/methodDefn.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/reflect-parse/methodDefn.js')
-rw-r--r-- | js/src/tests/non262/reflect-parse/methodDefn.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/js/src/tests/non262/reflect-parse/methodDefn.js b/js/src/tests/non262/reflect-parse/methodDefn.js new file mode 100644 index 0000000000..cad9b44435 --- /dev/null +++ b/js/src/tests/non262/reflect-parse/methodDefn.js @@ -0,0 +1,51 @@ +// |reftest| skip-if(!xulRuntime.shell) +function test() { + +// Bug 924672: Method definitions +assertExpr("b = { a() { } }", aExpr("=", ident("b"), + objExpr([{ key: ident("a"), value: funExpr(ident("a"), [], blockStmt([])), method: + true}]))); + +assertExpr("b = { *a() { } }", aExpr("=", ident("b"), + objExpr([{ key: ident("a"), value: genFunExpr("es6", ident("a"), [], blockStmt([])), method: + true}]))); + +// Method definitions without braces +assertError("({ a() void 0 })", SyntaxError); +assertError("({ a() 1 })", SyntaxError); +assertError("({ a() false })", SyntaxError); + +// getters and setters + +assertExpr("({ get x() { return 42 } })", + objExpr([ { key: ident("x"), + value: funExpr(ident("get x"), [], blockStmt([returnStmt(lit(42))])), + kind: "get" } ])); +assertExpr("({ set x(v) { return 42 } })", + objExpr([ { key: ident("x"), + value: funExpr(ident("set x"), [ident("v")], blockStmt([returnStmt(lit(42))])), + kind: "set" } ])); + +// Bug 1073809 - Getter/setter syntax with generators +assertExpr("({*get() { }})", objExpr([{ type: "Property", key: ident("get"), method: true, + value: genFunExpr("es6", ident("get"), [], blockStmt([]))}])); +assertExpr("({*set() { }})", objExpr([{ type: "Property", key: ident("set"), method: true, + value: genFunExpr("es6", ident("set"), [], blockStmt([]))}])); +assertError("({*get foo() { }})", SyntaxError); +assertError("({*set foo() { }})", SyntaxError); + +assertError("({ *get 1() {} })", SyntaxError); +assertError("({ *get \"\"() {} })", SyntaxError); +assertError("({ *get foo() {} })", SyntaxError); +assertError("({ *get []() {} })", SyntaxError); +assertError("({ *get [1]() {} })", SyntaxError); + +assertError("({ *set 1() {} })", SyntaxError); +assertError("({ *set \"\"() {} })", SyntaxError); +assertError("({ *set foo() {} })", SyntaxError); +assertError("({ *set []() {} })", SyntaxError); +assertError("({ *set [1]() {} })", SyntaxError); + +} + +runtest(test); |