OLD | NEW |
1 library; | 1 library; |
2 import self as self; | 2 import self as self; |
3 import "dart:core" as core; | 3 import "dart:core" as core; |
4 import "dart:mock" as mock; | 4 import "dart:mock" as mock; |
5 | 5 |
6 class Closure#main#function extends core::Object implements core::Function { | 6 class Closure#main#function extends core::Object implements core::Function { |
7 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | 7 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; |
8 field mock::Context context; | 8 field mock::Context context; |
9 constructor •(final mock::Context context) → dynamic | 9 constructor •(final mock::Context context) → dynamic |
10 : self::Closure#main#function::context = context | 10 : self::Closure#main#function::context = context |
(...skipping 15 matching lines...) Expand all Loading... |
26 final mock::Context #contextParameter = this.{self::Closure#main#function#1:
:context}; | 26 final mock::Context #contextParameter = this.{self::Closure#main#function#1:
:context}; |
27 if(!#contextParameter.parent.[](0).==(self::max.-(1))) | 27 if(!#contextParameter.parent.[](0).==(self::max.-(1))) |
28 throw "last: ${#contextParameter.parent.[](0)} != ${self::max.-(1)}"; | 28 throw "last: ${#contextParameter.parent.[](0)} != ${self::max.-(1)}"; |
29 } | 29 } |
30 } | 30 } |
31 static const field core::int max = 100; | 31 static const field core::int max = 100; |
32 static method main() → dynamic { | 32 static method main() → dynamic { |
33 dynamic closures = <dynamic>[]; | 33 dynamic closures = <dynamic>[]; |
34 dynamic closures2 = <dynamic>[]; | 34 dynamic closures2 = <dynamic>[]; |
35 final mock::Context #context = new mock::Context::•(1); | 35 final mock::Context #context = new mock::Context::•(1); |
36 #context.parent = null; | |
37 #context.[]=(0, null); | 36 #context.[]=(0, null); |
38 { | 37 { |
39 mock::Context #context = new mock::Context::•(1); | 38 mock::Context #context = new mock::Context::•(1); |
40 #context.parent = #context; | 39 #context.parent = #context; |
41 #context.[]=(0, 0); | 40 #context.[]=(0, 0); |
42 for (; #context.[](0).<(self::max); #context = #context.copy(), #context.[]=
(0, #context.[](0).+(1))) { | 41 for (; #context.[](0).<(self::max); #context = #context.copy(), #context.[]=
(0, #context.[](0).+(1))) { |
43 closures.add(new self::Closure#main#function::•(#context)); | 42 closures.add(new self::Closure#main#function::•(#context)); |
44 closures2.add(new self::Closure#main#function#1::•(#context)); | 43 closures2.add(new self::Closure#main#function#1::•(#context)); |
45 } | 44 } |
46 } | 45 } |
47 core::int sum = 0; | 46 core::int sum = 0; |
48 for (core::Function f in closures) { | 47 for (core::Function f in closures) { |
49 sum = sum.+(f.call()); | 48 sum = sum.+(f.call()); |
50 } | 49 } |
51 for (core::Function f in closures2) { | 50 for (core::Function f in closures2) { |
52 f.call(); | 51 f.call(); |
53 } | 52 } |
54 core::int expectedSum = self::max.-(1).*(self::max).~/(2); | 53 core::int expectedSum = self::max.-(1).*(self::max).~/(2); |
55 if(!expectedSum.==(sum)) { | 54 if(!expectedSum.==(sum)) { |
56 throw core::Exception::•("Unexpected sum = ${sum} != ${expectedSum}"); | 55 throw core::Exception::•("Unexpected sum = ${sum} != ${expectedSum}"); |
57 } | 56 } |
58 } | 57 } |
OLD | NEW |