| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Test correct usage of inlined double temporary objects. | 4 // Test correct usage of inlined double temporary objects. |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | |
| 7 | |
| 8 main() { | 6 main() { |
| 9 for (int i = 0; i < 2000; i++) { | 7 for (int i = 0; i < 2000; i++) { |
| 10 testBinaryOp(); | 8 testBinaryOp(); |
| 11 testUnaryOp(); | 9 testUnaryOp(); |
| 12 } | 10 } |
| 13 } | 11 } |
| 14 | 12 |
| 15 | 13 |
| 16 // VM: temporary double should not be used as result of division, | 14 // VM: temporary double should not be used as result of division, |
| 17 // otherwise the function always returns the same object. | 15 // otherwise the function always returns the same object. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 31 double unary(double a, double b) { | 29 double unary(double a, double b) { |
| 32 return -(a * (-b)); | 30 return -(a * (-b)); |
| 33 } | 31 } |
| 34 | 32 |
| 35 | 33 |
| 36 testUnaryOp() { | 34 testUnaryOp() { |
| 37 var x = unary(1.0, 2.0); | 35 var x = unary(1.0, 2.0); |
| 38 var y = unary(3.0, 4.0); | 36 var y = unary(3.0, 4.0); |
| 39 Expect.equals(2.0, x); | 37 Expect.equals(2.0, x); |
| 40 } | 38 } |
| OLD | NEW |