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

Side by Side Diff: tests/kernel/unsorted/closures_test.dart

Issue 2451893004: Revert "Reland "Merge more Kernel infrastructure from kernel_sdk SDK fork."" (Closed)
Patch Set: Created 4 years, 1 month 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 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'expect.dart';
6
7 class Base {
8 int constant1000() => 1000;
9 }
10
11 class Foo extends Base {
12 final int base;
13 Foo(this.base);
14
15 nestedAdderFunction(a, b, c, d, e) {
16 var result = a + b;
17 return () {
18 var result2 = c + d;
19 return () {
20 return base + result + result2 + e;
21 };
22 };
23 }
24
25 nestedAdderFunction2(a, b, c, d, e) {
26 var result = a + b;
27 return () {
28 var base = super.constant1000;
29 var result2 = c + d;
30 return () {
31 return base() + result + result2 + e;
32 };
33 };
34 }
35 }
36
37 nestedAdderFunction(a, b, c, d, e) {
38 var result = a + b;
39 return () {
40 var result2 = c + d;
41 return () {
42 return result + result2 + e;
43 };
44 };
45 }
46
47 main() {
48 Expect.isTrue(nestedAdderFunction(1, 2, 3, 4, 5)()() == 15);
49
50 var foo = new Foo(100);
51 Expect.isTrue(foo.nestedAdderFunction(1, 2, 3, 4, 5)()() == 115);
52 Expect.isTrue(foo.nestedAdderFunction2(1, 2, 3, 4, 5)()() == 1015);
53
54 var funs = [];
55 for (int i = 0; i < 3; i++) {
56 funs.add(() => i);
57 }
58 Expect.isTrue((funs[0]() + funs[1]() + funs[2]()) == 3);
59
60 var funs2 = [];
61 for (var i in [0, 1, 2]) {
62 funs2.add(() => i);
63 }
64 Expect.isTrue((funs2[0]() + funs2[1]() + funs2[2]()) == 3);
65 }
OLDNEW
« no previous file with comments | « tests/kernel/unsorted/closures_regression_test.dart ('k') | tests/kernel/unsorted/conditional_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698