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

Side by Side Diff: test/mjsunit/strict-mode.js

Issue 6382006: Strict mode parameter validation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Kevin's feedback Created 9 years, 11 months 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 | Annotate | Revision Log
« src/scanner-base.h ('K') | « src/scopes.h ('k') | no next file » | 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // 'with' disallowed in strict mode. 69 // 'with' disallowed in strict mode.
70 CheckStrictMode("with({}) {}", SyntaxError); 70 CheckStrictMode("with({}) {}", SyntaxError);
71 71
72 // Function named 'eval'. 72 // Function named 'eval'.
73 CheckStrictMode("function eval() {}", SyntaxError) 73 CheckStrictMode("function eval() {}", SyntaxError)
74 74
75 // Function named 'arguments'. 75 // Function named 'arguments'.
76 CheckStrictMode("function arguments() {}", SyntaxError) 76 CheckStrictMode("function arguments() {}", SyntaxError)
77 77
78 // Function parameter named 'eval'. 78 // Function parameter named 'eval'.
79 //CheckStrictMode("function foo(a, b, eval, c, d) {}", SyntaxError) 79 CheckStrictMode("function foo(a, b, eval, c, d) {}", SyntaxError)
80 80
81 // Function parameter named 'arguments'. 81 // Function parameter named 'arguments'.
82 //CheckStrictMode("function foo(a, b, arguments, c, d) {}", SyntaxError) 82 CheckStrictMode("function foo(a, b, arguments, c, d) {}", SyntaxError)
83 83
84 // Property accessor parameter named 'eval'. 84 // Property accessor parameter named 'eval'.
85 //CheckStrictMode("var o = { set foo(eval) {} }", SyntaxError) 85 CheckStrictMode("var o = { set foo(eval) {} }", SyntaxError)
86 86
87 // Property accessor parameter named 'arguments'. 87 // Property accessor parameter named 'arguments'.
88 //CheckStrictMode("var o = { set foo(arguments) {} }", SyntaxError) 88 CheckStrictMode("var o = { set foo(arguments) {} }", SyntaxError)
89 89
90 // Duplicate function parameter name. 90 // Duplicate function parameter name.
91 //CheckStrictMode("function foo(a, b, c, d, b) {}", SyntaxError) 91 CheckStrictMode("function foo(a, b, c, d, b) {}", SyntaxError)
Lasse Reichstein 2011/01/25 13:03:55 How about checking that it's not an error in non-s
Martin Maly 2011/01/25 17:21:25 Already implemented. The CheckStrictMode function
92 92
93 // catch(eval) 93 // catch(eval)
94 CheckStrictMode("try{}catch(eval){};", SyntaxError) 94 CheckStrictMode("try{}catch(eval){};", SyntaxError)
95 95
96 // catch(arguments) 96 // catch(arguments)
97 CheckStrictMode("try{}catch(arguments){};", SyntaxError) 97 CheckStrictMode("try{}catch(arguments){};", SyntaxError)
98 98
99 // var eval 99 // var eval
100 CheckStrictMode("var eval;", SyntaxError) 100 CheckStrictMode("var eval;", SyntaxError)
101 101
102 // var arguments 102 // var arguments
103 CheckStrictMode("var arguments;", SyntaxError) 103 CheckStrictMode("var arguments;", SyntaxError)
104 104
105 // Strict mode applies to the function in which the directive is used.. 105 // Strict mode applies to the function in which the directive is used..
106 //assertThrows('\ 106 assertThrows('\
107 //function foo(eval) {\ 107 function foo(eval) {\
108 // "use strict";\ 108 "use strict";\
109 //}', SyntaxError); 109 }', SyntaxError);
110 110
111 // Strict mode doesn't affect the outer stop of strict code. 111 // Strict mode doesn't affect the outer stop of strict code.
112 function NotStrict(eval) { 112 function NotStrict(eval) {
113 function Strict() { 113 function Strict() {
114 "use strict"; 114 "use strict";
115 } 115 }
116 with ({}) {}; 116 with ({}) {};
117 } 117 }
OLDNEW
« src/scanner-base.h ('K') | « src/scopes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698