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

Unified Diff: tests/standalone/int_array_test.dart

Issue 11139004: Intrinsify natural word size typed array getters on IA32 and X64 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Codereview Created 8 years, 2 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
« no previous file with comments | « runtime/vm/intrinsifier_x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/int_array_test.dart
diff --git a/tests/standalone/int_array_test.dart b/tests/standalone/int_array_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..dfab86e6e39759ccb8449dfbb41117acdab19e39
--- /dev/null
+++ b/tests/standalone/int_array_test.dart
@@ -0,0 +1,95 @@
+// Copyright (c) 2012, 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.
+//
+// Dart test program for testing native int arrays.
+
+// Library tag to be able to run in html test framework.
+#library("IntArrayTest.dart");
+
+#import('dart:scalarlist');
+
+void testInt32ToSmi() {
+ Int32List intArray;
+
+ intArray = new Int32List(4);
+ intArray[0] = 1073741823; // SmiMax
+ intArray[1] = -1073741824; // SmiMin
+ intArray[2] = 1073741824; // SmiMax+1
+ intArray[3] = -1073741825; // SmiMin-1
+ var x = intArray[0];
+ var y = intArray[1];
+ var z = intArray[2];
+ var w = intArray[3];
+ Expect.equals(1073741823, x);
+ Expect.equals(-1073741824, y);
+ Expect.equals(1073741824, z);
+ Expect.equals(-1073741825, w);
+}
+
+void testUint32ToSmi() {
+ Uint32List intArray;
+
+ intArray = new Uint32List(4);
+ intArray[0] = 1073741823; // SmiMax
+ intArray[1] = -1; // 0xFFFFFFFF : 4294967295
+ intArray[2] = 1073741830; // SmiMax+7
+ intArray[3] = -1073741825; // 0xbfffffff : 3221225471
+ var x = intArray[0];
+ var y = intArray[1];
+ var z = intArray[2];
+ var w = intArray[3];
+ Expect.equals(1073741823, x);
+ Expect.equals(4294967295, y);
+ Expect.equals(1073741830, z);
+ Expect.equals(3221225471, w);
+}
+
+void testInt64ToSmi() {
+ Int64List intArray;
+
+ intArray = new Int64List(4);
+ intArray[0] = 4611686018427387903; // SmiMax
+ intArray[1] = -4611686018427387904; // SmiMin
+ intArray[2] = 4611686018427387904; // SmiMax+1
+ intArray[3] = -4611686018427387905; // SmiMin-1
+ var x = intArray[0];
+ var y = intArray[1];
+ var z = intArray[2];
+ var w = intArray[3];
+ Expect.equals(4611686018427387903, x);
+ Expect.equals(-4611686018427387904, y);
+ Expect.equals(4611686018427387904, z);
+ Expect.equals(-4611686018427387905, w);
+}
+
+void testUint64ToSmi() {
+ Uint64List intArray;
+
+ intArray = new Uint64List(4);
+ intArray[0] = 4611686018427387903; // SmiMax
+ intArray[1] = -1; // 0xFFFFFFFFFFFFFFFF : 18446744073709551615
+ intArray[2] = 4611686018427387904; // SmiMax+1
+ intArray[3] = 9223372036854775808;
+ var x = intArray[0];
+ var y = intArray[1];
+ var z = intArray[2];
+ var w = intArray[3];
+ print(w);
+ Expect.equals(4611686018427387903, x);
+ Expect.equals(18446744073709551615, y);
+ Expect.equals(4611686018427387904, z);
+ Expect.equals(9223372036854775808, w);
+}
+
+
+main() {
+ testUint64ToSmi();
+ return;
+ for (int i = 0; i < 2000; i++) {
+ testInt32ToSmi();
+ testUint32ToSmi();
+ testInt64ToSmi();
+ testUint64ToSmi();
+ }
+}
« no previous file with comments | « runtime/vm/intrinsifier_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698