Implement JS 1.8 reduce/reduceRight array methods

RESOLVED FIXED

Status

Rhino
Core
RESOLVED FIXED
10 years ago
8 years ago

People

(Reporter: Hannes Wallnoefer, Assigned: Norris Boyd)

Tracking

(Blocks: 1 bug)

Details

Attachments

(3 attachments, 1 obsolete attachment)

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1
Build Identifier: 

Implement JavaScript 1.8 reduce/reduceRight array methods. See bug #363040 for spicermonkey implementation.

Reproducible: Always
(Reporter)

Comment 1

10 years ago
Created attachment 339794 [details] [diff] [review]
Implements reduce/reduceRight methods

Implements reduce and reduceRight methods on array prototype and constructor. I tried to reproduce the behaviour of spidermonkey, especially for sparse/empty arrays.
(Reporter)

Comment 2

10 years ago
Created attachment 339863 [details] [diff] [review]
improved patch

Patch with minor improvements and fixes.
Attachment #339794 - Attachment is obsolete: true
(Assignee)

Updated

10 years ago
Assignee: nobody → norrisboyd
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
(Reporter)

Updated

9 years ago
Blocks: 489326
(Reporter)

Comment 3

9 years ago
Committed the last patch to CVS HEAD:

Checking in src/org/mozilla/javascript/NativeArray.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/NativeArray.java,v  <--  NativeArray.java
new revision: 1.97; previous revision: 1.96
done
Checking in src/org/mozilla/javascript/resources/Messages.properties;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/resources/Messages.properties,v  <--  Messages.properties
new revision: 1.91; previous revision: 1.90
done
Status: ASSIGNED → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED

Comment 4

9 years ago
Created attachment 391093 [details] [diff] [review]
reduce and reduceRight throw a TypeError when array empty and no initVal

As per 15.4.4.21 step 5, and 15.4.4.22 step 5 of the spec.
(Assignee)

Comment 5

9 years ago
(In reply to comment #4)
> Created an attachment (id=391093) [details]
> reduce and reduceRight throw a TypeError when array empty and no initVal
> 
> As per 15.4.4.21 step 5, and 15.4.4.22 step 5 of the spec.

Committed:

Checking in src/org/mozilla/javascript/NativeArray.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/NativeArray.java,v  <--  NativeArray.java
new revision: 1.105; previous revision: 1.104

Comment 6

8 years ago
Created attachment 412824 [details] [diff] [review]
made reduceRight pass the correct (descending) index to the callback function
You need to log in before you can comment on or make changes to this bug.