| 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 " Foo = function() {\n" | 391 " Foo = function() {\n" |
| 392 " return 1;\n" | 392 " return 1;\n" |
| 393 " }();\n" | 393 " }();\n" |
| 394 " var Baz = Bar = function() {\n" | 394 " var Baz = Bar = function() {\n" |
| 395 " return 2;\n" | 395 " return 2;\n" |
| 396 " }\n" | 396 " }\n" |
| 397 "})();"); | 397 "})();"); |
| 398 // The inferred name is empty, because this is an assignment of a result. | 398 // The inferred name is empty, because this is an assignment of a result. |
| 399 CheckFunctionName(script, "return 1", ""); | 399 CheckFunctionName(script, "return 1", ""); |
| 400 // See MultipleAssignments test. | 400 // See MultipleAssignments test. |
| 401 CheckFunctionName(script, "return 2", "Enclosing.Bar"); | 401 // TODO(2276): Lazy compiling the enclosing outer closure would yield |
| 402 // in "Enclosing.Bar" being the inferred name here. |
| 403 CheckFunctionName(script, "return 2", "Bar"); |
| 402 } | 404 } |
| 403 | 405 |
| 404 | 406 |
| 405 TEST(MethodAssignmentInAnonymousFunctionCall) { | 407 TEST(MethodAssignmentInAnonymousFunctionCall) { |
| 406 InitializeVM(); | 408 InitializeVM(); |
| 407 v8::HandleScope scope; | 409 v8::HandleScope scope; |
| 408 | 410 |
| 409 v8::Handle<v8::Script> script = Compile( | 411 v8::Handle<v8::Script> script = Compile( |
| 410 "(function () {\n" | 412 "(function () {\n" |
| 411 " var EventSource = function () { };\n" | 413 " var EventSource = function () { };\n" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 431 " };\n" | 433 " };\n" |
| 432 " var foo = 10;\n" | 434 " var foo = 10;\n" |
| 433 " function f() {\n" | 435 " function f() {\n" |
| 434 " return wrapCode();\n" | 436 " return wrapCode();\n" |
| 435 " }\n" | 437 " }\n" |
| 436 " this.ref = f;\n" | 438 " this.ref = f;\n" |
| 437 "})()"); | 439 "})()"); |
| 438 script->Run(); | 440 script->Run(); |
| 439 CheckFunctionName(script, "return 2012", ""); | 441 CheckFunctionName(script, "return 2012", ""); |
| 440 } | 442 } |
| OLD | NEW |