From 439e92a042a35e441aebb7b1d64c0276c293b7ff Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Fri, 7 Aug 2015 04:20:49 +0900 Subject: [PATCH] Bug 1089045 - Part 3: Add parser test for ES6 class. r=Waldo --- js/src/jit-test/lib/syntax.js | 110 ++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/js/src/jit-test/lib/syntax.js b/js/src/jit-test/lib/syntax.js index d0447e7d8848..f597d9bca34b 100644 --- a/js/src/jit-test/lib/syntax.js +++ b/js/src/jit-test/lib/syntax.js @@ -1006,6 +1006,116 @@ function test_syntax(replacements, check_error, ignore_opts) { test("({a: b}) @"); test("({a: b}) => @"); + if (classesEnabled()) { + // ---- Class declaration ---- + + test("class @"); + test("class a @"); + test("class a { @"); + test("class a { constructor @"); + test("class a { constructor( @"); + test("class a { constructor() @"); + test("class a { constructor() { @"); + test("class a { constructor() { } @"); + test("class a { constructor() { } } @"); + + test("class a { constructor() { } static @"); + test("class a { constructor() { } static m @"); + test("class a { constructor() { } static m( @"); + test("class a { constructor() { } static m() @"); + test("class a { constructor() { } static m() { @"); + test("class a { constructor() { } static m() {} @"); + test("class a { constructor() { } static m() {} } @"); + + test("class a { constructor() { } static ( @"); + test("class a { constructor() { } static () @"); + test("class a { constructor() { } static () { @"); + test("class a { constructor() { } static () {} @"); + test("class a { constructor() { } static () {} } @"); + + test("class a { constructor() { } static get @"); + test("class a { constructor() { } static get p @"); + test("class a { constructor() { } static get p( @"); + test("class a { constructor() { } static get p() @"); + test("class a { constructor() { } static get p() { @"); + test("class a { constructor() { } static get p() {} @"); + test("class a { constructor() { } static get p() {} } @"); + + test("class a { constructor() { } static set @"); + test("class a { constructor() { } static set p @"); + test("class a { constructor() { } static set p( @"); + test("class a { constructor() { } static set p(v @"); + test("class a { constructor() { } static set p(v) @"); + test("class a { constructor() { } static set p(v) { @"); + test("class a { constructor() { } static set p(v) {} @"); + test("class a { constructor() { } static set p(v) {} } @"); + + test("class a { constructor() { } * @"); + test("class a { constructor() { } *m @"); + test("class a { constructor() { } *m( @"); + test("class a { constructor() { } *m() @"); + test("class a { constructor() { } *m() { @"); + test("class a { constructor() { } *m() {} @"); + test("class a { constructor() { } *m() {} } @"); + + test("class a { constructor() { } static * @"); + test("class a { constructor() { } static *m @"); + test("class a { constructor() { } static *m( @"); + test("class a { constructor() { } static *m() @"); + test("class a { constructor() { } static *m() { @"); + test("class a { constructor() { } static *m() {} @"); + test("class a { constructor() { } static *m() {} } @"); + + test("class a extends @"); + test("class a extends b @"); + test("class a extends b { @"); + + test("class a extends ( @"); + test("class a extends ( b @"); + test("class a extends ( b ) @"); + test("class a extends ( b ) { @"); + + // ---- Class expression ---- + + test("( class @"); + test("( class a @"); + test("( class a { @"); + test("( class a { constructor @"); + test("( class a { constructor( @"); + test("( class a { constructor() @"); + test("( class a { constructor() { @"); + test("( class a { constructor() { } @"); + test("( class a { constructor() { } } @"); + test("( class a { constructor() { } } ) @"); + + test("(class a extends @"); + test("(class a extends b @"); + test("(class a extends b { @"); + + test("(class a extends ( @"); + test("(class a extends ( b @"); + test("(class a extends ( b ) @"); + test("(class a extends ( b ) { @"); + + test("( class { @"); + test("( class { constructor @"); + test("( class { constructor( @"); + test("( class { constructor() @"); + test("( class { constructor() { @"); + test("( class { constructor() { } @"); + test("( class { constructor() { } } @"); + test("( class { constructor() { } } ) @"); + + test("(class extends @"); + test("(class extends b @"); + test("(class extends b { @"); + + test("(class extends ( @"); + test("(class extends ( b @"); + test("(class extends ( b ) @"); + test("(class extends ( b ) { @"); + } + // ---- Other ---- // Literals