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

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

Issue 1255293005: Fix analyzer interpretation of 'ClassName?.staticMember'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // Verify semantics of the ?. operator when it appears in a postincrement or 5 // Verify semantics of the ?. operator when it appears in a postincrement or
6 // preincrement expression (or a postdecrement or predecrement expression). 6 // preincrement expression (or a postdecrement or predecrement expression).
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import "conditional_access_helper.dart" as h;
9 10
10 class C { 11 class C {
11 int v; 12 int v;
12 C(this.v); 13 C(this.v);
13 static var staticField; 14 static int staticInt;
14 } 15 }
15 16
16 class D { 17 class D {
17 E v; 18 E v;
18 D(this.v); 19 D(this.v);
20 static E staticE;
19 } 21 }
20 22
21 class E { 23 class E {
22 G operator+(int i) => new I(); 24 G operator+(int i) => new I();
23 G operator-(int i) => new I(); 25 G operator-(int i) => new I();
24 } 26 }
25 27
26 class F {} 28 class F {}
27 29
28 class G extends E implements F {} 30 class G extends E implements F {}
29 31
30 class H {} 32 class H {}
31 33
32 class I extends G implements H {} 34 class I extends G implements H {}
33 35
34 C nullC() => null; 36 C nullC() => null;
35 37
36 main() { 38 main() {
37 // Make sure the "none" test fails if assignment to "?." is not implemented. 39 // Make sure the "none" test fails if assignment to "?." is not implemented.
38 // This makes status files easier to maintain. 40 // This makes status files easier to maintain.
39 nullC()?.v = 1; 41 nullC()?.v = 1;
40 42
41 // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1). 43 // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
42 Expect.equals(null, nullC()?.v++); /// 01: ok 44 Expect.equals(null, nullC()?.v++); /// 01: ok
43 { C c = new C(1); Expect.equals(1, c?.v++); Expect.equals(2, c.v); } /// 02: o k 45 { C c = new C(1); Expect.equals(1, c?.v++); Expect.equals(2, c.v); } /// 02: o k
44 46
47 // C?.v++ is equivalent to C.v++.
48 { C.staticInt = 1; Expect.equals(1, C?.staticInt++); Expect.equals(2, C.static Int); } /// 17: ok
49 { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt++); Expect.equals(2, h.C. staticInt); } /// 18: ok
50
45 // The static type of e1?.v++ is the same as the static type of e1.v. 51 // The static type of e1?.v++ is the same as the static type of e1.v.
46 { E e1 = new E(); D d = new D(e1); E e2 = d?.v++; Expect.identical(e1, e2); } /// 03: ok 52 { E e1 = new E(); D d = new D(e1); E e2 = d?.v++; Expect.identical(e1, e2); } /// 03: ok
47 { G g = new G(); D d = new D(g); F f = d?.v++; Expect.identical(f, g); } /// 0 4: static type warning 53 { G g = new G(); D d = new D(g); F f = d?.v++; Expect.identical(f, g); } /// 0 4: static type warning
54 { E e1 = new E(); D.staticE = e1; E e2 = D?.staticE++; Expect.identical(e1, e2 ); } /// 19: ok
55 { h.E e1 = new h.E(); h.D.staticE = e1; h.E e2 = h.D?.staticE++; Expect.identi cal(e1, e2); } /// 20: ok
56 { G g = new G(); D.staticE = g; F f = D?.staticE++; Expect.identical(f, g); } /// 21: static type warning
57 { h.G g = new h.G(); h.D.staticE = g; h.F f = h.D?.staticE++; Expect.identical (f, g); } /// 22: static type warning
48 58
49 // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1). 59 // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
50 Expect.equals(null, nullC()?.v--); /// 05: ok 60 Expect.equals(null, nullC()?.v--); /// 05: ok
51 { C c = new C(1); Expect.equals(1, c?.v--); Expect.equals(0, c.v); } /// 06: o k 61 { C c = new C(1); Expect.equals(1, c?.v--); Expect.equals(0, c.v); } /// 06: o k
52 62
63 // C?.v-- is equivalent to C.v--.
64 { C.staticInt = 1; Expect.equals(1, C?.staticInt--); Expect.equals(0, C.static Int); } /// 23: ok
65 { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt--); Expect.equals(0, h.C. staticInt); } /// 24: ok
66
53 // The static type of e1?.v-- is the same as the static type of e1.v. 67 // The static type of e1?.v-- is the same as the static type of e1.v.
54 { E e1 = new E(); D d = new D(e1); E e2 = d?.v--; Expect.identical(e1, e2); } /// 07: ok 68 { E e1 = new E(); D d = new D(e1); E e2 = d?.v--; Expect.identical(e1, e2); } /// 07: ok
55 { G g = new G(); D d = new D(g); F f = d?.v--; Expect.identical(f, g); } /// 0 8: static type warning 69 { G g = new G(); D d = new D(g); F f = d?.v--; Expect.identical(f, g); } /// 0 8: static type warning
70 { E e1 = new E(); D.staticE = e1; E e2 = D?.staticE--; Expect.identical(e1, e2 ); } /// 25: ok
71 { h.E e1 = new h.E(); h.D.staticE = e1; h.E e2 = h.D?.staticE--; Expect.identi cal(e1, e2); } /// 26: ok
72 { G g = new G(); D.staticE = g; F f = D?.staticE--; Expect.identical(f, g); } /// 27: static type warning
73 { h.G g = new h.G(); h.D.staticE = g; h.F f = h.D?.staticE--; Expect.identical (f, g); } /// 28: static type warning
56 74
57 // ++e1?.v is equivalent to e1?.v += 1. 75 // ++e1?.v is equivalent to e1?.v += 1.
58 Expect.equals(null, ++nullC()?.v); /// 09: ok 76 Expect.equals(null, ++nullC()?.v); /// 09: ok
59 { C c = new C(1); Expect.equals(2, ++c?.v); Expect.equals(2, c.v); } /// 10: o k 77 { C c = new C(1); Expect.equals(2, ++c?.v); Expect.equals(2, c.v); } /// 10: o k
60 78
79 // ++C?.v is equivalent to C?.v += 1.
80 { C.staticInt = 1; Expect.equals(2, ++C?.staticInt); Expect.equals(2, C.static Int); } /// 29: ok
81 { h.C.staticInt = 1; Expect.equals(2, ++h.C?.staticInt); Expect.equals(2, h.C. staticInt); } /// 30: ok
82
61 // The static type of ++e1?.v is the same as the static type of e1.v + 1. 83 // The static type of ++e1?.v is the same as the static type of e1.v + 1.
62 { D d = new D(new E()); F f = ++d?.v; Expect.identical(d.v, f); } /// 11: ok 84 { D d = new D(new E()); F f = ++d?.v; Expect.identical(d.v, f); } /// 11: ok
63 { D d = new D(new E()); H h = ++d?.v; Expect.identical(d.v, h); } /// 12: stat ic type warning 85 { D d = new D(new E()); H h = ++d?.v; Expect.identical(d.v, h); } /// 12: stat ic type warning
86 { D.staticE = new E(); F f = ++D?.staticE; Expect.identical(D.staticE, f); } / // 31: ok
87 { h.D.staticE = new h.E(); h.F f = ++h.D?.staticE; Expect.identical(h.D.static E, f); } /// 32: ok
88 { D.staticE = new E(); H h = ++D?.staticE; Expect.identical(D.staticE, h); } / // 33: static type warning
89 { h.D.staticE = new h.E(); h.H hh = ++h.D?.staticE; Expect.identical(h.D.stati cE, hh); } /// 34: static type warning
64 90
65 // --e1?.v is equivalent to e1?.v += 1. 91 // --e1?.v is equivalent to e1?.v -= 1.
66 Expect.equals(null, --nullC()?.v); /// 13: ok 92 Expect.equals(null, --nullC()?.v); /// 13: ok
67 { C c = new C(1); Expect.equals(0, --c?.v); Expect.equals(0, c.v); } /// 14: o k 93 { C c = new C(1); Expect.equals(0, --c?.v); Expect.equals(0, c.v); } /// 14: o k
68 94
95 // --C?.v is equivalent to C?.v -= 1.
96 { C.staticInt = 1; Expect.equals(0, --C?.staticInt); Expect.equals(0, C.static Int); } /// 35: ok
97 { h.C.staticInt = 1; Expect.equals(0, --h.C?.staticInt); Expect.equals(0, h.C. staticInt); } /// 36: ok
98
69 // The static type of --e1?.v is the same as the static type of e1.v - 1. 99 // The static type of --e1?.v is the same as the static type of e1.v - 1.
70 { D d = new D(new E()); F f = --d?.v; Expect.identical(d.v, f); } /// 15: ok 100 { D d = new D(new E()); F f = --d?.v; Expect.identical(d.v, f); } /// 15: ok
71 { D d = new D(new E()); H h = --d?.v; Expect.identical(d.v, h); } /// 16: stat ic type warning 101 { D d = new D(new E()); H h = --d?.v; Expect.identical(d.v, h); } /// 16: stat ic type warning
102 { D.staticE = new E(); F f = --D?.staticE; Expect.identical(D.staticE, f); } / // 37: ok
103 { h.D.staticE = new h.E(); h.F f = --h.D?.staticE; Expect.identical(h.D.static E, f); } /// 38: ok
104 { D.staticE = new E(); H h = --D?.staticE; Expect.identical(D.staticE, h); } / // 39: static type warning
105 { h.D.staticE = new h.E(); h.H hh = --h.D?.staticE; Expect.identical(h.D.stati cE, hh); } /// 40: static type warning
72 } 106 }
OLDNEW
« no previous file with comments | « tests/language/conditional_property_assignment_test.dart ('k') | tests/language/if_null_assignment_behavior_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698