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 24// Flags: --harmony-sloppy 25 26description('Tests for ES6 class syntax containing semicolon in the class body'); 27 28shouldThrow("class A { foo;() { } }", "'SyntaxError: Unexpected token ;'"); 29shouldThrow("class A { foo() ; { } }", "'SyntaxError: Unexpected token ;'"); 30shouldThrow("class A { get ; foo() { } }", "'SyntaxError: Unexpected token ;'"); 31shouldThrow("class A { get foo;() { } }", "'SyntaxError: Unexpected token ;'"); 32shouldThrow("class A { get foo() ; { } }", "'SyntaxError: Unexpected token ;'"); 33shouldThrow("class A { set ; foo(x) { } }", "'SyntaxError: Unexpected token ;'"); 34shouldThrow("class A { set foo;(x) { } }", "'SyntaxError: Unexpected token ;'"); 35shouldThrow("class A { set foo(x) ; { } }", "'SyntaxError: Unexpected token ;'"); 36 37shouldNotThrow("class A { ; }"); 38shouldNotThrow("class A { foo() { } ; }"); 39shouldNotThrow("class A { get foo() { } ; }"); 40shouldNotThrow("class A { set foo(x) { } ; }"); 41shouldNotThrow("class A { static foo() { } ; }"); 42shouldNotThrow("class A { static get foo() { } ; }"); 43shouldNotThrow("class A { static set foo(x) { } ; }"); 44 45shouldNotThrow("class A { ; foo() { } }"); 46shouldNotThrow("class A { ; get foo() { } }"); 47shouldNotThrow("class A { ; set foo(x) { } }"); 48shouldNotThrow("class A { ; static foo() { } }"); 49shouldNotThrow("class A { ; static get foo() { } }"); 50shouldNotThrow("class A { ; static set foo(x) { } }"); 51 52shouldNotThrow("class A { foo() { } ; foo() {} }"); 53shouldNotThrow("class A { foo() { } ; get foo() {} }"); 54shouldNotThrow("class A { foo() { } ; set foo(x) {} }"); 55shouldNotThrow("class A { foo() { } ; static foo() {} }"); 56shouldNotThrow("class A { foo() { } ; static get foo() {} }"); 57shouldNotThrow("class A { foo() { } ; static set foo(x) {} }"); 58 59shouldNotThrow("class A { get foo() { } ; foo() {} }"); 60shouldNotThrow("class A { get foo() { } ; get foo() {} }"); 61shouldNotThrow("class A { get foo() { } ; set foo(x) {} }"); 62shouldNotThrow("class A { get foo() { } ; static foo() {} }"); 63shouldNotThrow("class A { get foo() { } ; static get foo() {} }"); 64shouldNotThrow("class A { get foo() { } ; static set foo(x) {} }"); 65 66shouldNotThrow("class A { set foo(x) { } ; foo() {} }"); 67shouldNotThrow("class A { set foo(x) { } ; get foo() {} }"); 68shouldNotThrow("class A { set foo(x) { } ; set foo(x) {} }"); 69shouldNotThrow("class A { set foo(x) { } ; static foo() {} }"); 70shouldNotThrow("class A { set foo(x) { } ; static get foo() {} }"); 71shouldNotThrow("class A { set foo(x) { } ; static set foo(x) {} }"); 72 73shouldNotThrow("class A { static foo() { } ; foo() {} }"); 74shouldNotThrow("class A { static foo() { } ; get foo() {} }"); 75shouldNotThrow("class A { static foo() { } ; set foo(x) {} }"); 76shouldNotThrow("class A { static foo() { } ; static foo() {} }"); 77shouldNotThrow("class A { static foo() { } ; static get foo() {} }"); 78shouldNotThrow("class A { static foo() { } ; static set foo(x) {} }"); 79 80shouldNotThrow("class A { static get foo() { } ; foo() {} }"); 81shouldNotThrow("class A { static get foo() { } ; get foo() {} }"); 82shouldNotThrow("class A { static get foo() { } ; set foo(x) {} }"); 83shouldNotThrow("class A { static get foo() { } ; static foo() {} }"); 84shouldNotThrow("class A { static get foo() { } ; static get foo() {} }"); 85shouldNotThrow("class A { static get foo() { } ; static set foo(x) {} }"); 86 87shouldNotThrow("class A { static set foo(x) { } ; foo() {} }"); 88shouldNotThrow("class A { static set foo(x) { } ; get foo() {} }"); 89shouldNotThrow("class A { static set foo(x) { } ; set foo(x) {} }"); 90shouldNotThrow("class A { static set foo(x) { } ; static foo() {} }"); 91shouldNotThrow("class A { static set foo(x) { } ; static get foo() {} }"); 92shouldNotThrow("class A { static set foo(x) { } ; static set foo(x) {} }"); 93 94var successfullyParsed = true; 95