Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | |
|
rossberg
2015/04/10 14:02:56
Nit: I'd prefer to keep these tests in the main fi
conradw
2015/04/10 14:20:49
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Flags: --strong-mode --harmony-arrow-functions | |
| 6 "use strict"; | |
| 7 | |
| 8 function CheckStrongMode(code) { | |
| 9 let strictContexts = [ | |
| 10 ["'use strict';", ""], | |
| 11 ["function outer() { 'use strict';", "}"], | |
| 12 ["function outer() { 'use strict'; function inner() {", "}}"], | |
| 13 ["class C { m() {", "} }"] | |
| 14 ] | |
| 15 let strongContexts = [ | |
| 16 ["'use strong';", ""], | |
| 17 ["function outer() { 'use strong';", "}"], | |
| 18 ["function outer() { 'use strong'; function inner() {", "}}"], | |
| 19 ["class C { m() { 'use strong';", "} }"] | |
| 20 ] | |
| 21 | |
| 22 for (let context of strictContexts) { | |
| 23 assertDoesNotThrow(context[0] + code + context[1]); | |
| 24 } | |
| 25 for (let context of strongContexts) { | |
| 26 assertThrows(context[0] + code + context[1], SyntaxError); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 CheckStrongMode("(undefined => {return});"); | |
| 31 assertThrows("(undefined => {'use strong';});"); | |
| 32 | |
| 33 CheckStrongMode("((undefined, b, c) => {return});"); | |
| 34 assertThrows("((undefined, b, c) => {'use strong';});"); | |
| 35 | |
| 36 CheckStrongMode("((a, undefined, c) => {return});"); | |
| 37 assertThrows("((a, undefined, c) => {'use strong';});"); | |
| 38 | |
| 39 CheckStrongMode("((a, b, undefined) => {return});"); | |
| 40 assertThrows("((a, b, undefined) => {'use strong';});"); | |
| OLD | NEW |