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

Side by Side Diff: tests/compiler/dart2js_extra/if_null_test.dart

Issue 1151163004: Implementation of null-aware operators. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // SharedOptions=--enable-null-aware-operators
6 import "package:expect/expect.dart";
7
8 @NoInline() @AssumeDynamic()
9 confuse(x) => x;
10
11 main(args) {
12 var x = new A();
13 var y;
14
15 // Checks that inference doesn't incorrectly treat this as a normal
16 // assignment (where only B is a possible value after the assignment).
17 var c = x ??= new B();
18 var z = x;
19 Expect.equals('a', x.m());
20 Expect.equals('a', z.m());
21 Expect.equals('a', c.m());
22 if (confuse(true)) y = x;
23 Expect.equals('a', y.m());
24
25 // Similar test, within fields.
26 new C();
27 new D();
28 }
29
30 class A { m() => 'a'; }
31 class B { m() => 'b'; }
32
33 class C {
34 var y;
35 C() {
36 y = new A();
37 var c = y ??= new B();
38 Expect.equals('a', y.m());
39 Expect.equals('a', c.m());
40 }
41 }
42
43 class D {
44 var y;
45 D() {
46 this.y = new A();
47 var c = this.y ??= new B();
48 Expect.equals('a', y.m());
49 Expect.equals('a', c.m());
50 }
51 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_extra/conditional_send_test.dart ('k') | tests/language/conditional_access_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698