Reviewers: arv,
Message:
PTAL
Description:
[es5] convert parts ToString() in String.prototype.concat()
BUG=v8:3981
[email protected]
LOG=N
Please review this at https://codereview.chromium.org/1029103002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+15, -2 lines):
M src/string.js
A test/mjsunit/string-concat.js
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index
6286be3e49d42e8e4fcad7c8b9286e3419d35b40..0f29cd1dc147ca7c8fc6b24c4d965af32754a734
100644
--- a/src/string.js
+++ b/src/string.js
@@ -72,11 +72,10 @@ function StringCharCodeAtJS(pos) {
// ECMA-262, section 15.5.4.6
function StringConcat(other /* and more */) { // length == 1
CHECK_OBJECT_COERCIBLE(this, "String.prototype.concat");
-
var len = %_ArgumentsLength();
var this_as_string = TO_STRING_INLINE(this);
if (len === 1) {
- return this_as_string + other;
+ return this_as_string + TO_STRING_INLINE(other);
}
var parts = new InternalArray(len + 1);
parts[0] = this_as_string;
Index: test/mjsunit/string-concat.js
diff --git a/test/mjsunit/string-concat.js b/test/mjsunit/string-concat.js
new file mode 100644
index
0000000000000000000000000000000000000000..308912b7851f1093c15e10876bf790aa8b6678cc
--- /dev/null
+++ b/test/mjsunit/string-concat.js
@@ -0,0 +1,14 @@
+// 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.
+
+function Stringified(toString, valueOf) {
+ if (typeof valueOf === "undefined") valueOf = "-" + toString + "-";
+ return {
+ toString: function() { return toString; },
+ valueOf: function() { return valueOf; }
+ };
+}
+
+assertEquals("a.b.", "a.".concat(Stringified("b.")));
+assertEquals("a.b.c.", "a.".concat(Stringified("b."), Stringified("c.")));
--
--
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/d/optout.