Chromium Code Reviews| 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 // Test UnboxedIntConverter for int32. | |
| 5 | |
| 6 import "package:expect/expect.dart"; | |
| 7 import "dart:typed_data"; | |
| 8 | |
| 9 int32_to_mint(a, b) { | |
| 10 var sum = 0; | |
| 11 var j = 0; | |
| 12 for (var i = a; i <= b; i++) { | |
|
Florian Schneider
2014/08/27 09:36:51
This test does not seem to cover all int32 operati
Vyacheslav Egorov (Google)
2014/08/27 11:45:37
both `sum` and `j` are int32 phis here.
I will a
| |
| 13 sum -= (j * ++j) & 0xff; | |
| 14 } | |
| 15 | |
| 16 return 0xffffffff + sum; | |
| 17 } | |
| 18 | |
| 19 mint_to_int32(a, c, d) { | |
| 20 return a * a * a * (c - d); | |
| 21 } | |
| 22 | |
| 23 uint32_to_int32(a, c) { | |
| 24 return (a * a * a) * (c & 0xFFFFFFFF); | |
| 25 | |
| 26 } | |
| 27 | |
| 28 main() { | |
| 29 for (var j = 0; j < 10000; j++) { | |
| 30 Expect.equals(4294839503, int32_to_mint(0, 1000)); | |
| 31 Expect.equals(-8, mint_to_int32(2, 0x100000000, 0x100000001)); | |
| 32 Expect.equals(8, uint32_to_int32(2, 0x100000001)); | |
| 33 } | |
| 34 Expect.equals(8 * 0x80000001, uint32_to_int32(2, 0x180000001)); | |
| 35 } | |
| OLD | NEW |