From b0072ca1b51c90c2b34a87849972eab0cb59a67b Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Thu, 30 Jun 2016 09:00:54 -0400 Subject: [PATCH] Add tests for early errors in SwithStatement --- .../statements/switch/early-lex-dup.js | 20 +++++++++++++++++ .../switch/early-lex-var-collision.js | 22 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/language/statements/switch/early-lex-dup.js create mode 100644 test/language/statements/switch/early-lex-var-collision.js diff --git a/test/language/statements/switch/early-lex-dup.js b/test/language/statements/switch/early-lex-dup.js new file mode 100644 index 0000000000..3f74919c6f --- /dev/null +++ b/test/language/statements/switch/early-lex-dup.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-switch-statement-static-semantics-early-errors +es6id: 13.12.1 +description: Syntax error from duplicate lexical variables +info: > + It is a Syntax Error if the LexicallyDeclaredNames of CaseBlock contains any + duplicate entries. +negative: SyntaxError +features: [let, const] +---*/ + +switch (0) { + case 1: + let test262id; + break; + default: + const test262id = null; +} diff --git a/test/language/statements/switch/early-lex-var-collision.js b/test/language/statements/switch/early-lex-var-collision.js new file mode 100644 index 0000000000..b642264586 --- /dev/null +++ b/test/language/statements/switch/early-lex-var-collision.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-switch-statement-static-semantics-early-errors +es6id: 13.12.1 +description: > + Syntax error from collisions between lexical variables and var-declarared + variables +info: > + It is a Syntax Error if any element of the LexicallyDeclaredNames of + CaseClauses also occurs in the VarDeclaredNames of CaseClauses. +negative: SyntaxError +features: [let] +---*/ + +switch (0) { + case 1: + var test262id; + break; + default: + let test262id; +} -- GitLab