Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: test/preparser/strict-function-statement.pyt

Issue 788143004: Update strict mode function declaration tests before block scoping. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/preparser/testcfg.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2011 the V8 project authors. All rights reserved. 1 # Copyright 2011 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 11 matching lines...) Expand all
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 # In strict mode, function declarations may only appear as source elements. 28 # In strict mode, function declarations may only appear as source elements.
29 29
30 # A template that performs the same strict-mode test in different 30 # A template that performs the same strict-mode test in different
31 # scopes (global scope, function scope, and nested function scope). 31 # scopes (global scope, function scope, and nested function scope).
32 def StrictTest(name, source): 32 def StrictTest(name, source, legacy):
33 Test(name, '"use strict";\n' + source, "strict_function") 33 if legacy:
34 extra_flags = ["--noharmony-scoping"]
35 else:
36 extra_flags = []
37 Test(name, '"use strict";\n' + source, "strict_function",
38 extra_flags)
34 Test(name + '-infunc', 39 Test(name + '-infunc',
35 'function foo() {\n "use strict";\n' + source +'\n}\n', 40 'function foo() {\n "use strict";\n' + source +'\n}\n',
36 "strict_function") 41 "strict_function",
42 extra_flags)
37 Test(name + '-infunc2', 43 Test(name + '-infunc2',
38 'function foo() {\n "use strict";\n function bar() {\n' + 44 'function foo() {\n "use strict";\n function bar() {\n' +
39 source +'\n }\n}\n', 45 source +'\n }\n}\n',
40 "strict_function") 46 "strict_function",
47 extra_flags)
41 48
42 # Not testing with-scope, since with is not allowed in strict mode at all. 49 # Not testing with-scope, since with is not allowed in strict mode at all.
43 50
44 StrictTest("block", """ 51 StrictTest("block", """
45 { function foo() { } } 52 { function foo() { } }
46 """) 53 """, True)
47 54
48 StrictTest("try-w-catch", """ 55 StrictTest("try-w-catch", """
49 try { function foo() { } } catch (e) { } 56 try { function foo() { } } catch (e) { }
50 """) 57 """, True)
51 58
52 StrictTest("try-w-finally", """ 59 StrictTest("try-w-finally", """
53 try { function foo() { } } finally { } 60 try { function foo() { } } finally { }
54 """) 61 """, True)
55 62
56 StrictTest("catch", """ 63 StrictTest("catch", """
57 try { } catch (e) { function foo() { } } 64 try { } catch (e) { function foo() { } }
58 """) 65 """, True)
59 66
60 StrictTest("finally", """ 67 StrictTest("finally", """
61 try { } finally { function foo() { } } 68 try { } finally { function foo() { } }
62 """) 69 """, True)
63 70
64 StrictTest("for", """ 71 StrictTest("for", """
65 for (;;) { function foo() { } } 72 for (;;) { function foo() { } }
66 """) 73 """, True)
67 74
68 StrictTest("while", """ 75 StrictTest("while", """
69 while (true) { function foo() { } } 76 while (true) { function foo() { } }
70 """) 77 """, True)
71 78
72 StrictTest("do", """ 79 StrictTest("do", """
73 do { function foo() { } } while (true); 80 do { function foo() { } } while (true);
74 """) 81 """, True)
75 82
76 StrictTest("then", """ 83 StrictTest("then", """
77 if (true) { function foo() { } } 84 if (true) { function foo() { } }
78 """) 85 """, True)
79 86
80 87
81 StrictTest("then-w-else", """ 88 StrictTest("then-w-else", """
82 if (true) { function foo() { } } else { } 89 if (true) { function foo() { } } else { }
83 """) 90 """, True)
84 91
85 92
86 StrictTest("else", """ 93 StrictTest("else", """
87 if (true) { } else { function foo() { } } 94 if (true) { } else { function foo() { } }
88 """) 95 """, True)
89 96
90 StrictTest("switch-case", """ 97 StrictTest("switch-case", """
91 switch (true) { case true: function foo() { } } 98 switch (true) { case true: function foo() { } }
92 """) 99 """, False)
93 100
94 StrictTest("labeled", """ 101 StrictTest("labeled", """
95 label: function foo() { } 102 label: function foo() { }
96 """) 103 """, False)
97 104
98 105
99 106
OLDNEW
« no previous file with comments | « no previous file | test/preparser/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698