Implement %TypedArray%.prototype.join

RESOLVED FIXED in mozilla37

Status

()

Core
JavaScript: Standard Library
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: ziyunfei, Assigned: ziyunfei)

Tracking

({dev-doc-complete})

Trunk
mozilla37
dev-doc-complete
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [DocArea=JS])

Attachments

(1 attachment, 1 obsolete attachment)

Comment hidden (empty)
(Assignee)

Comment 1

4 years ago
Created attachment 8541847 [details] [diff] [review]
bug-1115817-v1.patch
Attachment #8541847 - Flags: review?(evilpies)
Comment on attachment 8541847 [details] [diff] [review]
bug-1115817-v1.patch

Review of attachment 8541847 [details] [diff] [review]:
-----------------------------------------------------------------

Great work as always.

::: js/src/builtin/TypedArray.js
@@ +186,5 @@
> +    // Step 9.
> +    var element0 = O[0];
> +
> +    // Steps 10-11.
> +    var R = (element0 === null || element0 === undefined) ? "" : ToString(element0);

element0 can't really be null or undefined, right? Because after step 8 we have at least one element, which can only be a number.

::: js/src/tests/ecma_6/TypedArray/join.js
@@ +19,5 @@
> +    assertEq(new constructor([1, 2, 3]).join(.1), "10.120.13");
> +    assertEq(new constructor([1, 2, 3]).join({toString(){return "foo"}}), "1foo2foo3");
> +    assertEq(new constructor().join(), "");
> +    assertEq(new constructor().join("*"), "");
> +    assertEq(new constructor(3).join(), "0,0,0");

Please add one test for the "special" len == 1 case.
Attachment #8541847 - Flags: review?(evilpies) → review+
Comment on attachment 8541847 [details] [diff] [review]
bug-1115817-v1.patch

Review of attachment 8541847 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/builtin/TypedArray.js
@@ +189,5 @@
> +    // Steps 10-11.
> +    var R = (element0 === null || element0 === undefined) ? "" : ToString(element0);
> +
> +    // Steps 12-13.
> +    // Omit the 'if' clause in step 13.c, since typed arrays can not have undefined or null element.

Oh I think this should be element*s*
Comment on attachment 8541847 [details] [diff] [review]
bug-1115817-v1.patch

Review of attachment 8541847 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/builtin/TypedArray.js
@@ +191,5 @@
> +
> +    // Steps 12-13.
> +    // Omit the 'if' clause in step 13.c, since typed arrays can not have undefined or null element.
> +    for (var k = 1; k < len; k++) {
> +        R = R + sep + ToString(O[k]);

While this is correct, I would prefer if you could separate this into the steps as well.

::: js/src/tests/ecma_6/TypedArray/join.js
@@ +12,5 @@
> +
> +for (var constructor of constructors) {
> +    assertEq(constructor.prototype.join.length, 1);
> +
> +    assertEq(new constructor([1, 2, 3]).join(), "1,2,3");

On test with join(undefined)
(Assignee)

Comment 5

4 years ago
Created attachment 8542390 [details] [diff] [review]
review comment addressed
Attachment #8541847 - Attachment is obsolete: true
Attachment #8542390 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/0c04156cefc1
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
You need to log in before you can comment on or make changes to this bug.