OLD | NEW |
1 import 'dart:collection'; | 1 import 'dart:collection'; |
2 import 'package:expect/expect.dart'; | 2 import 'package:expect/expect.dart'; |
3 | 3 |
4 class MyList extends ListBase { | 4 class MyList extends ListBase { |
5 int get length => 4; | 5 int get length => 4; |
6 set length(int x) {} | 6 set length(int x) {} |
7 int operator[](int x) => 42; | 7 int operator [](int x) => 42; |
8 void operator[]=(int x, val) {} | 8 void operator []=(int x, val) {} |
9 } | 9 } |
10 | 10 |
11 main() { | 11 main() { |
12 var x = new MyList(); | 12 var x = new MyList(); |
13 int z = 0; | 13 int z = 0; |
14 x.forEach((y) { z += y; }); | 14 x.forEach((y) { |
| 15 z += y; |
| 16 }); |
15 Expect.equals(z, 4 * 42); | 17 Expect.equals(z, 4 * 42); |
16 } | 18 } |
OLD | NEW |