OLD | NEW |
(Empty) | |
| 1 library; |
| 2 import self as self; |
| 3 import "dart:core" as core; |
| 4 |
| 5 static method doit(core::int x) → void { |
| 6 final Vector #context = MakeVector(3); |
| 7 #context[2] = x; |
| 8 final core::int max = 10; |
| 9 final core::double expectedSum = max.-(1).*(max)./(2); |
| 10 core::int counter = 0; |
| 11 dynamic calls = <dynamic>[]; |
| 12 while (counter.<(max)) { |
| 13 final Vector #context = MakeVector(3); |
| 14 #context[1] = #context; |
| 15 #context[2] = counter; |
| 16 calls.add(MakeClosure<() → dynamic>(self::closure#doit#function, #context)); |
| 17 counter = counter.+(1); |
| 18 } |
| 19 core::double sum = 0.0; |
| 20 for (dynamic c in calls) |
| 21 sum = sum.+(c.call()); |
| 22 if(!sum.==(expectedSum)) |
| 23 throw core::Exception::•("Unexpected sum = ${sum} != ${expectedSum}"); |
| 24 } |
| 25 static method main() → void { |
| 26 self::doit(0); |
| 27 } |
| 28 static method closure#doit#function(Vector #contextParameter) → dynamic { |
| 29 return (#contextParameter[2]).+(#contextParameter[1][2]); |
| 30 } |
OLD | NEW |