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

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

Issue 11794038: Bug fix and improvements to clamped arrays. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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
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; 8 library ByteArrayTest;
9 9
10 import 'dart:scalarlist'; 10 import 'dart:scalarlist';
(...skipping 30 matching lines...) Expand all
41 41
42 void testUnsignedByteArrayRange(bool check_throws) { 42 void testUnsignedByteArrayRange(bool check_throws) {
43 Uint8List byteArray; 43 Uint8List byteArray;
44 byteArray = new Uint8List(10); 44 byteArray = new Uint8List(10);
45 45
46 byteArray[1] = 255; 46 byteArray[1] = 255;
47 Expect.equals(255, byteArray[1]); 47 Expect.equals(255, byteArray[1]);
48 byteArray[1] = 0; 48 byteArray[1] = 0;
49 Expect.equals(0, byteArray[1]); 49 Expect.equals(0, byteArray[1]);
50 50
51 for (int i = 0; i < byteArray.length; i++) {
52 byteArray[i] = i;
53 }
54 for (int i = 0; i < byteArray.length; i++) {
55 Expect.equals(i, byteArray[i]);
56 }
57
51 // These should eventually throw. 58 // These should eventually throw.
52 byteArray[1] = 256; 59 byteArray[1] = 256;
53 byteArray[1] = -1; 60 byteArray[1] = -1;
54 byteArray[2] = -129; 61 byteArray[2] = -129;
55 if (check_throws) { 62 if (check_throws) {
56 Expect.throws(() { 63 Expect.throws(() {
57 byteArray[1] = 1.2; 64 byteArray[1] = 1.2;
58 }); 65 });
59 } 66 }
60 } 67 }
61 68
62 void testClampedUnsignedByteArrayRange(bool check_throws) { 69 void testClampedUnsignedByteArrayRange(bool check_throws) {
63 Uint8ClampedList byteArray; 70 Uint8ClampedList byteArray;
64 byteArray = new Uint8ClampedList(10); 71 byteArray = new Uint8ClampedList(10);
65 72
66 byteArray[1] = 255; 73 byteArray[1] = 255;
67 Expect.equals(255, byteArray[1]); 74 Expect.equals(255, byteArray[1]);
68 byteArray[1] = 0; 75 byteArray[1] = 0;
69 Expect.equals(0, byteArray[1]); 76 Expect.equals(0, byteArray[1]);
77 for (int i = 0; i < byteArray.length; i++) {
78 byteArray[i] = i;
79 }
80 for (int i = 0; i < byteArray.length; i++) {
81 Expect.equals(i, byteArray[i]);
82 }
70 83
71 // These should eventually throw. 84 // These should eventually throw.
72 byteArray[1] = 256; 85 byteArray[1] = 256;
73 byteArray[2] = -129; 86 byteArray[2] = -129;
74 Expect.equals(255, byteArray[1]); 87 Expect.equals(255, byteArray[1]);
75 Expect.equals(0, byteArray[2]); 88 Expect.equals(0, byteArray[2]);
76 } 89 }
77 90
78 void testByteArrayRange(bool check_throws) { 91 void testByteArrayRange(bool check_throws) {
79 Int8List byteArray; 92 Int8List byteArray;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 testClampedUnsignedByteArrayRange(false); 231 testClampedUnsignedByteArrayRange(false);
219 testSetRange(); 232 testSetRange();
220 testIndexOutOfRange(); 233 testIndexOutOfRange();
221 testIndexOf(); 234 testIndexOf();
222 testSubArray(); 235 testSubArray();
223 } 236 }
224 testByteArrayRange(true); 237 testByteArrayRange(true);
225 testUnsignedByteArrayRange(true); 238 testUnsignedByteArrayRange(true);
226 } 239 }
227 240
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