OLD | NEW |
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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 v8::Handle<v8::Script> script = Compile( | 251 v8::Handle<v8::Script> script = Compile( |
252 "function MyClass() {}\n" | 252 "function MyClass() {}\n" |
253 "MyClass.prototype = {\n" | 253 "MyClass.prototype = {\n" |
254 " method1: 0 ? function() { return 1; } :\n" | 254 " method1: 0 ? function() { return 1; } :\n" |
255 " function() { return 2; } }"); | 255 " function() { return 2; } }"); |
256 CheckFunctionName(script, "return 1", "MyClass.method1"); | 256 CheckFunctionName(script, "return 1", "MyClass.method1"); |
257 CheckFunctionName(script, "return 2", "MyClass.method1"); | 257 CheckFunctionName(script, "return 2", "MyClass.method1"); |
258 } | 258 } |
259 | 259 |
260 | 260 |
| 261 TEST(AnonymousInAnonymousClosure1) { |
| 262 CcTest::InitializeVM(); |
| 263 v8::HandleScope scope(CcTest::isolate()); |
| 264 |
| 265 v8::Handle<v8::Script> script = Compile( |
| 266 "(function() {\n" |
| 267 " (function() {\n" |
| 268 " var a = 1;\n" |
| 269 " return;\n" |
| 270 " })();\n" |
| 271 " var b = function() {\n" |
| 272 " var c = 1;\n" |
| 273 " return;\n" |
| 274 " };\n" |
| 275 "})();"); |
| 276 CheckFunctionName(script, "return", ""); |
| 277 } |
| 278 |
| 279 |
| 280 TEST(AnonymousInAnonymousClosure2) { |
| 281 CcTest::InitializeVM(); |
| 282 v8::HandleScope scope(CcTest::isolate()); |
| 283 |
| 284 v8::Handle<v8::Script> script = Compile( |
| 285 "(function() {\n" |
| 286 " (function() {\n" |
| 287 " var a = 1;\n" |
| 288 " return;\n" |
| 289 " })();\n" |
| 290 " var c = 1;\n" |
| 291 "})();"); |
| 292 CheckFunctionName(script, "return", ""); |
| 293 } |
| 294 |
| 295 |
| 296 TEST(NamedInAnonymousClosure) { |
| 297 CcTest::InitializeVM(); |
| 298 v8::HandleScope scope(CcTest::isolate()); |
| 299 |
| 300 v8::Handle<v8::Script> script = Compile( |
| 301 "var foo = function() {\n" |
| 302 " (function named() {\n" |
| 303 " var a = 1;\n" |
| 304 " })();\n" |
| 305 " var c = 1;\n" |
| 306 " return;\n" |
| 307 "};"); |
| 308 CheckFunctionName(script, "return", "foo"); |
| 309 } |
| 310 |
| 311 |
261 // See http://code.google.com/p/v8/issues/detail?id=380 | 312 // See http://code.google.com/p/v8/issues/detail?id=380 |
262 TEST(Issue380) { | 313 TEST(Issue380) { |
263 CcTest::InitializeVM(); | 314 CcTest::InitializeVM(); |
264 v8::HandleScope scope(CcTest::isolate()); | 315 v8::HandleScope scope(CcTest::isolate()); |
265 | 316 |
266 v8::Handle<v8::Script> script = Compile( | 317 v8::Handle<v8::Script> script = Compile( |
267 "function a() {\n" | 318 "function a() {\n" |
268 "var result = function(p,a,c,k,e,d)" | 319 "var result = function(p,a,c,k,e,d)" |
269 "{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n" | 320 "{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n" |
270 "}"); | 321 "}"); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 " };\n" | 473 " };\n" |
423 " var foo = 10;\n" | 474 " var foo = 10;\n" |
424 " function f() {\n" | 475 " function f() {\n" |
425 " return wrapCode();\n" | 476 " return wrapCode();\n" |
426 " }\n" | 477 " }\n" |
427 " this.ref = f;\n" | 478 " this.ref = f;\n" |
428 "})()"); | 479 "})()"); |
429 script->Run(); | 480 script->Run(); |
430 CheckFunctionName(script, "return 2012", ""); | 481 CheckFunctionName(script, "return 2012", ""); |
431 } | 482 } |
OLD | NEW |