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

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

Issue 13860006: Fix static type errors in a number of tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « sdk/lib/io/http.dart ('k') | tests/standalone/io/echo_server_stream_test.dart » ('j') | 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 float arrays. 5 // Dart test program for testing native float 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 FloatArrayTest; 8 library FloatArrayTest;
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import 'dart:typed_data'; 11 import 'dart:typed_data';
12 12
13 void testCreateFloat32Array() { 13 void testCreateFloat32Array() {
14 Float32List floatArray; 14 Float32List floatArray;
15 15
16 floatArray = new Float32List(0); 16 floatArray = new Float32List(0);
17 Expect.equals(0, floatArray.length); 17 Expect.equals(0, floatArray.length);
18 18
19 floatArray = new Float32List(10); 19 floatArray = new Float32List(10);
20 Expect.equals(10, floatArray.length); 20 Expect.equals(10, floatArray.length);
21 for (int i = 0; i < 10; i++) { 21 for (int i = 0; i < 10; i++) {
22 Expect.equals(0.0, floatArray[i]); 22 Expect.equals(0.0, floatArray[i]);
23 } 23 }
24 } 24 }
25 25
26 void testSetRange32() { 26 void testSetRange32() {
27 Float32List floatArray = new Float32List(3); 27 Float32List floatArray = new Float32List(3);
28 28
29 List<num> list = [10.0, 11.0, 12.0]; 29 List<double> list = [10.0, 11.0, 12.0];
30 floatArray.setRange(0, 3, list); 30 floatArray.setRange(0, 3, list);
31 for (int i = 0; i < 3; i++) { 31 for (int i = 0; i < 3; i++) {
32 Expect.equals(10 + i, floatArray[i]); 32 Expect.equals(10 + i, floatArray[i]);
33 } 33 }
34 34
35 floatArray[0] = 20.0; 35 floatArray[0] = 20.0;
36 floatArray[1] = 21.0; 36 floatArray[1] = 21.0;
37 floatArray[2] = 22.0; 37 floatArray[2] = 22.0;
38 list.setRange(0, 3, floatArray); 38 list.setRange(0, 3, floatArray);
39 for (int i = 0; i < 3; i++) { 39 for (int i = 0; i < 3; i++) {
40 Expect.equals(20 + i, list[i]); 40 Expect.equals(20 + i, list[i]);
41 } 41 }
42 42
43 // 4.0e40 is larger than the largest representable float. 43 // 4.0e40 is larger than the largest representable float.
44 floatArray.setRange(1, 3, const [8.0, 4.0e40]); 44 floatArray.setRange(1, 3, const [8.0, 4.0e40]);
45 Expect.equals(20, floatArray[0]); 45 Expect.equals(20, floatArray[0]);
46 Expect.equals(8, floatArray[1]); 46 Expect.equals(8, floatArray[1]);
47 Expect.equals(double.INFINITY, floatArray[2]); 47 Expect.equals(double.INFINITY, floatArray[2]);
48 } 48 }
49 49
50 void testIndexOutOfRange32() { 50 void testIndexOutOfRange32() {
51 Float32List floatArray = new Float32List(3); 51 Float32List floatArray = new Float32List(3);
52 List<num> list = const [0.0, 1.0, 2.0, 3.0]; 52 List<double> list = const [0.0, 1.0, 2.0, 3.0];
53 53
54 Expect.throws(() { 54 Expect.throws(() {
55 floatArray[5] = 2.0; 55 floatArray[5] = 2.0;
56 }); 56 });
57 Expect.throws(() { 57 Expect.throws(() {
58 floatArray.setRange(0, 4, list); 58 floatArray.setRange(0, 4, list);
59 }); 59 });
60 60
61 Expect.throws(() { 61 Expect.throws(() {
62 floatArray.setRange(3, 4, list); 62 floatArray.setRange(3, 4, list);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 floatArray = new Float64List(10); 103 floatArray = new Float64List(10);
104 Expect.equals(10, floatArray.length); 104 Expect.equals(10, floatArray.length);
105 for (int i = 0; i < 10; i++) { 105 for (int i = 0; i < 10; i++) {
106 Expect.equals(0.0, floatArray[i]); 106 Expect.equals(0.0, floatArray[i]);
107 } 107 }
108 } 108 }
109 109
110 void testSetRange64() { 110 void testSetRange64() {
111 Float64List floatArray = new Float64List(3); 111 Float64List floatArray = new Float64List(3);
112 112
113 List<num> list = [10.0, 11.0, 12.0]; 113 List<double> list = [10.0, 11.0, 12.0];
114 floatArray.setRange(0, 3, list); 114 floatArray.setRange(0, 3, list);
115 for (int i = 0; i < 3; i++) { 115 for (int i = 0; i < 3; i++) {
116 Expect.equals(10 + i, floatArray[i]); 116 Expect.equals(10 + i, floatArray[i]);
117 } 117 }
118 118
119 floatArray[0] = 20.0; 119 floatArray[0] = 20.0;
120 floatArray[1] = 21.0; 120 floatArray[1] = 21.0;
121 floatArray[2] = 22.0; 121 floatArray[2] = 22.0;
122 list.setRange(0, 3, floatArray); 122 list.setRange(0, 3, floatArray);
123 for (int i = 0; i < 3; i++) { 123 for (int i = 0; i < 3; i++) {
124 Expect.equals(20 + i, list[i]); 124 Expect.equals(20 + i, list[i]);
125 } 125 }
126 126
127 // Unlike Float32Array we can properly represent 4.0e40 127 // Unlike Float32Array we can properly represent 4.0e40
128 floatArray.setRange(1, 3, const [8.0, 4.0e40]); 128 floatArray.setRange(1, 3, const [8.0, 4.0e40]);
129 Expect.equals(20, floatArray[0]); 129 Expect.equals(20, floatArray[0]);
130 Expect.equals(8, floatArray[1]); 130 Expect.equals(8, floatArray[1]);
131 Expect.equals(4.0e40, floatArray[2]); 131 Expect.equals(4.0e40, floatArray[2]);
132 } 132 }
133 133
134 void testIndexOutOfRange64() { 134 void testIndexOutOfRange64() {
135 Float64List floatArray = new Float64List(3); 135 Float64List floatArray = new Float64List(3);
136 List<num> list = const [0.0, 1.0, 2.0, 3.0]; 136 List<double> list = const [0.0, 1.0, 2.0, 3.0];
137 137
138 Expect.throws(() { 138 Expect.throws(() {
139 floatArray[5] = 2.0; 139 floatArray[5] = 2.0;
140 }); 140 });
141 Expect.throws(() { 141 Expect.throws(() {
142 floatArray.setRange(0, 4, list); 142 floatArray.setRange(0, 4, list);
143 }); 143 });
144 144
145 Expect.throws(() { 145 Expect.throws(() {
146 floatArray.setRange(3, 4, list); 146 floatArray.setRange(3, 4, list);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 testBadValues32(); 207 testBadValues32();
208 testBadValues64(); 208 testBadValues64();
209 // Check optimized (inlined) version of []= 209 // Check optimized (inlined) version of []=
210 Expect.throws(() { 210 Expect.throws(() {
211 storeIt32(a32, 1, 2); 211 storeIt32(a32, 1, 2);
212 }); 212 });
213 Expect.throws(() { 213 Expect.throws(() {
214 storeIt64(a64, 1, 2); 214 storeIt64(a64, 1, 2);
215 }); 215 });
216 } 216 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/echo_server_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698