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

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 import "package:expect/expect.dart";
6
7 @NoInline() @AssumeDynamic()
8 confuse(x) => x;
9
10 main(args) {
11 var x = new A();
12 var y;
13
14 // Checks that inference doesn't incorrectly treat this as a normal
15 // assignment (where only B is a possible value after the assignment).
16 var c = x ??= new B();
17 var z = x;
18 Expect.equals('a', x.m());
19 Expect.equals('a', z.m());
20 Expect.equals('a', c.m());
21 if (confuse(true)) y = x;
22 Expect.equals('a', y.m());
23
24 // Similar test, within fields.
25 new C();
26 new D();
27 }
28
29 class A { m() => 'a'; }
30 class B { m() => 'b'; }
31
32 class C {
33 var y;
34 C() {
35 y = new A();
36 var c = y ??= new B();
37 Expect.equals('a', y.m());
38 Expect.equals('a', c.m());
39 }
40 }
41
42 class D {
43 var y;
44 D() {
45 this.y = new A();
46 var c = this.y ??= new B();
47 Expect.equals('a', y.m());
48 Expect.equals('a', c.m());
49 }
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698