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

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

Issue 1239513005: Switch on null-aware operators by default in analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 // Evaluation of an if-null expresion e of the form e1 ?? e2 is equivalent to 5 // Evaluation of an if-null expresion e of the form e1 ?? e2 is equivalent to
6 // the evaluation of the expression ((x) => x == null ? e2 : x)(e1). The 6 // the evaluation of the expression ((x) => x == null ? e2 : x)(e1). The
7 // static type of e is the least upper bound of the static type of e1 and the 7 // static type of e is the least upper bound of the static type of e1 and the
8 // static type of e2. 8 // static type of e2.
9 9
10 // SharedOptions=--enable-null-aware-operators
11
12 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
13 11
14 class A { 12 class A {
15 final String a; 13 final String a;
16 A(this.a); 14 A(this.a);
17 } 15 }
18 16
19 class B extends A { 17 class B extends A {
20 B(String v) : b = v, super(v); 18 B(String v) : b = v, super(v);
21 final String b; 19 final String b;
(...skipping 24 matching lines...) Expand all
46 Expect.equals('B', (new B('B') ?? nullC()).a); /// 08: ok 44 Expect.equals('B', (new B('B') ?? nullC()).a); /// 08: ok
47 Expect.equals('B', (new B('B') ?? nullC()).b); /// 09: static type warning 45 Expect.equals('B', (new B('B') ?? nullC()).b); /// 09: static type warning
48 Expect.throws(() => (new B('B') ?? nullC()).c, noMethod); /// 10: static type warning 46 Expect.throws(() => (new B('B') ?? nullC()).c, noMethod); /// 10: static type warning
49 Expect.equals('C', (nullB() ?? new C('C')).a); /// 11: ok 47 Expect.equals('C', (nullB() ?? new C('C')).a); /// 11: ok
50 Expect.throws(() => (nullB() ?? new C('C')).b, noMethod); /// 12: static type warning 48 Expect.throws(() => (nullB() ?? new C('C')).b, noMethod); /// 12: static type warning
51 Expect.equals('C', (nullB() ?? new C('C')).c); /// 13: static type warning 49 Expect.equals('C', (nullB() ?? new C('C')).c); /// 13: static type warning
52 Expect.throws(() => (nullB() ?? nullC()).a, noMethod); /// 14: ok 50 Expect.throws(() => (nullB() ?? nullC()).a, noMethod); /// 14: ok
53 Expect.throws(() => (nullB() ?? nullC()).b, noMethod); /// 15: static type war ning 51 Expect.throws(() => (nullB() ?? nullC()).b, noMethod); /// 15: static type war ning
54 Expect.throws(() => (nullB() ?? nullC()).c, noMethod); /// 16: static type war ning 52 Expect.throws(() => (nullB() ?? nullC()).c, noMethod); /// 16: static type war ning
55 } 53 }
OLDNEW
« no previous file with comments | « tests/language/if_null_assignment_static_test.dart ('k') | tests/language/if_null_evaluation_order_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698