OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 class Foo { | 7 class Foo { |
8 var field = 0; | 8 var field = 0; |
9 } | 9 } |
10 | 10 |
11 bar(x,y) { | 11 bar(x, y) { |
12 return x * 100 + y; | 12 return x * 100 + y; |
13 } | 13 } |
14 | 14 |
15 foo(z) { | 15 foo(z) { |
16 var x = 0, y = x; | 16 var x = 0, y = x; |
17 if (z > 0) { | 17 if (z > 0) { |
18 x = 10; | 18 x = 10; |
19 } | 19 } |
20 if (z > 10) { | 20 if (z > 10) { |
21 y = 20; | 21 y = 20; |
22 } | 22 } |
23 return bar(x,y); | 23 return bar(x, y); |
24 } | 24 } |
25 | 25 |
26 baz(z) { | 26 baz(z) { |
27 var f = new Foo() | 27 var f = new Foo() |
28 ..field = 10 | 28 ..field = 10 |
29 ..field = z; | 29 ..field = z; |
30 return f; | 30 return f; |
31 } | 31 } |
32 | 32 |
33 main() { | 33 main() { |
34 Expect.equals(0, foo(0)); | 34 Expect.equals(0, foo(0)); |
35 Expect.equals(1000, foo(5)); | 35 Expect.equals(1000, foo(5)); |
36 Expect.equals(1020, foo(15)); | 36 Expect.equals(1020, foo(15)); |
37 | 37 |
38 Expect.equals(20, baz(20).field); | 38 Expect.equals(20, baz(20).field); |
39 Expect.equals(30, baz(30).field); | 39 Expect.equals(30, baz(30).field); |
40 } | 40 } |
OLD | NEW |