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

Side by Side Diff: test/cctest/test-func-name-inference.cc

Issue 8112007: Fix incorrect function name inference in case of assignment / global assignment. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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
« no previous file with comments | « src/parser.cc ('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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 354
355 v8::Handle<v8::Script> script = Compile( 355 v8::Handle<v8::Script> script = Compile(
356 "function createMyObj() {\n" 356 "function createMyObj() {\n"
357 " var obj = {};\n" 357 " var obj = {};\n"
358 " obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n" 358 " obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n"
359 " return obj;\n" 359 " return obj;\n"
360 "}"); 360 "}");
361 // Can't infer the function name statically. 361 // Can't infer the function name statically.
362 CheckFunctionName(script, "return 1", "obj.(anonymous function)"); 362 CheckFunctionName(script, "return 1", "obj.(anonymous function)");
363 } 363 }
364
365
366 TEST(GlobalAssignmentAndCall) {
367 InitializeVM();
368 v8::HandleScope scope;
369
370 v8::Handle<v8::Script> script = Compile(
371 "var Foo = function() {\n"
372 " return 1;\n"
373 "}();\n"
374 "var Baz = Bar = function() {\n"
375 " return 2;\n"
376 "}");
377 // The inferred name is empty, because this is an assignment of a result.
378 CheckFunctionName(script, "return 1", "");
379 // See MultipleAssignments test.
380 CheckFunctionName(script, "return 2", "Bar");
381 }
382
383
384 TEST(AssignmentAndCall) {
385 InitializeVM();
386 v8::HandleScope scope;
387
388 v8::Handle<v8::Script> script = Compile(
389 "(function Enclosing() {\n"
390 " var Foo;\n"
391 " Foo = function() {\n"
392 " return 1;\n"
393 " }();\n"
394 " var Baz = Bar = function() {\n"
395 " return 2;\n"
396 " }\n"
397 "})();");
398 // The inferred name is empty, because this is an assignment of a result.
399 CheckFunctionName(script, "return 1", "");
400 // See MultipleAssignments test.
401 CheckFunctionName(script, "return 2", "Enclosing.Bar");
402 }
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698