Reviewers: Dmitry Lomov (chromium),

Description:
Fix typed array error message.

[email protected]
BUG=v8:3159
LOG=N

Please review this at https://codereview.chromium.org/163293002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+13, -3 lines):
  M src/messages.js
  M src/typedarray.js
  A test/mjsunit/regress/regress-3159.js


Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index cdf95b1f2736d19ad0339d6de13953d19a8171cf..733fe95e2f7bddc0eea9997571bd2fd85278d6e5 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -120,7 +120,7 @@ var kMessages = {
   invalid_string_length:         ["Invalid string length"],
   invalid_typed_array_offset:    ["Start offset is too large:"],
   invalid_typed_array_length:    ["Invalid typed array length"],
- invalid_typed_array_alignment: ["%0", "of", "%1", "should be a multiple of", "%3"], + invalid_typed_array_alignment: ["%0", " of ", "%1", " should be a multiple of ", "%2"],
   typed_array_set_source_too_large:
                                  ["Source is too large"],
   typed_array_set_negative_offset:
Index: src/typedarray.js
diff --git a/src/typedarray.js b/src/typedarray.js
index c0f07eda85623defe627fa5f7d834bfb5f2ba6e5..0c0cb71b2a3bf883972384a8cb1d86be23baa299 100644
--- a/src/typedarray.js
+++ b/src/typedarray.js
@@ -58,7 +58,7 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)

       if (offset % ELEMENT_SIZE !== 0) {
         throw MakeRangeError("invalid_typed_array_alignment",
-            "start offset", "NAME", ELEMENT_SIZE);
+            ["start offset", "NAME", ELEMENT_SIZE]);
       }
       if (offset > bufferByteLength) {
         throw MakeRangeError("invalid_typed_array_offset");
@@ -70,7 +70,7 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
     if (IS_UNDEFINED(length)) {
       if (bufferByteLength % ELEMENT_SIZE !== 0) {
         throw MakeRangeError("invalid_typed_array_alignment",
-          "byte length", "NAME", ELEMENT_SIZE);
+          ["byte length", "NAME", ELEMENT_SIZE]);
       }
       newByteLength = bufferByteLength - offset;
       newLength = newByteLength / ELEMENT_SIZE;
Index: test/mjsunit/regress/regress-3159.js
diff --git a/test/mjsunit/regress/regress-3159.js b/test/mjsunit/regress/regress-3159.js
new file mode 100644
index 0000000000000000000000000000000000000000..cfc8a39b8d011533ed94fcaf11669814c9cbc4d2
--- /dev/null
+++ b/test/mjsunit/regress/regress-3159.js
@@ -0,0 +1,10 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+try {
+  new Uint32Array(new ArrayBuffer(1), 2, 3);
+} catch (e) {
+  assertEquals("start offset of Uint32Array should be a multiple of 4",
+               e.message);
+}


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to