| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, 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 // Interpolation effect analysis test. |
| 8 |
| 9 get never => new DateTime.now().millisecondsSinceEpoch == 0; |
| 10 |
| 11 class A { |
| 12 int a = 0; |
| 13 toString() { ++a; return 'A'; } |
| 14 } |
| 15 |
| 16 // Many interpolations to make function too big to inline. |
| 17 // Summary for [fmt] must include effects from toString(). |
| 18 fmt(x) => '$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x$x'; |
| 19 |
| 20 test(a) { |
| 21 if (a == null) return; |
| 22 if (never) a.a += 1; |
| 23 var b = a.a; // field load |
| 24 var c = fmt(a); // field modified through implicit call to toString() |
| 25 var d = a.a; // field re-load |
| 26 Expect.equals('A 0 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 30', '$a $b $c $d'); |
| 27 |
| 28 // Extra use of [fmt] to prevent inlining on basis of single reference. |
| 29 Expect.equals('', fmt('')); |
| 30 } |
| 31 |
| 32 main() { |
| 33 test(null); |
| 34 test(new A()); |
| 35 } |
| OLD | NEW |