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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intrinsifier_x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, 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 //
5 // Dart test program for testing native int arrays.
6
7 // Library tag to be able to run in html test framework.
8 #library("IntArrayTest.dart");
9
10 #import('dart:scalarlist');
11
12 void testInt32ToSmi() {
13 Int32List intArray;
14
15 intArray = new Int32List(4);
16 intArray[0] = 1073741823; // SmiMax
17 intArray[1] = -1073741824; // SmiMin
18 intArray[2] = 1073741824; // SmiMax+1
19 intArray[3] = -1073741825; // SmiMin-1
20 var x = intArray[0];
21 var y = intArray[1];
22 var z = intArray[2];
23 var w = intArray[3];
24 Expect.equals(1073741823, x);
25 Expect.equals(-1073741824, y);
26 Expect.equals(1073741824, z);
27 Expect.equals(-1073741825, w);
28 }
29
30 void testUint32ToSmi() {
31 Uint32List intArray;
32
33 intArray = new Uint32List(4);
34 intArray[0] = 1073741823; // SmiMax
35 intArray[1] = -1; // 0xFFFFFFFF : 4294967295
36 intArray[2] = 1073741830; // SmiMax+7
37 intArray[3] = -1073741825; // 0xbfffffff : 3221225471
38 var x = intArray[0];
39 var y = intArray[1];
40 var z = intArray[2];
41 var w = intArray[3];
42 Expect.equals(1073741823, x);
43 Expect.equals(4294967295, y);
44 Expect.equals(1073741830, z);
45 Expect.equals(3221225471, w);
46 }
47
48 void testInt64ToSmi() {
49 Int64List intArray;
50
51 intArray = new Int64List(4);
52 intArray[0] = 4611686018427387903; // SmiMax
53 intArray[1] = -4611686018427387904; // SmiMin
54 intArray[2] = 4611686018427387904; // SmiMax+1
55 intArray[3] = -4611686018427387905; // SmiMin-1
56 var x = intArray[0];
57 var y = intArray[1];
58 var z = intArray[2];
59 var w = intArray[3];
60 Expect.equals(4611686018427387903, x);
61 Expect.equals(-4611686018427387904, y);
62 Expect.equals(4611686018427387904, z);
63 Expect.equals(-4611686018427387905, w);
64 }
65
66 void testUint64ToSmi() {
67 Uint64List intArray;
68
69 intArray = new Uint64List(4);
70 intArray[0] = 4611686018427387903; // SmiMax
71 intArray[1] = -1; // 0xFFFFFFFFFFFFFFFF : 18446744073709551615
72 intArray[2] = 4611686018427387904; // SmiMax+1
73 intArray[3] = 9223372036854775808;
74 var x = intArray[0];
75 var y = intArray[1];
76 var z = intArray[2];
77 var w = intArray[3];
78 print(w);
79 Expect.equals(4611686018427387903, x);
80 Expect.equals(18446744073709551615, y);
81 Expect.equals(4611686018427387904, z);
82 Expect.equals(9223372036854775808, w);
83 }
84
85
86 main() {
87 testUint64ToSmi();
88 return;
89 for (int i = 0; i < 2000; i++) {
90 testInt32ToSmi();
91 testUint32ToSmi();
92 testInt64ToSmi();
93 testUint64ToSmi();
94 }
95 }
OLDNEW
« 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