Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: pkg/kernel/testcases/closures/for_loop.dart.expect

Issue 2561723003: Merge kernel closure conversion into the Dart SDK (Closed)
Patch Set: Remove path constraint Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 library;
2 import self as self;
3 import "dart:core" as core;
4 import "dart:mock" as mock;
5
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.";
8 field mock::Context context;
9 constructor •(final mock::Context context) → dynamic
10 : self::Closure#main#function::context = context
11 ;
12 method call() → dynamic {
13 "This is a temporary solution. In the VM, this will become an additional par ameter.";
14 final mock::Context #contextParameter = this.{self::Closure#main#function::c ontext};
15 return let final dynamic #t1 = #contextParameter.parent in let final dynamic #t2 = 0 in let final dynamic #t3 = #contextParameter.[](0) in let final dynamic #t4 = #t1.[]=(#t2, #t3) in #t3;
16 }
17 }
18 class Closure#main#function#1 extends core::Object implements core::Function {
19 field core::String note = "This is temporary. The VM doesn't need closure clas ses.";
20 field mock::Context context;
21 constructor •(final mock::Context context) → dynamic
22 : self::Closure#main#function#1::context = context
23 ;
24 method call() → dynamic {
25 "This is a temporary solution. In the VM, this will become an additional par ameter.";
26 final mock::Context #contextParameter = this.{self::Closure#main#function#1: :context};
27 if(!#contextParameter.parent.[](0).==(self::max.-(1)))
28 throw "last: ${#contextParameter.parent.[](0)} != ${self::max.-(1)}";
29 }
30 }
31 static const field core::int max = 100;
32 static method main() → dynamic {
33 dynamic closures = <dynamic>[];
34 dynamic closures2 = <dynamic>[];
35 final mock::Context #context = new mock::Context::•(1);
36 #context.parent = null;
37 #context.[]=(0, null);
38 {
39 mock::Context #context = new mock::Context::•(1);
40 #context.parent = #context;
41 #context.[]=(0, 0);
42 for (; #context.[](0).<(self::max); #context = #context.copy(), #context.[]= (0, #context.[](0).+(1))) {
43 closures.add(new self::Closure#main#function::•(#context));
44 closures2.add(new self::Closure#main#function#1::•(#context));
45 }
46 }
47 core::int sum = 0;
48 for (core::Function f in closures) {
49 sum = sum.+(f.call());
50 }
51 for (core::Function f in closures2) {
52 f.call();
53 }
54 core::int expectedSum = self::max.-(1).*(self::max).~/(2);
55 if(!expectedSum.==(sum)) {
56 throw core::Exception::•("Unexpected sum = ${sum} != ${expectedSum}");
57 }
58 }
OLDNEW
« no previous file with comments | « pkg/kernel/testcases/closures/for_loop.dart ('k') | pkg/kernel/testcases/closures/for_variable_capture_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698