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 |
| 5 import 'package:expect/expect.dart'; |
| 6 |
| 7 bool nonInlinedNumTypeCheck(Object object) { |
| 8 if (new DateTime.now().millisecondsSinceEpoch == 42) { |
| 9 return nonInlinedNumTypeCheck(object); |
| 10 } |
| 11 return object is num; |
| 12 } |
| 13 |
| 14 bool nonInlinedStringTypeCheck(Object object) { |
| 15 if (new DateTime.now().millisecondsSinceEpoch == 42) { |
| 16 return nonInlinedStringTypeCheck(object); |
| 17 } |
| 18 return object is String; |
| 19 } |
| 20 |
| 21 int confuse(x) { |
| 22 if (new DateTime.now().millisecondsSinceEpoch == 42) return confuse(x - 1); |
| 23 return x; |
| 24 } |
| 25 |
| 26 main() { |
| 27 var o = [ "foo", 499 ][confuse(0)]; |
| 28 |
| 29 // The is-checks in the '!' must not be propagated to the if-body, but |
| 30 // the second is-check should. |
| 31 if (!(o is num) && o is String) { |
| 32 Expect.isFalse((nonInlinedNumTypeCheck(o))); |
| 33 Expect.isTrue((nonInlinedStringTypeCheck(o))); |
| 34 } |
| 35 } |
OLD | NEW |