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

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

Issue 17572009: Update typed arrays behavior to match ES6 rev 15. Remove TO_POSITIVE_INTEGER and throw on negative … (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 7 years, 6 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 | « src/typedarray.js ('k') | test/mjsunit/harmony/typedarrays.js » ('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 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return 8; 57 return 8;
58 default: 58 default:
59 assertUnreachable(func); 59 assertUnreachable(func);
60 } 60 }
61 } 61 }
62 62
63 function checkGet(func, index, expected, littleEndian) { 63 function checkGet(func, index, expected, littleEndian) {
64 function doGet() { 64 function doGet() {
65 return view["get" + func](index, littleEndian); 65 return view["get" + func](index, littleEndian);
66 } 66 }
67 if (index < 0) index = 0; 67 if (index >=0 && index + getElementSize(func) - 1 < view.byteLength)
68 if (index + getElementSize(func) - 1 < view.byteLength)
69 assertSame(expected, doGet()); 68 assertSame(expected, doGet());
70 else 69 else
71 assertThrows(doGet, RangeError); 70 assertThrows(doGet, RangeError);
72 } 71 }
73 72
74 function checkSet(func, index, value, littleEndian) { 73 function checkSet(func, index, value, littleEndian) {
75 function doSet() { 74 function doSet() {
76 view["set" + func](index, value, littleEndian); 75 view["set" + func](index, value, littleEndian);
77 } 76 }
78 actualIndex = index < 0 ? 0 : index; 77 if (index >= 0 &&
79 if (actualIndex >= 0 && 78 index + getElementSize(func) - 1 < view.byteLength) {
80 actualIndex + getElementSize(func) - 1 < view.byteLength) {
81 assertSame(undefined, doSet()); 79 assertSame(undefined, doSet());
82 checkGet(func, index, value, littleEndian); 80 checkGet(func, index, value, littleEndian);
83 } else { 81 } else {
84 assertThrows(doSet, RangeError); 82 assertThrows(doSet, RangeError);
85 } 83 }
86 } 84 }
87 85
88 function test(isTestingGet, func, index, value, littleEndian) { 86 function test(isTestingGet, func, index, value, littleEndian) {
89 if (isTestingGet) 87 if (isTestingGet)
90 checkGet(func, index, value, littleEndian); 88 checkGet(func, index, value, littleEndian);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 CheckAccessor("setUint32"); 301 CheckAccessor("setUint32");
304 CheckAccessor("getInt32"); 302 CheckAccessor("getInt32");
305 CheckAccessor("setInt32"); 303 CheckAccessor("setInt32");
306 CheckAccessor("getFloat32"); 304 CheckAccessor("getFloat32");
307 CheckAccessor("setFloat32"); 305 CheckAccessor("setFloat32");
308 CheckAccessor("getFloat64"); 306 CheckAccessor("getFloat64");
309 CheckAccessor("setFloat64"); 307 CheckAccessor("setFloat64");
310 } 308 }
311 309
312 TestGeneralAccessors(); 310 TestGeneralAccessors();
OLDNEW
« no previous file with comments | « src/typedarray.js ('k') | test/mjsunit/harmony/typedarrays.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698