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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 CheckFunctionName(script, "return 2", ""); | 280 CheckFunctionName(script, "return 2", ""); |
281 CheckFunctionName(script, "return 3", ""); | 281 CheckFunctionName(script, "return 3", ""); |
282 } | 282 } |
283 | 283 |
284 | 284 |
285 TEST(MultipleFuncsConditional) { | 285 TEST(MultipleFuncsConditional) { |
286 CcTest::InitializeVM(); | 286 CcTest::InitializeVM(); |
287 v8::HandleScope scope(CcTest::isolate()); | 287 v8::HandleScope scope(CcTest::isolate()); |
288 | 288 |
289 v8::Local<v8::Script> script = Compile(CcTest::isolate(), | 289 v8::Local<v8::Script> script = Compile(CcTest::isolate(), |
290 "fun1 = 0 ?\n" | 290 "var x = 0;\n" |
| 291 "fun1 = x ?\n" |
291 " function() { return 1; } :\n" | 292 " function() { return 1; } :\n" |
292 " function() { return 2; }"); | 293 " function() { return 2; }"); |
293 CheckFunctionName(script, "return 1", "fun1"); | 294 CheckFunctionName(script, "return 1", "fun1"); |
294 CheckFunctionName(script, "return 2", "fun1"); | 295 CheckFunctionName(script, "return 2", "fun1"); |
295 } | 296 } |
296 | 297 |
297 | 298 |
298 TEST(MultipleFuncsInLiteral) { | 299 TEST(MultipleFuncsInLiteral) { |
299 CcTest::InitializeVM(); | 300 CcTest::InitializeVM(); |
300 v8::HandleScope scope(CcTest::isolate()); | 301 v8::HandleScope scope(CcTest::isolate()); |
301 | 302 |
302 v8::Local<v8::Script> script = | 303 v8::Local<v8::Script> script = |
303 Compile(CcTest::isolate(), | 304 Compile(CcTest::isolate(), |
| 305 "var x = 0;\n" |
304 "function MyClass() {}\n" | 306 "function MyClass() {}\n" |
305 "MyClass.prototype = {\n" | 307 "MyClass.prototype = {\n" |
306 " method1: 0 ? function() { return 1; } :\n" | 308 " method1: x ? function() { return 1; } :\n" |
307 " function() { return 2; } }"); | 309 " function() { return 2; } }"); |
308 CheckFunctionName(script, "return 1", "MyClass.method1"); | 310 CheckFunctionName(script, "return 1", "MyClass.method1"); |
309 CheckFunctionName(script, "return 2", "MyClass.method1"); | 311 CheckFunctionName(script, "return 2", "MyClass.method1"); |
310 } | 312 } |
311 | 313 |
312 | 314 |
313 TEST(AnonymousInAnonymousClosure1) { | 315 TEST(AnonymousInAnonymousClosure1) { |
314 CcTest::InitializeVM(); | 316 CcTest::InitializeVM(); |
315 v8::HandleScope scope(CcTest::isolate()); | 317 v8::HandleScope scope(CcTest::isolate()); |
316 | 318 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 " };\n" | 534 " };\n" |
533 " var foo = 10;\n" | 535 " var foo = 10;\n" |
534 " function f() {\n" | 536 " function f() {\n" |
535 " return wrapCode();\n" | 537 " return wrapCode();\n" |
536 " }\n" | 538 " }\n" |
537 " this.ref = f;\n" | 539 " this.ref = f;\n" |
538 "})()"); | 540 "})()"); |
539 script->Run(CcTest::isolate()->GetCurrentContext()).ToLocalChecked(); | 541 script->Run(CcTest::isolate()->GetCurrentContext()).ToLocalChecked(); |
540 CheckFunctionName(script, "return 2012", ""); | 542 CheckFunctionName(script, "return 2012", ""); |
541 } | 543 } |
OLD | NEW |