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

Side by Side Diff: tests/language/argument_definition4_test.dart

Issue 12036088: Fix argument test for the captured parameter of an outer function (issue 8007). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.cc ('k') | tests/language/argument_definition5_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, 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 test1(bool passed, {a: 42}) {
6 if (passed) {
7 Expect.equals(54, a);
8 Expect.isTrue(?a);
9 } else {
10 Expect.equals(42, a);
11 Expect.isFalse(?a);
12 }
13 Expect.isTrue(?passed);
14 }
15
16 test2() {
17 var closure = (passed, {a: 42}) {
18 if (passed) {
19 Expect.equals(54, a);
20 Expect.isTrue(?a);
21 } else {
22 Expect.equals(42, a);
23 Expect.isFalse(?a);
24 }
25 Expect.isTrue(?passed);
26 };
27 closure(true, a:54);
28 closure(false);
29 }
30
31 class A {
32 test3(bool passed, {a: 42}) {
33 if (passed) {
34 Expect.equals(54, a);
35 Expect.isTrue(?a);
36 } else {
37 Expect.equals(42, a);
38 Expect.isFalse(?a);
39 }
40 Expect.isTrue(?passed);
41 }
42 }
43
44
45 test4(bool passed, {a}) {
46 if (passed) {
47 Expect.equals(54, a);
48 Expect.isTrue(?a);
49 } else {
50 Expect.equals(null, a);
51 Expect.isFalse(?a);
52 }
53 Expect.isTrue(?passed);
54 }
55
56 int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1));
57
58 main() {
59 test1(true, a:54);
60 test1(false);
61 test2();
62 new A().test3(true, a:54);
63 new A().test3(false);
64
65 var things = [test1, test2, new A().test3];
66
67 var closure = things[inscrutable(0)];
68 closure(true, a:54);
69 closure(false);
70
71 closure = things[inscrutable(1)];
72 closure();
73
74 closure = things[inscrutable(2)];
75 closure(true, a:54);
76 closure(false);
77
78 test4(true, a:54);
79 test4(false);
80 }
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | tests/language/argument_definition5_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698