| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Tests function statements and expressions. | 5 // Tests function statements and expressions. |
| 6 | 6 |
| 7 class Bug4089219 { | 7 class Bug4089219 { |
| 8 int x; | 8 int x; |
| 9 var f; | 9 var f; |
| 10 | 10 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 int result = f(1, 2, 3); | 300 int result = f(1, 2, 3); |
| 301 assert(5 == result, "expected 5 got ${result}"); | 301 assert(5 == result, "expected 5 got ${result}"); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void testFunctionDefaults1() { | 304 void testFunctionDefaults1() { |
| 305 // TODO(jimhug): This return null shouldn't be necessary. | 305 // TODO(jimhug): This return null shouldn't be necessary. |
| 306 function f() { return null; }; | 306 function f() { return null; }; |
| 307 (function(a = 10) { assert(a == 10); })(); | 307 (function(a = 10) { assert(a == 10); })(); |
| 308 (function(a, b = 10) { assert(b == 10); })(1); | 308 (function(a, b = 10) { assert(b == 10); })(1); |
| 309 (function(a = 10) { assert(a == null); })( f() ); | 309 (function(a = 10) { assert(a == null); })( f() ); |
| 310 // FAILS: (function(a = 10) { assert(a === null); })( f() ); | |
| 311 } | 310 } |
| 312 | 311 |
| 313 void testFunctionDefaults2() { | 312 void testFunctionDefaults2() { |
| 314 assert( helperFunctionDefaults2() == 10); | 313 assert( helperFunctionDefaults2() == 10); |
| 315 assert( helperFunctionDefaults2(1) == 1); | 314 assert( helperFunctionDefaults2(1) == 1); |
| 316 } | 315 } |
| 317 | 316 |
| 318 void helperFunctionDefaults2(a = 10) { | 317 void helperFunctionDefaults2(a = 10) { |
| 319 return (function(){return a;})(); | 318 return (function(){return a;})(); |
| 320 } | 319 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 foo = f; | 360 foo = f; |
| 362 fooIntString = f; | 361 fooIntString = f; |
| 363 | 362 |
| 364 foo = fooIntString; | 363 foo = fooIntString; |
| 365 fooIntString = foo; | 364 fooIntString = foo; |
| 366 | 365 |
| 367 uf = uf2; | 366 uf = uf2; |
| 368 uf2 = uf; | 367 uf2 = uf; |
| 369 } | 368 } |
| 370 } | 369 } |
| OLD | NEW |