Closed Bug 1116390 Opened 9 years ago Closed 9 years ago

Implement %TypedArray%.prototype.{every, some}

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-1116390-v1.patch (obsolete) — Splinter Review
Attachment #8542762 - Flags: review?(evilpies)
Comment on attachment 8542762 [details] [diff] [review]
bug-1116390-v1.patch

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

::: js/src/tests/ecma_6/TypedArray/every-and-some.js
@@ +90,5 @@
> +    assertThrowsInstanceOf(() => {
> +        arr.every();
> +    }, TypeError);
> +    var invalidCallbacks = [undefined, null, 1, false, "", Symbol(), [], {}, /./];
> +    invalidCallbacks.every(callback => {

forEach :)

@@ +105,5 @@
> +    // Called from other globals.
> +    if (typeof newGlobal === "function") {
> +        var every = newGlobal()[constructor.name].prototype.every;
> +        var sum = 0;
> +        every.call(new constructor([1, 2, 3]), v => sum += v);

assertEq(..., true)

@@ +139,5 @@
> +    assertEq(new constructor([1, 2, 3]).some(v => v % 2), true);
> +    assertEq(new constructor([0, 2, 4]).some(v => v % 2), false);
> +    assertEq(new constructor([1, 3, 5]).some(v => v > 2), true);
> +    assertEq(new constructor([1, 3, 5]).some(v => v < 0), false);
> +    assertEq(new constructor(10).some(v => v !== 0), false);

Wouldn't this be true?

@@ +213,5 @@
> +    assertThrowsInstanceOf(() => {
> +        arr.some();
> +    }, TypeError);
> +    var invalidCallbacks = [undefined, null, 1, false, "", Symbol(), [], {}, /./];
> +    invalidCallbacks.some(callback => {

forEach

@@ +228,5 @@
> +    // Called from other globals.
> +    if (typeof newGlobal === "function") {
> +        var some = newGlobal()[constructor.name].prototype.some;
> +        var sum = 0;
> +        some.call(new constructor([1, 2, 3]), v => {

assertEq(..., false)
Attachment #8542762 - Flags: review?(evilpies) → review+
Comment on attachment 8542762 [details] [diff] [review]
bug-1116390-v1.patch

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

::: js/src/tests/ecma_6/TypedArray/every-and-some.js
@@ +139,5 @@
> +    assertEq(new constructor([1, 2, 3]).some(v => v % 2), true);
> +    assertEq(new constructor([0, 2, 4]).some(v => v % 2), false);
> +    assertEq(new constructor([1, 3, 5]).some(v => v > 2), true);
> +    assertEq(new constructor([1, 3, 5]).some(v => v < 0), false);
> +    assertEq(new constructor(10).some(v => v !== 0), false);

I guess you mean line 144? Because the `some` method always returns `false` when called on empty arrays.
Comment on attachment 8542762 [details] [diff] [review]
bug-1116390-v1.patch

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

::: js/src/tests/ecma_6/TypedArray/every-and-some.js
@@ +139,5 @@
> +    assertEq(new constructor([1, 2, 3]).some(v => v % 2), true);
> +    assertEq(new constructor([0, 2, 4]).some(v => v % 2), false);
> +    assertEq(new constructor([1, 3, 5]).some(v => v > 2), true);
> +    assertEq(new constructor([1, 3, 5]).some(v => v < 0), false);
> +    assertEq(new constructor(10).some(v => v !== 0), false);

Oh, sorry. I read this as new constructor([10])
Attachment #8542762 - Attachment is obsolete: true
Attachment #8543509 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/c963d611da18
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: