1// Copyright 2015 the V8 project authors. All rights reserved. 2// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3// 4// Redistribution and use in source and binary forms, with or without 5// modification, are permitted provided that the following conditions 6// are met: 7// 1. Redistributions of source code must retain the above copyright 8// notice, this list of conditions and the following disclaimer. 9// 2. Redistributions in binary form must reproduce the above copyright 10// notice, this list of conditions and the following disclaimer in the 11// documentation and/or other materials provided with the distribution. 12// 13// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY 14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 24description('Tests for ES6 class syntax containing semicolon in the class body'); 25 26shouldThrow("class A { foo;() { } }", "'SyntaxError: Unexpected token ;'"); 27shouldThrow("class A { foo() ; { } }", "'SyntaxError: Unexpected token ;'"); 28shouldThrow("class A { get ; foo() { } }", "'SyntaxError: Unexpected token ;'"); 29shouldThrow("class A { get foo;() { } }", "'SyntaxError: Unexpected token ;'"); 30shouldThrow("class A { get foo() ; { } }", "'SyntaxError: Unexpected token ;'"); 31shouldThrow("class A { set ; foo(x) { } }", "'SyntaxError: Unexpected token ;'"); 32shouldThrow("class A { set foo;(x) { } }", "'SyntaxError: Unexpected token ;'"); 33shouldThrow("class A { set foo(x) ; { } }", "'SyntaxError: Unexpected token ;'"); 34 35shouldNotThrow("class A { ; }"); 36shouldNotThrow("class A { foo() { } ; }"); 37shouldNotThrow("class A { get foo() { } ; }"); 38shouldNotThrow("class A { set foo(x) { } ; }"); 39shouldNotThrow("class A { static foo() { } ; }"); 40shouldNotThrow("class A { static get foo() { } ; }"); 41shouldNotThrow("class A { static set foo(x) { } ; }"); 42 43shouldNotThrow("class A { ; foo() { } }"); 44shouldNotThrow("class A { ; get foo() { } }"); 45shouldNotThrow("class A { ; set foo(x) { } }"); 46shouldNotThrow("class A { ; static foo() { } }"); 47shouldNotThrow("class A { ; static get foo() { } }"); 48shouldNotThrow("class A { ; static set foo(x) { } }"); 49 50shouldNotThrow("class A { foo() { } ; foo() {} }"); 51shouldNotThrow("class A { foo() { } ; get foo() {} }"); 52shouldNotThrow("class A { foo() { } ; set foo(x) {} }"); 53shouldNotThrow("class A { foo() { } ; static foo() {} }"); 54shouldNotThrow("class A { foo() { } ; static get foo() {} }"); 55shouldNotThrow("class A { foo() { } ; static set foo(x) {} }"); 56 57shouldNotThrow("class A { get foo() { } ; foo() {} }"); 58shouldNotThrow("class A { get foo() { } ; get foo() {} }"); 59shouldNotThrow("class A { get foo() { } ; set foo(x) {} }"); 60shouldNotThrow("class A { get foo() { } ; static foo() {} }"); 61shouldNotThrow("class A { get foo() { } ; static get foo() {} }"); 62shouldNotThrow("class A { get foo() { } ; static set foo(x) {} }"); 63 64shouldNotThrow("class A { set foo(x) { } ; foo() {} }"); 65shouldNotThrow("class A { set foo(x) { } ; get foo() {} }"); 66shouldNotThrow("class A { set foo(x) { } ; set foo(x) {} }"); 67shouldNotThrow("class A { set foo(x) { } ; static foo() {} }"); 68shouldNotThrow("class A { set foo(x) { } ; static get foo() {} }"); 69shouldNotThrow("class A { set foo(x) { } ; static set foo(x) {} }"); 70 71shouldNotThrow("class A { static foo() { } ; foo() {} }"); 72shouldNotThrow("class A { static foo() { } ; get foo() {} }"); 73shouldNotThrow("class A { static foo() { } ; set foo(x) {} }"); 74shouldNotThrow("class A { static foo() { } ; static foo() {} }"); 75shouldNotThrow("class A { static foo() { } ; static get foo() {} }"); 76shouldNotThrow("class A { static foo() { } ; static set foo(x) {} }"); 77 78shouldNotThrow("class A { static get foo() { } ; foo() {} }"); 79shouldNotThrow("class A { static get foo() { } ; get foo() {} }"); 80shouldNotThrow("class A { static get foo() { } ; set foo(x) {} }"); 81shouldNotThrow("class A { static get foo() { } ; static foo() {} }"); 82shouldNotThrow("class A { static get foo() { } ; static get foo() {} }"); 83shouldNotThrow("class A { static get foo() { } ; static set foo(x) {} }"); 84 85shouldNotThrow("class A { static set foo(x) { } ; foo() {} }"); 86shouldNotThrow("class A { static set foo(x) { } ; get foo() {} }"); 87shouldNotThrow("class A { static set foo(x) { } ; set foo(x) {} }"); 88shouldNotThrow("class A { static set foo(x) { } ; static foo() {} }"); 89shouldNotThrow("class A { static set foo(x) { } ; static get foo() {} }"); 90shouldNotThrow("class A { static set foo(x) { } ; static set foo(x) {} }"); 91 92var successfullyParsed = true; 93