OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, 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 // Test constant folding on numbers. |
| 5 |
| 6 import "package:expect/expect.dart"; |
| 7 import 'compiler_helper.dart'; |
| 8 |
| 9 const String CODE = """ |
| 10 class A { |
| 11 var link; |
| 12 } |
| 13 int foo(x) { |
| 14 if (new DateTime.now().millisecondsSinceEpoch == 42) return null; |
| 15 var a = new A(); |
| 16 if (new DateTime.now().millisecondsSinceEpoch == 42) return a; |
| 17 a.link = a; |
| 18 return a; |
| 19 } |
| 20 void main() { |
| 21 var x = foo(0); |
| 22 return x == x.link; |
| 23 } |
| 24 """; |
| 25 |
| 26 main() { |
| 27 // The `==` is strengthened to a HIdentity instruction. The HIdentity follows |
| 28 // `x.link`, so x cannot be `null`. |
| 29 var compare = new RegExp(r'x === x\.get\$link\(\)'); |
| 30 compileAndMatch(CODE, 'main', compare); |
| 31 } |
OLD | NEW |