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

Side by Side Diff: tests/standalone/byte_array_test.dart

Issue 11074016: Intrinsify writing to Uint8 and Int8 arrays on IA32. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments, fixed signed check, and tests. 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // Dart test program for testing native byte arrays. 5 // Dart test program for testing native byte arrays.
6 6
7 // Library tag to be able to run in html test framework. 7 // Library tag to be able to run in html test framework.
8 #library("ByteArrayTest.dart"); 8 #library("ByteArrayTest.dart");
9 9
10 #import('dart:scalarlist'); 10 #import('dart:scalarlist');
11 11
12 void testCreateByteArray() { 12 void testCreateByteArray() {
13 Uint8List byteArray; 13 Uint8List byteArray;
14 14
15 byteArray = new Uint8List(0); 15 byteArray = new Uint8List(0);
16 Expect.equals(0, byteArray.length); 16 Expect.equals(0, byteArray.length);
17 17
18 byteArray = new Uint8List(10); 18 byteArray = new Uint8List(10);
19 Expect.equals(10, byteArray.length); 19 Expect.equals(10, byteArray.length);
20 for (int i = 0; i < 10; i++) { 20 for (int i = 0; i < 10; i++) {
21 Expect.equals(0, byteArray[i]); 21 Expect.equals(0, byteArray[i]);
22 } 22 }
23
24 }
25
26 void testUnsignedByteArrayRange() {
27 Uint8List byteArray;
28 byteArray = new Uint8List(10);
29
30 byteArray[1] = 255;
31 Expect.equals(255, byteArray[1]);
32 byteArray[1] = 0;
33 Expect.equals(0, byteArray[1]);
34
35 // These should eventually throw.
srdjan 2012/10/16 17:56:01 Don't they throw? You can use Expect.throws(...) t
36 byteArray[1] = 256;
37 byteArray[1] = -1;
38 byteArray[2] = -129;
39 }
40
41 void testByteArrayRange() {
42 Int8List byteArray;
43 byteArray = new Int8List(10);
44 byteArray[1] = 0;
45 Expect.equals(0, byteArray[1]);
46 byteArray[2] = -128;
47 Expect.equals(-128, byteArray[2]);
48 byteArray[3] = 127;
49 Expect.equals(127, byteArray[3]);
50 // This should eventually throw.
srdjan 2012/10/16 17:56:01 ditto
51 byteArray[0] = 128;
52 byteArray[4] = -129;
23 } 53 }
24 54
25 void testSetRange() { 55 void testSetRange() {
26 Uint8List byteArray = new Uint8List(3); 56 Uint8List byteArray = new Uint8List(3);
27 57
28 List<int> list = [10, 11, 12]; 58 List<int> list = [10, 11, 12];
29 byteArray.setRange(0, 3, list); 59 byteArray.setRange(0, 3, list);
30 for (int i = 0; i < 3; i++) { 60 for (int i = 0; i < 3; i++) {
31 Expect.equals(10 + i, byteArray[i]); 61 Expect.equals(10 + i, byteArray[i]);
32 } 62 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 104 }
75 Expect.equals(0, list.indexOf(10.0)); 105 Expect.equals(0, list.indexOf(10.0));
76 Expect.equals(5, list.indexOf(15.0)); 106 Expect.equals(5, list.indexOf(15.0));
77 Expect.equals(9, list.indexOf(19.0)); 107 Expect.equals(9, list.indexOf(19.0));
78 Expect.equals(-1, list.indexOf(20.0)); 108 Expect.equals(-1, list.indexOf(20.0));
79 } 109 }
80 110
81 main() { 111 main() {
82 for (int i = 0; i < 2000; i++) { 112 for (int i = 0; i < 2000; i++) {
83 testCreateByteArray(); 113 testCreateByteArray();
114 testByteArrayRange();
115 testUnsignedByteArrayRange();
84 testSetRange(); 116 testSetRange();
85 testIndexOutOfRange(); 117 testIndexOutOfRange();
86 testIndexOf(); 118 testIndexOf();
87 } 119 }
88 } 120 }
OLDNEW
« runtime/vm/intrinsifier_ia32.cc ('K') | « runtime/vm/intrinsifier_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698