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

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

Issue 11745028: Fix incorrect desugaring of cascades. (Closed) Base URL: https://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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Test cascades, issue 7665. 5 // Test cascades, issues 7494 (vm), 7689 (dart2js).
6 6
7 main() { 7 main() {
8 var a = new Element(null); 8 var a = new Element(null);
9 Expect.equals(1, a.path0.length); 9 Expect.equals(1, a.path0.length);
10 Expect.equals(a, a.path0[0]); 10 Expect.equals(a, a.path0[0]);
11 11
12 Expect.equals(1, a.path1.length); // 2 instead of 1 12 // Issue 7693: e0 ? e1 : e2..f() parses as (e0 ? e1 : e2)..f().
13 Expect.equals(2, a.path1.length);
13 Expect.equals(a, a.path1[0]); 14 Expect.equals(a, a.path1[0]);
15 Expect.equals(a, a.path1[1]);
14 16
15 Expect.equals(1, a.path2.length); // NPE. 17 Expect.equals(1, a.path2.length); // NPE.
16 18
17 var b = new Element(a); 19 var b = new Element(a);
18 Expect.equals(2, b.path0.length); 20 Expect.equals(2, b.path0.length);
19 Expect.equals(a, b.path0[0]); 21 Expect.equals(a, b.path0[0]);
20 Expect.equals(b, b.path0[1]); 22 Expect.equals(b, b.path0[1]);
21 23
22 Expect.equals(2, b.path1.length); // 3 instead of 2. 24 Expect.equals(3, b.path1.length);
23 Expect.equals(a, b.path1[0]); 25 Expect.equals(a, b.path1[0]);
24 Expect.equals(b, b.path1[1]); 26 Expect.equals(a, b.path1[1]);
27 Expect.equals(b, b.path1[2]);
25 28
26 Expect.equals(2, b.path2.length); // NPE. 29 Expect.equals(2, b.path2.length); // NPE.
27 } 30 }
28 31
29 32
30 class Element { 33 class Element {
31 final Element parent; 34 final Element parent;
32 35
33 Element(this.parent); 36 Element(this.parent);
34 37
35 List<Element> get path0 { 38 List<Element> get path0 {
36 if (parent == null) { 39 if (parent == null) {
37 return <Element>[this]; 40 return <Element>[this];
38 } else { 41 } else {
39 return parent.path0..add(this); 42 return parent.path0..add(this);
40 } 43 }
41 } 44 }
42 45
43 List<Element> get path1 { 46 List<Element> get path1 {
44 return (parent == null) ? <Element>[this] : parent.path1..add(this); 47 return (parent == null) ? <Element>[this] : parent.path1..add(this);
45 } 48 }
46 49
47 List<Element> get path2 { 50 List<Element> get path2 {
48 return (parent == null) ? <Element>[this] : (parent.path2..add(this)); 51 return (parent == null) ? <Element>[this] : (parent.path2..add(this));
49 } 52 }
50 } 53 }
OLDNEW
« runtime/vm/parser.cc ('K') | « runtime/vm/parser.cc ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698