blob: 3c4278ac0bbf06379b83b08a773551d06a8084fa [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// See: http://code.google.com/p/v8/issues/detail?id=4377
6
7// Switch statements should introduce their own lexical scope
8
9'use strict';
10
11switch (1) { case 1: let x = 2; }
12
13assertThrows(function() { return x; }, ReferenceError);
14
15{
16 let result;
17 let x = 1;
18 switch (x) {
19 case 1:
20 let x = 2;
21 result = x;
22 break;
23 default:
24 result = 0;
25 break;
26 }
27 assertEquals(1, x);
28 assertEquals(2, result);
29}
30
31{
32 let result;
33 let x = 1;
34 switch (eval('x')) {
35 case 1:
36 let x = 2;
37 result = x;
38 break;
39 default:
40 result = 0;
41 break;
42 }
43 assertEquals(1, x);
44 assertEquals(2, result);
45}