| 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 | 4 |
| 5 // VMOptions=--warn_on_javascript_compatibility --warning_as_error --optimizatio
n_counter_threshold=5 | 5 // VMOptions=--warn_on_javascript_compatibility --warning_as_error --optimizatio
n_counter_threshold=5 |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 f(x, y) { | 9 f(x, y) { |
| 10 // Unoptimized and optimized code. | 10 // Unoptimized and optimized code. |
| 11 1 is double; /// 00: compile-time error | 11 1 is double; /// 00: ok |
| 12 if (1 is double) { x++; } /// 01: compile-time error | 12 if (1 is double) { x++; } /// 01: ok |
| 13 try { 1 as double; } on CastError catch (e) { } /// 02: compile-time error | 13 try { 1 as double; } on CastError catch (e) { } /// 02: ok |
| 14 try { var y = 1 as double; } on CastError catch (e) { } /// 03: compile-time
error | 14 try { var y = 1 as double; } on CastError catch (e) { } /// 03: ok |
| 15 1.0 is int; /// 04: compile-time error | 15 1.0 is int; /// 04: ok |
| 16 if (1.0 is int) { x++; } /// 05: compile-time error | 16 if (1.0 is int) { x++; } /// 05: ok |
| 17 try { 1.0 as int; } on CastError catch (e) { } /// 06: compile-time error | 17 try { 1.0 as int; } on CastError catch (e) { } /// 06: ok |
| 18 try { var z = 1.0 as int; } on CastError catch (e) { } /// 07: compile-time e
rror | 18 try { var z = 1.0 as int; } on CastError catch (e) { } /// 07: ok |
| 19 | 19 |
| 20 x is double; /// 10: ok | 20 x is double; /// 10: ok |
| 21 if (x is double) { } /// 11: ok | 21 if (x is double) { } /// 11: ok |
| 22 try { x as double; } on CastError catch (e) { } /// 12: ok | 22 try { x as double; } on CastError catch (e) { } /// 12: ok |
| 23 try { var z = x as double; } on CastError catch (e) { } /// 13: ok | 23 try { var z = x as double; } on CastError catch (e) { } /// 13: ok |
| 24 y is int; /// 14: ok | 24 y is int; /// 14: ok |
| 25 if (y is int) { } /// 15: ok | 25 if (y is int) { } /// 15: ok |
| 26 try { y as int; } on CastError catch (e) { } /// 16: ok | 26 try { y as int; } on CastError catch (e) { } /// 16: ok |
| 27 try { var z = y as int; } on CastError catch (e) { } /// 17: ok | 27 try { var z = y as int; } on CastError catch (e) { } /// 17: ok |
| 28 | 28 |
| 29 // It is a compile-time error if evaluation of a constant object results in |
| 30 // an uncaught exception being thrown, a JavascriptCompatibilityError here. |
| 29 "${1.0}"; /// 20: compile-time error | 31 "${1.0}"; /// 20: compile-time error |
| 30 var z = "${1.0}"; /// 21: compile-time error | 32 var z = "${1.0}"; /// 21: compile-time error |
| 33 |
| 31 (1.0).toString(); /// 22: ok | 34 (1.0).toString(); /// 22: ok |
| 32 var z = (1.0).toString(); /// 23: ok | 35 var z = (1.0).toString(); /// 23: ok |
| 33 "$y"; /// 24: ok | 36 "$y"; /// 24: ok |
| 34 var z = "$y"; /// 25: ok | 37 var z = "$y"; /// 25: ok |
| 35 y.toString(); /// 26: ok | 38 y.toString(); /// 26: ok |
| 36 var z = y.toString(); /// 27: ok | 39 var z = y.toString(); /// 27: ok |
| 37 | 40 |
| 38 var a = "yz"; | 41 var a = "yz"; |
| 39 var b = "xyz"; | 42 var b = "xyz"; |
| 40 b = b.substring(1); | 43 b = b.substring(1); |
| 41 if (identical(a, b)) { } /// 28: ok | 44 if (identical(a, b)) { } /// 28: ok |
| 42 | 45 |
| 43 if (identical(x, y)) { } /// 29: ok | 46 if (identical(x, y)) { } /// 29: ok |
| 44 if (identical(y, x)) { } /// 30: ok | 47 if (identical(y, x)) { } /// 30: ok |
| 45 | 48 |
| 46 if (x > 10) { | 49 if (x > 10) { |
| 47 // Optimized code. | 50 // Optimized code. |
| 48 x is double; /// 40: ok | 51 x is double; /// 40: ok |
| 49 if (x is double) { } /// 41: ok | 52 if (x is double) { } /// 41: ok |
| 50 try { x as double; } on CastError catch (e) { } /// 42: ok | 53 try { x as double; } on CastError catch (e) { } /// 42: ok |
| 51 try { var z = x as double; } on CastError catch (e) { } /// 43: ok | 54 try { var z = x as double; } on CastError catch (e) { } /// 43: ok |
| 52 y is int; /// 44: ok | 55 y is int; /// 44: ok |
| 53 if (y is int) { } /// 45: ok | 56 if (y is int) { } /// 45: ok |
| 54 try { y as int; } on CastError catch (e) { } /// 46: ok | 57 try { y as int; } on CastError catch (e) { } /// 46: ok |
| 55 try { var z = y as int; } on CastError catch (e) { } /// 47: ok | 58 try { var z = y as int; } on CastError catch (e) { } /// 47: ok |
| 56 | 59 |
| 57 "${1.0}"; /// 50: compile-time error | 60 "${1.0}"; /// 50: compile-time error |
| 58 var z = "${1.0}"; /// 51: compile-time error | 61 var z = "${1.0}"; /// 51: compile-time error |
| 62 |
| 59 (1.0).toString(); /// 52: ok | 63 (1.0).toString(); /// 52: ok |
| 60 var z = (1.0).toString(); /// 53: ok | 64 var z = (1.0).toString(); /// 53: ok |
| 61 "$y"; /// 54: ok | 65 "$y"; /// 54: ok |
| 62 var z = "$y"; /// 55: ok | 66 var z = "$y"; /// 55: ok |
| 63 y.toString(); /// 56: ok | 67 y.toString(); /// 56: ok |
| 64 var z = y.toString(); /// 57: ok | 68 var z = y.toString(); /// 57: ok |
| 65 | 69 |
| 66 var a = "yz"; | 70 var a = "yz"; |
| 67 var b = "xyz"; | 71 var b = "xyz"; |
| 68 b = b.substring(1); | 72 b = b.substring(1); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 174 } |
| 171 } | 175 } |
| 172 Expect.equals(1, numWarnings); | 176 Expect.equals(1, numWarnings); |
| 173 // No warnings (errors) should be issued after this point. | 177 // No warnings (errors) should be issued after this point. |
| 174 for (var i = 0; i < 20; i++) { | 178 for (var i = 0; i < 20; i++) { |
| 175 k(i * 1.0, i); | 179 k(i * 1.0, i); |
| 176 k(i * 1.0, i + 0.5); | 180 k(i * 1.0, i + 0.5); |
| 177 } | 181 } |
| 178 } | 182 } |
| 179 | 183 |
| OLD | NEW |