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

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

Issue 10911062: Codegen support for the argument definition test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « lib/compiler/implementation/tree/nodes.dart ('k') | tests/language/language.status » ('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) 2012, 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, 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 int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1));
45
46 main() {
47 test1(true, 54);
48 test1(false);
49 test2();
50 new A().test3(true, 54);
51 new A().test3(false);
52
53 var things = [test1, test2, new A().test3];
54
55 var closure = things[inscrutable(0)];
56 closure(true, 54);
57 closure(false);
58
59 closure = things[inscrutable(1)];
60 closure();
61
62 closure = things[inscrutable(2)];
63 closure(true, 54);
64 closure(false);
65 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/tree/nodes.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698