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

Unified 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 side-by-side diff with in-line comments
Download patch
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/dataview-accessors.js
diff --git a/test/mjsunit/harmony/dataview-accessors.js b/test/mjsunit/harmony/dataview-accessors.js
index b655a4164a14d338a12a02a94ed5b59e22e0aed4..8cbff3d3c83de295e34f79509a27ddbbb276915d 100644
--- a/test/mjsunit/harmony/dataview-accessors.js
+++ b/test/mjsunit/harmony/dataview-accessors.js
@@ -294,12 +294,53 @@ function TestSetters() {
runFloatTestCases(false, 7);
runNegativeIndexTests(false);
-
}
TestGetters();
TestSetters();
+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.
+ var view = new DataView(new ArrayBuffer(100));
+ assertSame(undefined, view["set" + typename](0, value));
+ assertSame(expected, view["get" + typename](0));
+ assertSame(undefined, view["set" + typename](0, value, true));
+ assertSame(expected, view["get" + typename](0, true));
+}
+
+function TestOutOfRange() {
+ CheckOutOfRange("Int8", 0x80, -0x80);
+ CheckOutOfRange("Int8", 0x1000, 0);
+ CheckOutOfRange("Int8", -0x81, 0x7F);
+
+ CheckOutOfRange("Uint8", 0x100, 0);
+ CheckOutOfRange("Uint8", 0x1000, 0);
+ CheckOutOfRange("Uint8", -0x80, 0x80);
+ CheckOutOfRange("Uint8", -1, 0xFF);
+ CheckOutOfRange("Uint8", -0xFF, 1);
+
+ CheckOutOfRange("Int16", 0x8000, -0x8000);
+ CheckOutOfRange("Int16", 0x10000, 0);
+ CheckOutOfRange("Int16", -0x8001, 0x7FFF);
+
+ CheckOutOfRange("Uint16", 0x10000, 0);
+ CheckOutOfRange("Uint16", 0x100000, 0);
+ CheckOutOfRange("Uint16", -0x8000, 0x8000);
+ CheckOutOfRange("Uint16", -1, 0xFFFF);
+ CheckOutOfRange("Uint16", -0xFFFF, 1);
+
+ CheckOutOfRange("Int32", 0x80000000, -0x80000000);
+ CheckOutOfRange("Int32", 0x100000000, 0);
+ CheckOutOfRange("Int32", -0x80000001, 0x7FFFFFFF);
+
+ CheckOutOfRange("Uint32", 0x100000000, 0);
+ CheckOutOfRange("Uint32", 0x1000000000, 0);
+ CheckOutOfRange("Uint32", -0x80000000, 0x80000000);
+ CheckOutOfRange("Uint32", -1, 0xFFFFFFFF);
+ CheckOutOfRange("Uint32", -0xFFFFFFFF, 1);
+}
+
+TestOutOfRange();
+
function TestGeneralAccessors() {
var a = new DataView(new ArrayBuffer(256));
function CheckAccessor(name) {
« 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