1// Copyright JS Foundation and other contributors, http://js.foundation 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15function checkSyntax (str) { 16 try { 17 eval (str); 18 assert (false); 19 } catch (e) { 20 assert (e instanceof SyntaxError); 21 } 22} 23 24checkSyntax ("if (5) let a;"); 25checkSyntax ("if (5) const a;"); 26checkSyntax ("if (0) {} else let a;"); 27checkSyntax ("if (0) {} else const a;"); 28checkSyntax ("while (5) let a;"); 29checkSyntax ("while (5) const a;"); 30checkSyntax ("do let a; while (5)"); 31checkSyntax ("do const a; while (5)"); 32checkSyntax ("for (a in b) let c;"); 33checkSyntax ("for (a in b) const c;"); 34checkSyntax ("for (a of b) let c;"); 35checkSyntax ("for (a of b) const c;"); 36checkSyntax ("for (;;) let c;"); 37checkSyntax ("for (;;) const c;"); 38checkSyntax ("with ({}) let c;"); 39checkSyntax ("with ({}) const c;"); 40checkSyntax ("a: let c;"); 41checkSyntax ("a: const c;"); 42