| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 division by power of two. | 4 // Test division by power of two. |
| 5 // Test that results before and after optimization are the same. | 5 // Test that results before and after optimization are the same. |
| 6 // VMOptions=--optimization-counter-threshold=10 --no-use-osr |
| 6 | 7 |
| 7 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 8 | 9 |
| 9 // [function, [list of tuples argument/result]]. | 10 // [function, [list of tuples argument/result]]. |
| 10 var expectedResults = | 11 var expectedResults = |
| 11 [ [divBy1, | 12 [ [divBy1, |
| 12 [[134217730, 134217730], | 13 [[134217730, 134217730], |
| 13 [-134217730, -134217730], | 14 [-134217730, -134217730], |
| 14 [10, 10], | 15 [10, 10], |
| 15 [-10, -10]]], | 16 [-10, -10]]], |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 divByNeg4(a) => a ~/ -4; | 81 divByNeg4(a) => a ~/ -4; |
| 81 divBy134217728(a) => a ~/ 134217728; | 82 divBy134217728(a) => a ~/ 134217728; |
| 82 divByNeg134217728(a) => a ~/ -134217728; | 83 divByNeg134217728(a) => a ~/ -134217728; |
| 83 | 84 |
| 84 divBy4_(a) => a ~/ 4; | 85 divBy4_(a) => a ~/ 4; |
| 85 divByNeg4_(a) => a ~/ -4; | 86 divByNeg4_(a) => a ~/ -4; |
| 86 divBy549755813888(a) => a ~/ 549755813888; | 87 divBy549755813888(a) => a ~/ 549755813888; |
| 87 divByNeg549755813888(a) => a ~/ -549755813888; | 88 divByNeg549755813888(a) => a ~/ -549755813888; |
| 88 | 89 |
| 89 main() { | 90 main() { |
| 90 for (int i = 0; i < 8000; i++) { | 91 for (int i = 0; i < 20; i++) { |
| 91 for (var e in expectedResults) { | 92 for (var e in expectedResults) { |
| 92 Function f = e[0]; | 93 Function f = e[0]; |
| 93 List values = e[1]; | 94 List values = e[1]; |
| 94 for (var v in values) { | 95 for (var v in values) { |
| 95 int arg = v[0]; | 96 int arg = v[0]; |
| 96 int res = v[1]; | 97 int res = v[1]; |
| 97 Expect.equals(res, f(arg)); | 98 Expect.equals(res, f(arg)); |
| 98 } | 99 } |
| 99 } | 100 } |
| 100 try { | 101 try { |
| 101 divBy0(4); | 102 divBy0(4); |
| 102 Expect.fail("Should have thrown exception."); | 103 Expect.fail("Should have thrown exception."); |
| 103 } on IntegerDivisionByZeroException catch (e) {} | 104 } on IntegerDivisionByZeroException catch (e) {} |
| 104 } | 105 } |
| 105 } | 106 } |
| OLD | NEW |