Index: tests/standalone/unboxed_int_converter_test.dart |
diff --git a/tests/standalone/unboxed_int_converter_test.dart b/tests/standalone/unboxed_int_converter_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..784b23e3c3306e317db0aa7e24f89ec126a85fca |
--- /dev/null |
+++ b/tests/standalone/unboxed_int_converter_test.dart |
@@ -0,0 +1,35 @@ |
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+// Test UnboxedIntConverter for int32. |
+ |
+import "package:expect/expect.dart"; |
+import "dart:typed_data"; |
+ |
+int32_to_mint(a, b) { |
+ var sum = 0; |
+ var j = 0; |
+ 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
|
+ sum -= (j * ++j) & 0xff; |
+ } |
+ |
+ return 0xffffffff + sum; |
+} |
+ |
+mint_to_int32(a, c, d) { |
+ return a * a * a * (c - d); |
+} |
+ |
+uint32_to_int32(a, c) { |
+ return (a * a * a) * (c & 0xFFFFFFFF); |
+ |
+} |
+ |
+main() { |
+ for (var j = 0; j < 10000; j++) { |
+ Expect.equals(4294839503, int32_to_mint(0, 1000)); |
+ Expect.equals(-8, mint_to_int32(2, 0x100000000, 0x100000001)); |
+ Expect.equals(8, uint32_to_int32(2, 0x100000001)); |
+ } |
+ Expect.equals(8 * 0x80000001, uint32_to_int32(2, 0x180000001)); |
+} |