michael@0: // Any copyright is dedicated to the Public Domain. michael@0: // http://creativecommons.org/licenses/publicdomain/ michael@0: michael@0: var gTestfile = 'destructure-accessor.js'; michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 536472; michael@0: var summary = michael@0: 'ES5: { get x(v) { } } and { set x(v, v2) { } } should be syntax errors'; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: function expectOk(s) michael@0: { michael@0: try michael@0: { michael@0: eval(s); michael@0: return; michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(true, false, michael@0: "expected no error parsing '" + "', got : " + e); michael@0: } michael@0: } michael@0: michael@0: function expectSyntaxError(s) michael@0: { michael@0: try michael@0: { michael@0: eval(s); michael@0: throw new Error("no error thrown"); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof SyntaxError, true, michael@0: "expected syntax error parsing '" + s + "', got: " + e); michael@0: } michael@0: } michael@0: michael@0: expectSyntaxError("({ get x([]) { } })"); michael@0: expectSyntaxError("({ get x({}) { } })"); michael@0: expectSyntaxError("({ get x(a, []) { } })"); michael@0: expectSyntaxError("({ get x(a, {}) { } })"); michael@0: expectSyntaxError("({ get x([], a) { } })"); michael@0: expectSyntaxError("({ get x({}, a) { } })"); michael@0: expectSyntaxError("({ get x([], a, []) { } })"); michael@0: expectSyntaxError("({ get x([], a, {}) { } })"); michael@0: expectSyntaxError("({ get x({}, a, []) { } })"); michael@0: expectSyntaxError("({ get x({}, a, {}) { } })"); michael@0: michael@0: expectOk("({ get x() { } })"); michael@0: michael@0: michael@0: expectSyntaxError("({ set x() { } })"); michael@0: expectSyntaxError("({ set x(a, []) { } })"); michael@0: expectSyntaxError("({ set x(a, b, c) { } })"); michael@0: michael@0: expectOk("({ set x([]) { } })"); michael@0: expectOk("({ set x({}) { } })"); michael@0: expectOk("({ set x([a]) { } })"); michael@0: expectOk("({ set x([a, b]) { } })"); michael@0: expectOk("({ set x([a,]) { } })"); michael@0: expectOk("({ set x([a, b,]) { } })"); michael@0: expectOk("({ set x([, b]) { } })"); michael@0: expectOk("({ set x([, b,]) { } })"); michael@0: expectOk("({ set x([, b, c]) { } })"); michael@0: expectOk("({ set x([, b, c,]) { } })"); michael@0: expectOk("({ set x({ a: a }) { } })"); michael@0: expectOk("({ set x({ a: a, b: b }) { } })"); michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: reportCompare(true, true);