Closed Bug 1115817 Opened 10 years ago Closed 9 years ago

Implement %TypedArray%.prototype.join

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla37

People

(Reporter: 446240525, Assigned: 446240525)

References

Details

(Keywords: dev-doc-complete, Whiteboard: [DocArea=JS])

Attachments

(1 file, 1 obsolete file)

      No description provided.
Attached patch bug-1115817-v1.patch (obsolete) — Splinter Review
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)
Attachment #8541847 - Attachment is obsolete: true
Attachment #8542390 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/0c04156cefc1
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: