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

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

Issue 6902203: Fix presubmit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 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 | « no previous file | 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 2007-2009 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
11 // with the distribution. 11 // with the distribution.
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
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; }");
292 CheckFunctionName(script, "return 1", "fun2"); 292 CheckFunctionName(script, "return 1", "fun2");
293 } 293 }
294 294
295 295
296 TEST(PassedAsConstructorParameter) { 296 TEST(PassedAsConstructorParameter) {
297 InitializeVM(); 297 InitializeVM();
298 v8::HandleScope scope; 298 v8::HandleScope scope;
299 299
300 v8::Handle<v8::Script> script = Compile( 300 v8::Handle<v8::Script> script = Compile(
301 "function Foo() {}\n" 301 "function Foo() {}\n"
302 "var foo = new Foo(function() { return 1; })"); 302 "var foo = new Foo(function() { return 1; })");
303 CheckFunctionName(script, "return 1", ""); 303 CheckFunctionName(script, "return 1", "");
304 } 304 }
305 305
306 306
307 TEST(FactoryHashmap) { 307 TEST(FactoryHashmap) {
308 InitializeVM(); 308 InitializeVM();
309 v8::HandleScope scope; 309 v8::HandleScope scope;
310 310
311 v8::Handle<v8::Script> script = Compile( 311 v8::Handle<v8::Script> script = Compile(
312 "function createMyObj() {\n" 312 "function createMyObj() {\n"
313 " var obj = {};\n" 313 " var obj = {};\n"
314 " obj[\"method1\"] = function() { return 1; }\n" 314 " obj[\"method1\"] = function() { return 1; }\n"
315 " obj[\"method2\"] = function() { return 2; }\n" 315 " obj[\"method2\"] = function() { return 2; }\n"
316 " return obj;\n" 316 " return obj;\n"
317 "}"); 317 "}");
318 CheckFunctionName(script, "return 1", "obj.method1"); 318 CheckFunctionName(script, "return 1", "obj.method1");
319 CheckFunctionName(script, "return 2", "obj.method2"); 319 CheckFunctionName(script, "return 2", "obj.method2");
320 } 320 }
321 321
322 322
323 TEST(FactoryHashmapVariable) { 323 TEST(FactoryHashmapVariable) {
324 InitializeVM(); 324 InitializeVM();
325 v8::HandleScope scope; 325 v8::HandleScope scope;
326 326
327 v8::Handle<v8::Script> script = Compile( 327 v8::Handle<v8::Script> script = Compile(
328 "function createMyObj() {\n" 328 "function createMyObj() {\n"
329 " var obj = {};\n" 329 " var obj = {};\n"
330 " var methodName = \"method1\";\n" 330 " var methodName = \"method1\";\n"
331 " obj[methodName] = function() { return 1; }\n" 331 " obj[methodName] = function() { return 1; }\n"
332 " methodName = \"method2\";\n" 332 " methodName = \"method2\";\n"
333 " obj[methodName] = function() { return 2; }\n" 333 " obj[methodName] = function() { return 2; }\n"
334 " return obj;\n" 334 " return obj;\n"
335 "}"); 335 "}");
336 // Can't infer function names statically. 336 // Can't infer function names statically.
337 CheckFunctionName(script, "return 1", "obj.(anonymous function)"); 337 CheckFunctionName(script, "return 1", "obj.(anonymous function)");
338 CheckFunctionName(script, "return 2", "obj.(anonymous function)"); 338 CheckFunctionName(script, "return 2", "obj.(anonymous function)");
339 } 339 }
340 340
341 341
342 TEST(FactoryHashmapConditional) { 342 TEST(FactoryHashmapConditional) {
343 InitializeVM(); 343 InitializeVM();
344 v8::HandleScope scope; 344 v8::HandleScope scope;
345 345
346 v8::Handle<v8::Script> script = Compile( 346 v8::Handle<v8::Script> script = Compile(
347 "function createMyObj() {\n" 347 "function createMyObj() {\n"
348 " var obj = {};\n" 348 " var obj = {};\n"
349 " obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n" 349 " obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n"
350 " return obj;\n" 350 " return obj;\n"
351 "}"); 351 "}");
352 // Can't infer the function name statically. 352 // Can't infer the function name statically.
353 CheckFunctionName(script, "return 1", "obj.(anonymous function)"); 353 CheckFunctionName(script, "return 1", "obj.(anonymous function)");
354 } 354 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698