| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // Testing optimized 'is' tests. | 4 // Testing optimized 'is' tests. |
| 5 // VMOptions=--optimization-counter-threshold=5 --no-use-osr | 5 // VMOptions=--optimization-counter-threshold=5 --no-use-osr |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 | 9 |
| 10 bool isInt(x) => x is int; | 10 bool isInt(x) => x is int; |
| 11 | 11 |
| 12 | 12 |
| 13 bool isIntRes(x) { | 13 int isIntRes(x) { |
| 14 if (x is int) { | 14 if (x is int) { |
| 15 return 1; | 15 return 1; |
| 16 } else { | 16 } else { |
| 17 return 0; | 17 return 0; |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 | 21 |
| 22 bool isNotIntRes(x) { | 22 int isNotIntRes(x) { |
| 23 if (x is! int) { | 23 if (x is! int) { |
| 24 return 1; | 24 return 1; |
| 25 } else { | 25 } else { |
| 26 return 0; | 26 return 0; |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 | 30 |
| 31 bool isIfThenElseIntRes(x) { | 31 int isIfThenElseIntRes(x) { |
| 32 return x is int ? 1 : 0; | 32 return x is int ? 1 : 0; |
| 33 } | 33 } |
| 34 | 34 |
| 35 | 35 |
| 36 | 36 |
| 37 bool isString(x) => x is String; | 37 bool isString(x) => x is String; |
| 38 | 38 |
| 39 | 39 |
| 40 bool isStringRes(x) { | 40 int isStringRes(x) { |
| 41 if (x is String) { | 41 if (x is String) { |
| 42 return 1; | 42 return 1; |
| 43 } else { | 43 } else { |
| 44 return 0; | 44 return 0; |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| 49 bool isNotStringRes(x) { | 49 int isNotStringRes(x) { |
| 50 if (x is! String) { | 50 if (x is! String) { |
| 51 return 1; | 51 return 1; |
| 52 } else { | 52 } else { |
| 53 return 0; | 53 return 0; |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 main() { | 58 main() { |
| 59 for (int i = 0; i < 20; i++) { | 59 for (int i = 0; i < 20; i++) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 for (int i = 0; i < 20; i++) { | 101 for (int i = 0; i < 20; i++) { |
| 102 Expect.equals(0, isStringRes(3.2)); | 102 Expect.equals(0, isStringRes(3.2)); |
| 103 Expect.equals(1, isStringRes("Lotus")); | 103 Expect.equals(1, isStringRes("Lotus")); |
| 104 Expect.equals(0, isStringRes(null)); | 104 Expect.equals(0, isStringRes(null)); |
| 105 | 105 |
| 106 Expect.equals(1, isNotStringRes(3.2)); | 106 Expect.equals(1, isNotStringRes(3.2)); |
| 107 Expect.equals(0, isNotStringRes("Lotus")); | 107 Expect.equals(0, isNotStringRes("Lotus")); |
| 108 Expect.equals(1, isNotStringRes(null)); | 108 Expect.equals(1, isNotStringRes(null)); |
| 109 } | 109 } |
| 110 } | 110 } |
| OLD | NEW |