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 // VMOptions=--warn_on_javascript_compatibility --no_warning_as_error --optimiza
tion_counter_threshold=5 | |
6 | |
7 import "package:expect/expect.dart"; | |
8 | |
9 f(x, y) { | |
10 // Unoptimized and optimized code. | |
11 1 is double; /// 00: ok | |
12 if (1 is double) { x++; } /// 01: ok | |
13 try { 1 as double; } on CastError catch (e) { } /// 02: ok | |
14 try { var y = 1 as double; } on CastError catch (e) { } /// 03: ok | |
15 1.0 is int; /// 04: ok | |
16 if (1.0 is int) { x++; } /// 05: ok | |
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: ok | |
19 | |
20 x is double; /// 10: ok | |
21 if (x is double) { } /// 11: 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 | |
24 y is int; /// 14: ok | |
25 if (y is int) { } /// 15: 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 | |
28 | |
29 "${1.0}"; /// 20: ok | |
30 var z = "${1.0}"; /// 21: ok | |
31 (1.0).toString(); /// 22: ok | |
32 var z = (1.0).toString(); /// 23: ok | |
33 "$y"; /// 24: ok | |
34 var z = "$y"; /// 25: ok | |
35 y.toString(); /// 26: ok | |
36 var z = y.toString(); /// 27: ok | |
37 | |
38 var a = "yz"; | |
39 var b = "xyz"; | |
40 b = b.substring(1); | |
41 if (identical(a, b)) { } /// 28: ok | |
42 | |
43 if (identical(x, y)) { } /// 29: ok | |
44 if (identical(y, x)) { } /// 30: ok | |
45 | |
46 if (x > 10) { | |
47 // Optimized code. | |
48 x is double; /// 40: ok | |
49 if (x is double) { } /// 41: ok | |
50 try { x as double; } on CastError catch (e) { } /// 42: ok | |
51 try { var z = x as double; } on CastError catch (e) { } /// 43: ok | |
52 y is int; /// 44: ok | |
53 if (y is int) { } /// 45: ok | |
54 try { y as int; } on CastError catch (e) { } /// 46: ok | |
55 try { var z = y as int; } on CastError catch (e) { } /// 47: ok | |
56 | |
57 "${1.0}"; /// 50: ok | |
58 var z = "${1.0}"; /// 51: ok | |
59 (1.0).toString(); /// 52: ok | |
60 var z = (1.0).toString(); /// 53: ok | |
61 "$y"; /// 54: ok | |
62 var z = "$y"; /// 55: ok | |
63 y.toString(); /// 56: ok | |
64 var z = y.toString(); /// 57: ok | |
65 | |
66 var a = "yz"; | |
67 var b = "xyz"; | |
68 b = b.substring(1); | |
69 if (identical(a, b)) { } /// 58: ok | |
70 | |
71 if (identical(x, y)) { } /// 59: ok | |
72 if (identical(y, x)) { } /// 60: ok | |
73 } | |
74 } | |
75 | |
76 g(x, y) => f(x, y); // Test inlining calls. | |
77 h(x, y) => g(x, y); | |
78 | |
79 main() { | |
80 for (var i = 0; i < 20; i++) { | |
81 h(i, i* 1.0); | |
82 } | |
83 } | |
84 | |
OLD | NEW |