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

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

Issue 7206015: Fix issue 1354: Bad function name inference. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 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/func-name-inferrer.cc ('K') | « test/cctest/cctest.status ('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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 "}"); 281 "}");
282 CheckFunctionName(script, "return p", ""); 282 CheckFunctionName(script, "return p", "");
283 } 283 }
284 284
285 285
286 TEST(MultipleAssignments) { 286 TEST(MultipleAssignments) {
287 InitializeVM(); 287 InitializeVM();
288 v8::HandleScope scope; 288 v8::HandleScope scope;
289 289
290 v8::Handle<v8::Script> script = Compile( 290 v8::Handle<v8::Script> script = Compile(
291 "var fun1 = fun2 = function () { return 1; }"); 291 "var fun1 = fun2 = function () { return 1; }\n"
292 "var bar1 = bar2 = bar3 = function () { return 2; }\n"
293 "foo1 = foo2 = function () { return 3; }\n"
294 "baz1 = baz2 = baz3 = function () { return 4; }");
292 CheckFunctionName(script, "return 1", "fun2"); 295 CheckFunctionName(script, "return 1", "fun2");
296 CheckFunctionName(script, "return 2", "bar3");
297 CheckFunctionName(script, "return 3", "foo2");
298 CheckFunctionName(script, "return 4", "baz3");
293 } 299 }
294 300
295 301
296 TEST(PassedAsConstructorParameter) { 302 TEST(AsConstructorParameter) {
297 InitializeVM(); 303 InitializeVM();
298 v8::HandleScope scope; 304 v8::HandleScope scope;
299 305
300 v8::Handle<v8::Script> script = Compile( 306 v8::Handle<v8::Script> script = Compile(
301 "function Foo() {}\n" 307 "function Foo() {}\n"
302 "var foo = new Foo(function() { return 1; })"); 308 "var foo = new Foo(function() { return 1; })\n"
309 "var bar = new Foo(function() { return 2; }, function() { return 3; })");
303 CheckFunctionName(script, "return 1", ""); 310 CheckFunctionName(script, "return 1", "");
311 CheckFunctionName(script, "return 2", "");
312 CheckFunctionName(script, "return 3", "");
304 } 313 }
305 314
306 315
307 TEST(FactoryHashmap) { 316 TEST(FactoryHashmap) {
308 InitializeVM(); 317 InitializeVM();
309 v8::HandleScope scope; 318 v8::HandleScope scope;
310 319
311 v8::Handle<v8::Script> script = Compile( 320 v8::Handle<v8::Script> script = Compile(
312 "function createMyObj() {\n" 321 "function createMyObj() {\n"
313 " var obj = {};\n" 322 " var obj = {};\n"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 354
346 v8::Handle<v8::Script> script = Compile( 355 v8::Handle<v8::Script> script = Compile(
347 "function createMyObj() {\n" 356 "function createMyObj() {\n"
348 " var obj = {};\n" 357 " var obj = {};\n"
349 " obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n" 358 " obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n"
350 " return obj;\n" 359 " return obj;\n"
351 "}"); 360 "}");
352 // Can't infer the function name statically. 361 // Can't infer the function name statically.
353 CheckFunctionName(script, "return 1", "obj.(anonymous function)"); 362 CheckFunctionName(script, "return 1", "obj.(anonymous function)");
354 } 363 }
OLDNEW
« src/func-name-inferrer.cc ('K') | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698