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

Side by Side Diff: test/mjsunit/harmony/dataview-accessors.js

Issue 18703007: Use corerct conversions for DataView accessors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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
« src/runtime.cc ('K') | « src/runtime.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 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 287 }
288 288
289 function TestSetters() { 289 function TestSetters() {
290 runIntegerTestCases(false, initialArray, 0, 16); 290 runIntegerTestCases(false, initialArray, 0, 16);
291 runFloatTestCases(false); 291 runFloatTestCases(false);
292 292
293 runIntegerTestCases(false, initialArray, 3, 2); 293 runIntegerTestCases(false, initialArray, 3, 2);
294 runFloatTestCases(false, 7); 294 runFloatTestCases(false, 7);
295 295
296 runNegativeIndexTests(false); 296 runNegativeIndexTests(false);
297
298 } 297 }
299 298
300 TestGetters(); 299 TestGetters();
301 TestSetters(); 300 TestSetters();
302 301
302 function CheckOutOfRange(typename, value, expected) {
titzer 2013/07/12 16:37:02 Mmmm...jsiness. Could we have a version of this te
Dmitry Lomov (no reviews) 2013/07/12 18:22:45 Done.
303 var view = new DataView(new ArrayBuffer(100));
304 assertSame(undefined, view["set" + typename](0, value));
305 assertSame(expected, view["get" + typename](0));
306 assertSame(undefined, view["set" + typename](0, value, true));
307 assertSame(expected, view["get" + typename](0, true));
308 }
309
310 function TestOutOfRange() {
311 CheckOutOfRange("Int8", 0x80, -0x80);
312 CheckOutOfRange("Int8", 0x1000, 0);
313 CheckOutOfRange("Int8", -0x81, 0x7F);
314
315 CheckOutOfRange("Uint8", 0x100, 0);
316 CheckOutOfRange("Uint8", 0x1000, 0);
317 CheckOutOfRange("Uint8", -0x80, 0x80);
318 CheckOutOfRange("Uint8", -1, 0xFF);
319 CheckOutOfRange("Uint8", -0xFF, 1);
320
321 CheckOutOfRange("Int16", 0x8000, -0x8000);
322 CheckOutOfRange("Int16", 0x10000, 0);
323 CheckOutOfRange("Int16", -0x8001, 0x7FFF);
324
325 CheckOutOfRange("Uint16", 0x10000, 0);
326 CheckOutOfRange("Uint16", 0x100000, 0);
327 CheckOutOfRange("Uint16", -0x8000, 0x8000);
328 CheckOutOfRange("Uint16", -1, 0xFFFF);
329 CheckOutOfRange("Uint16", -0xFFFF, 1);
330
331 CheckOutOfRange("Int32", 0x80000000, -0x80000000);
332 CheckOutOfRange("Int32", 0x100000000, 0);
333 CheckOutOfRange("Int32", -0x80000001, 0x7FFFFFFF);
334
335 CheckOutOfRange("Uint32", 0x100000000, 0);
336 CheckOutOfRange("Uint32", 0x1000000000, 0);
337 CheckOutOfRange("Uint32", -0x80000000, 0x80000000);
338 CheckOutOfRange("Uint32", -1, 0xFFFFFFFF);
339 CheckOutOfRange("Uint32", -0xFFFFFFFF, 1);
340 }
341
342 TestOutOfRange();
343
303 function TestGeneralAccessors() { 344 function TestGeneralAccessors() {
304 var a = new DataView(new ArrayBuffer(256)); 345 var a = new DataView(new ArrayBuffer(256));
305 function CheckAccessor(name) { 346 function CheckAccessor(name) {
306 var f = a[name]; 347 var f = a[name];
307 assertThrows(function() { f(); }, TypeError); 348 assertThrows(function() { f(); }, TypeError);
308 f.call(a, 0, 0); // should not throw 349 f.call(a, 0, 0); // should not throw
309 assertThrows(function() { f.call({}, 0, 0); }, TypeError); 350 assertThrows(function() { f.call({}, 0, 0); }, TypeError);
310 assertThrows(function() { f.call(a); }, TypeError); 351 assertThrows(function() { f.call(a); }, TypeError);
311 } 352 }
312 CheckAccessor("getUint8"); 353 CheckAccessor("getUint8");
313 CheckAccessor("setUint8"); 354 CheckAccessor("setUint8");
314 CheckAccessor("getInt8"); 355 CheckAccessor("getInt8");
315 CheckAccessor("setInt8"); 356 CheckAccessor("setInt8");
316 CheckAccessor("getUint16"); 357 CheckAccessor("getUint16");
317 CheckAccessor("setUint16"); 358 CheckAccessor("setUint16");
318 CheckAccessor("getInt16"); 359 CheckAccessor("getInt16");
319 CheckAccessor("setInt16"); 360 CheckAccessor("setInt16");
320 CheckAccessor("getUint32"); 361 CheckAccessor("getUint32");
321 CheckAccessor("setUint32"); 362 CheckAccessor("setUint32");
322 CheckAccessor("getInt32"); 363 CheckAccessor("getInt32");
323 CheckAccessor("setInt32"); 364 CheckAccessor("setInt32");
324 CheckAccessor("getFloat32"); 365 CheckAccessor("getFloat32");
325 CheckAccessor("setFloat32"); 366 CheckAccessor("setFloat32");
326 CheckAccessor("getFloat64"); 367 CheckAccessor("getFloat64");
327 CheckAccessor("setFloat64"); 368 CheckAccessor("setFloat64");
328 } 369 }
329 370
330 TestGeneralAccessors(); 371 TestGeneralAccessors();
OLDNEW
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698