OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 v8::Handle<v8::Script> script = Compile( | 214 v8::Handle<v8::Script> script = Compile( |
215 "function f1(a) { return a(); }\n" | 215 "function f1(a) { return a(); }\n" |
216 "function f2(a, b) { return a() + b(); }\n" | 216 "function f2(a, b) { return a() + b(); }\n" |
217 "var result1 = f1(function() { return 1; })\n" | 217 "var result1 = f1(function() { return 1; })\n" |
218 "var result2 = f2(function() { return 2; }, function() { return 3; })"); | 218 "var result2 = f2(function() { return 2; }, function() { return 3; })"); |
219 // Can't infer names here. | 219 // Can't infer names here. |
220 CheckFunctionName(script, "return 1", ""); | 220 CheckFunctionName(script, "return 1", ""); |
221 CheckFunctionName(script, "return 2", ""); | 221 CheckFunctionName(script, "return 2", ""); |
222 CheckFunctionName(script, "return 3", ""); | 222 CheckFunctionName(script, "return 3", ""); |
223 } | 223 } |
| 224 |
| 225 |
| 226 TEST(MultipleFuncsConditional) { |
| 227 InitializeVM(); |
| 228 v8::HandleScope scope; |
| 229 |
| 230 v8::Handle<v8::Script> script = Compile( |
| 231 "fun1 = 0 ?\n" |
| 232 " function() { return 1; } :\n" |
| 233 " function() { return 2; }"); |
| 234 CheckFunctionName(script, "return 1", "fun1"); |
| 235 CheckFunctionName(script, "return 2", "fun1"); |
| 236 } |
| 237 |
| 238 |
| 239 TEST(MultipleFuncsInLiteral) { |
| 240 InitializeVM(); |
| 241 v8::HandleScope scope; |
| 242 |
| 243 v8::Handle<v8::Script> script = Compile( |
| 244 "function MyClass() {}\n" |
| 245 "MyClass.prototype = {\n" |
| 246 " method1: 0 ? function() { return 1; } :\n" |
| 247 " function() { return 2; } }"); |
| 248 CheckFunctionName(script, "return 1", "MyClass.method1"); |
| 249 CheckFunctionName(script, "return 2", "MyClass.method1"); |
| 250 } |
OLD | NEW |