Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(962)

Unified Diff: tests/standalone/unboxed_int_converter_test.dart

Issue 504143003: Support Int32 representation for selected binary operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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));
+}
« runtime/vm/intermediate_language_ia32.cc ('K') | « tests/standalone/standalone.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698