| 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 // Dart test program testing top-level variables. | 4 // Dart test program testing top-level variables. |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 | |
| 9 class TopLevelFuncTest { | 8 class TopLevelFuncTest { |
| 10 static testMain() { | 9 static testMain() { |
| 11 var z = [1, 10, 100, 1000]; | 10 var z = [1, 10, 100, 1000]; |
| 12 Expect.equals(Sum(z), 1111); | 11 Expect.equals(Sum(z), 1111); |
| 13 | 12 |
| 14 var w = Window; | 13 var w = Window; |
| 15 Expect.equals(w, "window"); | 14 Expect.equals(w, "window"); |
| 16 | 15 |
| 17 Expect.equals(null, rgb); | 16 Expect.equals(null, rgb); |
| 18 Color = "ff0000"; | 17 Color = "ff0000"; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 } | 34 } |
| 36 | 35 |
| 37 int Sum(List<int> v) { | 36 int Sum(List<int> v) { |
| 38 int s = 0; | 37 int s = 0; |
| 39 for (int i = 0; i < v.length; i++) { | 38 for (int i = 0; i < v.length; i++) { |
| 40 s += v[i]; | 39 s += v[i]; |
| 41 } | 40 } |
| 42 return s; | 41 return s; |
| 43 } | 42 } |
| 44 | 43 |
| 45 get Window { return "win" "dow"; } | 44 get Window { |
| 45 return "win" "dow"; |
| 46 } |
| 46 | 47 |
| 47 String rgb; | 48 String rgb; |
| 48 | 49 |
| 49 void set Color(col) { rgb = "#$col"; } | 50 void set Color(col) { |
| 51 rgb = "#$col"; |
| 52 } |
| 50 | 53 |
| 51 List<String> get digits { | 54 List<String> get digits { |
| 52 return ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; | 55 return ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; |
| 53 } | 56 } |
| 54 | 57 |
| 55 Function get Enumerator { | 58 Function get Enumerator { |
| 56 int k = 0; | 59 int k = 0; |
| 57 return () => k++; | 60 return () => k++; |
| 58 } | 61 } |
| 59 | 62 |
| 60 main() { | 63 main() { |
| 61 TopLevelFuncTest.testMain(); | 64 TopLevelFuncTest.testMain(); |
| 62 } | 65 } |
| OLD | NEW |