OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 array.reverse(); // restore the array. | 107 array.reverse(); // restore the array. |
108 } | 108 } |
109 | 109 |
110 function runIntegerTestCases(isTestingGet, array, start, length) { | 110 function runIntegerTestCases(isTestingGet, array, start, length) { |
111 createDataView(array, 0, true, start, length); | 111 createDataView(array, 0, true, start, length); |
112 | 112 |
113 test(isTestingGet, "Int8", 0, 0); | 113 test(isTestingGet, "Int8", 0, 0); |
114 test(isTestingGet, "Int8", undefined, 0); | 114 test(isTestingGet, "Int8", undefined, 0); |
115 test(isTestingGet, "Int8", 8, -128); | 115 test(isTestingGet, "Int8", 8, -128); |
116 test(isTestingGet, "Int8", 15, -1); | 116 test(isTestingGet, "Int8", 15, -1); |
117 test(isTestingGet, "Int8", 1e12, undefined); | |
118 | 117 |
119 test(isTestingGet, "Uint8", 0, 0); | 118 test(isTestingGet, "Uint8", 0, 0); |
120 test(isTestingGet, "Uint8", undefined, 0); | 119 test(isTestingGet, "Uint8", undefined, 0); |
121 test(isTestingGet, "Uint8", 8, 128); | 120 test(isTestingGet, "Uint8", 8, 128); |
122 test(isTestingGet, "Uint8", 15, 255); | 121 test(isTestingGet, "Uint8", 15, 255); |
123 test(isTestingGet, "Uint8", 1e12, undefined); | |
124 | 122 |
125 // Little endian. | 123 // Little endian. |
126 test(isTestingGet, "Int16", 0, 256, true); | 124 test(isTestingGet, "Int16", 0, 256, true); |
127 test(isTestingGet, "Int16", undefined, 256, true); | 125 test(isTestingGet, "Int16", undefined, 256, true); |
128 test(isTestingGet, "Int16", 5, 26213, true); | 126 test(isTestingGet, "Int16", 5, 26213, true); |
129 test(isTestingGet, "Int16", 9, -32127, true); | 127 test(isTestingGet, "Int16", 9, -32127, true); |
130 test(isTestingGet, "Int16", 14, -2, true); | 128 test(isTestingGet, "Int16", 14, -2, true); |
131 test(isTestingGet, "Int16", 1e12, undefined, true); | |
132 | 129 |
133 // Big endian. | 130 // Big endian. |
134 test(isTestingGet, "Int16", 0, 1); | 131 test(isTestingGet, "Int16", 0, 1); |
135 test(isTestingGet, "Int16", undefined, 1); | 132 test(isTestingGet, "Int16", undefined, 1); |
136 test(isTestingGet, "Int16", 5, 25958); | 133 test(isTestingGet, "Int16", 5, 25958); |
137 test(isTestingGet, "Int16", 9, -32382); | 134 test(isTestingGet, "Int16", 9, -32382); |
138 test(isTestingGet, "Int16", 14, -257); | 135 test(isTestingGet, "Int16", 14, -257); |
139 test(isTestingGet, "Int16", 1e12, undefined); | |
140 | 136 |
141 // Little endian. | 137 // Little endian. |
142 test(isTestingGet, "Uint16", 0, 256, true); | 138 test(isTestingGet, "Uint16", 0, 256, true); |
143 test(isTestingGet, "Uint16", undefined, 256, true); | 139 test(isTestingGet, "Uint16", undefined, 256, true); |
144 test(isTestingGet, "Uint16", 5, 26213, true); | 140 test(isTestingGet, "Uint16", 5, 26213, true); |
145 test(isTestingGet, "Uint16", 9, 33409, true); | 141 test(isTestingGet, "Uint16", 9, 33409, true); |
146 test(isTestingGet, "Uint16", 14, 65534, true); | 142 test(isTestingGet, "Uint16", 14, 65534, true); |
147 test(isTestingGet, "Uint16", 1e12, undefined, true); | |
148 | 143 |
149 // Big endian. | 144 // Big endian. |
150 test(isTestingGet, "Uint16", 0, 1); | 145 test(isTestingGet, "Uint16", 0, 1); |
151 test(isTestingGet, "Uint16", undefined, 1); | 146 test(isTestingGet, "Uint16", undefined, 1); |
152 test(isTestingGet, "Uint16", 5, 25958); | 147 test(isTestingGet, "Uint16", 5, 25958); |
153 test(isTestingGet, "Uint16", 9, 33154); | 148 test(isTestingGet, "Uint16", 9, 33154); |
154 test(isTestingGet, "Uint16", 14, 65279); | 149 test(isTestingGet, "Uint16", 14, 65279); |
155 test(isTestingGet, "Uint16", 1e12, undefined); | |
156 | 150 |
157 // Little endian. | 151 // Little endian. |
158 test(isTestingGet, "Int32", 0, 50462976, true); | 152 test(isTestingGet, "Int32", 0, 50462976, true); |
159 test(isTestingGet, "Int32", undefined, 50462976, true); | 153 test(isTestingGet, "Int32", undefined, 50462976, true); |
160 test(isTestingGet, "Int32", 3, 1717920771, true); | 154 test(isTestingGet, "Int32", 3, 1717920771, true); |
161 test(isTestingGet, "Int32", 6, -2122291354, true); | 155 test(isTestingGet, "Int32", 6, -2122291354, true); |
162 test(isTestingGet, "Int32", 9, -58490239, true); | 156 test(isTestingGet, "Int32", 9, -58490239, true); |
163 test(isTestingGet, "Int32", 12,-66052, true); | 157 test(isTestingGet, "Int32", 12,-66052, true); |
164 test(isTestingGet, "Int32", 1e12, undefined, true); | |
165 | 158 |
166 // Big endian. | 159 // Big endian. |
167 test(isTestingGet, "Int32", 0, 66051); | 160 test(isTestingGet, "Int32", 0, 66051); |
168 test(isTestingGet, "Int32", undefined, 66051); | 161 test(isTestingGet, "Int32", undefined, 66051); |
169 test(isTestingGet, "Int32", 3, 56911206); | 162 test(isTestingGet, "Int32", 3, 56911206); |
170 test(isTestingGet, "Int32", 6, 1718059137); | 163 test(isTestingGet, "Int32", 6, 1718059137); |
171 test(isTestingGet, "Int32", 9, -2122152964); | 164 test(isTestingGet, "Int32", 9, -2122152964); |
172 test(isTestingGet, "Int32", 12, -50462977); | 165 test(isTestingGet, "Int32", 12, -50462977); |
173 test(isTestingGet, "Int32", 1e12, undefined); | |
174 | 166 |
175 // Little endian. | 167 // Little endian. |
176 test(isTestingGet, "Uint32", 0, 50462976, true); | 168 test(isTestingGet, "Uint32", 0, 50462976, true); |
177 test(isTestingGet, "Uint32", undefined, 50462976, true); | 169 test(isTestingGet, "Uint32", undefined, 50462976, true); |
178 test(isTestingGet, "Uint32", 3, 1717920771, true); | 170 test(isTestingGet, "Uint32", 3, 1717920771, true); |
179 test(isTestingGet, "Uint32", 6, 2172675942, true); | 171 test(isTestingGet, "Uint32", 6, 2172675942, true); |
180 test(isTestingGet, "Uint32", 9, 4236477057, true); | 172 test(isTestingGet, "Uint32", 9, 4236477057, true); |
181 test(isTestingGet, "Uint32", 12,4294901244, true); | 173 test(isTestingGet, "Uint32", 12,4294901244, true); |
182 test(isTestingGet, "Uint32", 1e12, undefined, true); | |
183 | 174 |
184 // Big endian. | 175 // Big endian. |
185 test(isTestingGet, "Uint32", 0, 66051); | 176 test(isTestingGet, "Uint32", 0, 66051); |
186 test(isTestingGet, "Uint32", undefined, 66051); | 177 test(isTestingGet, "Uint32", undefined, 66051); |
187 test(isTestingGet, "Uint32", 3, 56911206); | 178 test(isTestingGet, "Uint32", 3, 56911206); |
188 test(isTestingGet, "Uint32", 6, 1718059137); | 179 test(isTestingGet, "Uint32", 6, 1718059137); |
189 test(isTestingGet, "Uint32", 9, 2172814332); | 180 test(isTestingGet, "Uint32", 9, 2172814332); |
190 test(isTestingGet, "Uint32", 12, 4244504319); | 181 test(isTestingGet, "Uint32", 12, 4244504319); |
191 test(isTestingGet, "Uint32", 1e12, undefined); | |
192 } | 182 } |
193 | 183 |
194 function testFloat(isTestingGet, func, array, start, expected) { | 184 function testFloat(isTestingGet, func, array, start, expected) { |
195 // Little endian. | 185 // Little endian. |
196 createDataView(array, 0, true, start); | 186 createDataView(array, 0, true, start); |
197 test(isTestingGet, func, 0, expected, true); | 187 test(isTestingGet, func, 0, expected, true); |
198 test(isTestingGet, func, undefined, expected, true); | 188 test(isTestingGet, func, undefined, expected, true); |
199 createDataView(array, 3, true, start); | 189 createDataView(array, 3, true, start); |
200 test(isTestingGet, func, 3, expected, true); | 190 test(isTestingGet, func, 3, expected, true); |
201 createDataView(array, 7, true, start); | 191 createDataView(array, 7, true, start); |
202 test(isTestingGet, func, 7, expected, true); | 192 test(isTestingGet, func, 7, expected, true); |
203 createDataView(array, 10, true, start); | 193 createDataView(array, 10, true, start); |
204 test(isTestingGet, func, 10, expected, true); | 194 test(isTestingGet, func, 10, expected, true); |
205 test(isTestingGet, func, 1e12, undefined, true); | |
206 | 195 |
207 // Big endian. | 196 // Big endian. |
208 createDataView(array, 0, false); | 197 createDataView(array, 0, false); |
209 test(isTestingGet, func, 0, expected, false); | 198 test(isTestingGet, func, 0, expected, false); |
210 test(isTestingGet, func, undefined, expected, false); | 199 test(isTestingGet, func, undefined, expected, false); |
211 createDataView(array, 3, false); | 200 createDataView(array, 3, false); |
212 test(isTestingGet, func, 3, expected, false); | 201 test(isTestingGet, func, 3, expected, false); |
213 createDataView(array, 7, false); | 202 createDataView(array, 7, false); |
214 test(isTestingGet, func, 7, expected, false); | 203 test(isTestingGet, func, 7, expected, false); |
215 createDataView(array, 10, false); | 204 createDataView(array, 10, false); |
216 test(isTestingGet, func, 10, expected, false); | 205 test(isTestingGet, func, 10, expected, false); |
217 test(isTestingGet, func, 1e12, undefined, false); | |
218 } | 206 } |
219 | 207 |
220 function runFloatTestCases(isTestingGet, start) { | 208 function runFloatTestCases(isTestingGet, start) { |
221 testFloat(isTestingGet, "Float32", | 209 testFloat(isTestingGet, "Float32", |
222 isTestingGet ? [0, 0, 32, 65] : initialArray, start, 10); | 210 isTestingGet ? [0, 0, 32, 65] : initialArray, start, 10); |
223 | 211 |
224 testFloat(isTestingGet, "Float32", | 212 testFloat(isTestingGet, "Float32", |
225 isTestingGet ? [164, 112, 157, 63] : initialArray, | 213 isTestingGet ? [164, 112, 157, 63] : initialArray, |
226 start, 1.2300000190734863); | 214 start, 1.2300000190734863); |
227 testFloat(isTestingGet, "Float32", | 215 testFloat(isTestingGet, "Float32", |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 assertThrows(function() { a.setInt8(1) }, TypeError); | 440 assertThrows(function() { a.setInt8(1) }, TypeError); |
453 assertThrows(function() { a.setUint16(1) }, TypeError); | 441 assertThrows(function() { a.setUint16(1) }, TypeError); |
454 assertThrows(function() { a.setInt16(1) }, TypeError); | 442 assertThrows(function() { a.setInt16(1) }, TypeError); |
455 assertThrows(function() { a.setUint32(1) }, TypeError); | 443 assertThrows(function() { a.setUint32(1) }, TypeError); |
456 assertThrows(function() { a.setInt32(1) }, TypeError); | 444 assertThrows(function() { a.setInt32(1) }, TypeError); |
457 assertThrows(function() { a.setFloat32(1) }, TypeError); | 445 assertThrows(function() { a.setFloat32(1) }, TypeError); |
458 assertThrows(function() { a.setFloat64(1) }, TypeError); | 446 assertThrows(function() { a.setFloat64(1) }, TypeError); |
459 } | 447 } |
460 | 448 |
461 TestInsufficientArguments(); | 449 TestInsufficientArguments(); |
OLD | NEW |