Index: pkg/kernel/testcases/closures/uncaptured_for_in_loop.dart.expect |
diff --git a/pkg/kernel/testcases/closures/uncaptured_for_in_loop.dart.expect b/pkg/kernel/testcases/closures/uncaptured_for_in_loop.dart.expect |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eb0f413218f30b31cb80bbf929f8a4851a8838f1 |
--- /dev/null |
+++ b/pkg/kernel/testcases/closures/uncaptured_for_in_loop.dart.expect |
@@ -0,0 +1,35 @@ |
+library; |
+import self as self; |
+import "dart:core" as core; |
+import "dart:mock" as mock; |
+ |
+class Closure#main#function extends core::Object implements core::Function { |
+ field core::String note = "This is temporary. The VM doesn't need closure classes."; |
+ field mock::Context context; |
+ constructor •(final mock::Context context) → dynamic |
+ : self::Closure#main#function::context = context |
+ ; |
+ method call() → dynamic { |
+ "This is a temporary solution. In the VM, this will become an additional parameter."; |
+ final mock::Context #contextParameter = this.{self::Closure#main#function::context}; |
+ return #contextParameter.[](0); |
+ } |
+} |
+static const field dynamic numbers = const <core::int>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
+static method main() → dynamic { |
+ dynamic closures = <dynamic>[]; |
+ for (core::int i in self::numbers) { |
+ final mock::Context #context = new mock::Context::•(1); |
+ #context.parent = null; |
+ #context.[]=(0, i); |
+ closures.add(new self::Closure#main#function::•(#context)); |
+ } |
+ core::int sum = 0; |
+ for (core::Function f in closures) { |
+ sum = sum.+(f.call()); |
+ } |
+ core::int expectedSum = self::numbers.length.-(1).*(self::numbers.length).~/(2); |
+ if(!expectedSum.==(sum)) { |
+ throw core::Exception::•("Unexpected sum = ${sum} != ${expectedSum}"); |
+ } |
+} |