summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/reduce
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Array/prototype/reduce
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/reduce')
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-1.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-10.js18
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-11.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-12.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-13.js18
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-14.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-15.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-2.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-3.js18
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-4.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-5.js18
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-6.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-7.js15
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-8.js17
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-9.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-1.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-2.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-3.js18
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-4.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-5.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-6.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-7.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-8.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-1.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-10.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-11.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-12.js37
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-13.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-14.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-17.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-18.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-19.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-2.js15
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-3.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-4.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-5.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-6.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-7.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-8.js37
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-9.js43
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-1.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-10.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-11.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-12.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-13.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-14.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-15.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-16.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-17.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-18.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-19.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-2.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-20.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-21.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-22.js43
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-23.js45
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-24.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-25.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-3.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-4.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-5.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-6.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-7.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-9.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-1.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-12.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-15.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-2.js16
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-3.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-4.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-5.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-6.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-7.js16
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-8.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-9.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-1.js16
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-10.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-11.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-2.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-3.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-4.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-5.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-6.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-7.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-8.js37
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-9.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-1.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-10.js13
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-11.js13
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-2.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-3.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-4.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-5.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-6.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-8.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-9.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-2.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-3.js45
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js43
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js49
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js41
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js37
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js45
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js48
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js44
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-1.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-2.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-3.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-5.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-6.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-1.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-10.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-2.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-4.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-5.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-7.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-8.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-9.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-1.js18
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-10.js41
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-11.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-12.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-13.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-14.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-15.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-16.js41
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-17.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-18.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-19.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-2.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-20.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-21.js46
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-22.js43
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-23.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-24.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-25.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-26.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-27.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-28.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-29.js41
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-3.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-4.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-5.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-6.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-7.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-8.js46
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-9.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-1.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js44
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js34
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js50
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js42
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js43
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js40
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js46
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js49
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js47
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js36
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js37
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js27
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/call-with-boolean.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js76
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/length.js30
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/name.js28
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/prop-desc.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/reduce/shell.js161
259 files changed, 7646 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-1.js
new file mode 100644
index 0000000000..f602de688b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-1.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to undefined
+---*/
+
+
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(undefined);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-10.js
new file mode 100644
index 0000000000..356831c93f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-10.js
@@ -0,0 +1,18 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to the Math object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return ('[object Math]' === Object.prototype.toString.call(obj));
+}
+
+Math.length = 1;
+Math[0] = 1;
+
+assert(Array.prototype.reduce.call(Math, callbackfn, 1), 'Array.prototype.reduce.call(Math, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-11.js
new file mode 100644
index 0000000000..e7c228f2fa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-11.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to Date object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return obj instanceof Date;
+}
+
+var obj = new Date();
+obj.length = 1;
+obj[0] = 1;
+
+assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-12.js
new file mode 100644
index 0000000000..7b9841d843
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-12.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to RegExp object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return obj instanceof RegExp;
+}
+
+var obj = new RegExp();
+obj.length = 1;
+obj[0] = 1;
+
+assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-13.js
new file mode 100644
index 0000000000..e336ea2370
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-13.js
@@ -0,0 +1,18 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to the JSON object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return ('[object JSON]' === Object.prototype.toString.call(obj));
+}
+
+JSON.length = 1;
+JSON[0] = 1;
+
+assert(Array.prototype.reduce.call(JSON, callbackfn, 1), 'Array.prototype.reduce.call(JSON, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-14.js
new file mode 100644
index 0000000000..0265a4209e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-14.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to Error object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return obj instanceof Error;
+}
+
+var obj = new Error();
+obj.length = 1;
+obj[0] = 1;
+
+assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-15.js
new file mode 100644
index 0000000000..38f7254600
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-15.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to the Arguments object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return ('[object Arguments]' === Object.prototype.toString.call(obj));
+}
+
+var obj = (function() {
+ return arguments;
+}("a", "b"));
+
+assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-2.js
new file mode 100644
index 0000000000..71a935eda1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-2.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to null
+---*/
+
+
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(null);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-3.js
new file mode 100644
index 0000000000..7288e5a23d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-3.js
@@ -0,0 +1,18 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to boolean primitive
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return obj instanceof Boolean;
+}
+
+Boolean.prototype[0] = true;
+Boolean.prototype.length = 1;
+
+assert(Array.prototype.reduce.call(false, callbackfn, 1), 'Array.prototype.reduce.call(false, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-4.js
new file mode 100644
index 0000000000..a8026dec51
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-4.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to Boolean object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return obj instanceof Boolean;
+}
+
+var obj = new Boolean(true);
+obj.length = 2;
+obj[0] = 11;
+obj[1] = 12;
+
+assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-5.js
new file mode 100644
index 0000000000..48c2e67a3f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-5.js
@@ -0,0 +1,18 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to number primitive
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return obj instanceof Number;
+}
+
+Number.prototype[0] = 1;
+Number.prototype.length = 1;
+
+assert(Array.prototype.reduce.call(2.5, callbackfn, 1), 'Array.prototype.reduce.call(2.5, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-6.js
new file mode 100644
index 0000000000..174051b42b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-6.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to Number object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return obj instanceof Number;
+}
+
+var obj = new Number(-128);
+obj.length = 2;
+obj[0] = 11;
+obj[1] = 12;
+
+assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-7.js
new file mode 100644
index 0000000000..a49a2f72d4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-7.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to string primitive
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return obj instanceof String;
+}
+
+assert(Array.prototype.reduce.call("abc", callbackfn, 1), 'Array.prototype.reduce.call("abc", callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-8.js
new file mode 100644
index 0000000000..3bd7f04768
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-8.js
@@ -0,0 +1,17 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to String object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return obj instanceof String;
+}
+
+var obj = new String("abc");
+
+assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-9.js
new file mode 100644
index 0000000000..f4d55a0b8f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-1-9.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to Function object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return obj instanceof Function;
+}
+
+var obj = function(a, b) {
+ return a + b;
+};
+obj[0] = 11;
+obj[1] = 9;
+
+assert(Array.prototype.reduce.call(obj, callbackfn, 1), 'Array.prototype.reduce.call(obj, callbackfn, 1) !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-1.js
new file mode 100644
index 0000000000..ab069463b9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-1.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce doesn't mutate the Array on which it is
+ called on
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ return 1;
+}
+var srcArr = [1, 2, 3, 4, 5];
+srcArr.reduce(callbackfn);
+
+assert.sameValue(srcArr[0], 1, 'srcArr[0]');
+assert.sameValue(srcArr[1], 2, 'srcArr[1]');
+assert.sameValue(srcArr[2], 3, 'srcArr[2]');
+assert.sameValue(srcArr[3], 4, 'srcArr[3]');
+assert.sameValue(srcArr[4], 5, 'srcArr[4]');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-2.js
new file mode 100644
index 0000000000..7ed501c653
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-2.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce reduces the array in ascending order of
+ indices
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ return prevVal + curVal;
+}
+var srcArr = ['1', '2', '3', '4', '5'];
+
+assert.sameValue(srcArr.reduce(callbackfn), '12345', 'srcArr.reduce(callbackfn)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-3.js
new file mode 100644
index 0000000000..7a91f97074
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-3.js
@@ -0,0 +1,18 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - subclassed array of length 1
+---*/
+
+foo.prototype = [1];
+
+function foo() {}
+var f = new foo();
+
+function cb() {}
+
+assert.sameValue(f.reduce(cb), 1, 'f.reduce(cb)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-4.js
new file mode 100644
index 0000000000..9670ccae3d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-4.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - subclassed array with length more than 1
+---*/
+
+foo.prototype = new Array(1, 2, 3, 4);
+
+function foo() {}
+var f = new foo();
+
+function cb(prevVal, curVal, idx, obj) {
+ return prevVal + curVal;
+}
+
+assert.sameValue(f.reduce(cb), 10, 'f.reduce(cb)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-5.js
new file mode 100644
index 0000000000..c29ea02ed1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-5.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce reduces the array in ascending order of
+ indices(initialvalue present)
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ return prevVal + curVal;
+}
+var srcArr = ['1', '2', '3', '4', '5'];
+
+assert.sameValue(srcArr.reduce(callbackfn, '0'), '012345', 'srcArr.reduce(callbackfn,"0")');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-6.js
new file mode 100644
index 0000000000..d007e84a0a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-6.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - subclassed array when initialvalue
+ provided
+---*/
+
+foo.prototype = [1, 2, 3, 4];
+
+function foo() {}
+var f = new foo();
+
+function cb(prevVal, curVal, idx, obj) {
+ return prevVal + curVal;
+}
+
+assert.sameValue(f.reduce(cb, -1), 9, 'f.reduce(cb,-1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-7.js
new file mode 100644
index 0000000000..3e3e1b039e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-7.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - subclassed array with length 1 and
+ initialvalue provided
+---*/
+
+foo.prototype = [1];
+
+function foo() {}
+var f = new foo();
+
+function cb(prevVal, curVal, idx, obj) {
+ return prevVal + curVal;
+}
+
+assert.sameValue(f.reduce(cb, -1), 0, 'f.reduce(cb,-1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-8.js
new file mode 100644
index 0000000000..a13c8c6f39
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-10-8.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce doesn't visit expandos
+---*/
+
+var callCnt = 0;
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ callCnt++;
+ return curVal;
+}
+var srcArr = ['1', '2', '3', '4', '5'];
+srcArr["i"] = 10;
+srcArr[true] = 11;
+srcArr.reduce(callbackfn);
+
+assert.sameValue(callCnt, 4, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-1.js
new file mode 100644
index 0000000000..b45ecf4a0d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-1.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is own data property on an
+ Array-like object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+var obj = {
+ 0: 12,
+ 1: 11,
+ 2: 9,
+ length: 2
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-10.js
new file mode 100644
index 0000000000..a73d8c2115
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-10.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to Array-like object, 'length' is
+ an inherited accessor property
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "length", {
+ get: function() {
+ return 2;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-11.js
new file mode 100644
index 0000000000..26a9bded1c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-11.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to Array-like object, 'length' is
+ an own accessor property without a get function
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+Object.defineProperty(obj, "length", {
+ set: function() {},
+ configurable: true
+});
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-12.js
new file mode 100644
index 0000000000..7496112e3b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-12.js
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is own accessor property without
+ a get function that overrides an inherited accessor property on an
+ Array
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+}
+
+Object.defineProperty(Object.prototype, "length", {
+ get: function() {
+ return 2;
+ },
+ configurable: true
+});
+
+var obj = {
+ 0: 12,
+ 1: 11
+};
+Object.defineProperty(obj, "length", {
+ set: function() {},
+ configurable: true
+});
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-13.js
new file mode 100644
index 0000000000..fdcedaf33f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-13.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to Array-like object that 'length'
+ is inherited accessor property without a get function
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+}
+
+var proto = {};
+Object.defineProperty(proto, "length", {
+ set: function() {},
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child[0] = 11;
+child[1] = 12;
+
+assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), 1, 'Array.prototype.reduce.call(child, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-14.js
new file mode 100644
index 0000000000..a399b536e7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-14.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to the Array-like object that
+ 'length' property doesn't exist
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-17.js
new file mode 100644
index 0000000000..db35b46d4d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-17.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to the Arguments object, which
+ implements its own property get method
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+var func = function(a, b) {
+ arguments[2] = 9;
+ return Array.prototype.reduce.call(arguments, callbackfn, 1);
+};
+
+assert.sameValue(func(12, 11), true, 'func(12, 11)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-18.js
new file mode 100644
index 0000000000..cf6c09d672
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-18.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to String object, which implements
+ its own property get method
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 3);
+}
+
+var str = new String("012");
+
+assert.sameValue(Array.prototype.reduce.call(str, callbackfn, 1), true, 'Array.prototype.reduce.call(str, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-19.js
new file mode 100644
index 0000000000..dd0066d782
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-19.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to Function object, which
+ implements its own property get method
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+var fun = function(a, b) {
+ return a + b;
+};
+fun[0] = 12;
+fun[1] = 11;
+fun[2] = 9;
+
+assert.sameValue(Array.prototype.reduce.call(fun, callbackfn, 1), true, 'Array.prototype.reduce.call(fun, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-2.js
new file mode 100644
index 0000000000..949641eda5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-2.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - 'length' is own data property on an Array
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+assert.sameValue([12, 11].reduce(callbackfn, 1), true, '[12, 11].reduce(callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-3.js
new file mode 100644
index 0000000000..6d4aed1c5e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-3.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is an own data property that
+ overrides an inherited data property on an Array-like object
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+var proto = {
+ length: 3
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 2;
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-4.js
new file mode 100644
index 0000000000..042b286c01
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-4.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is own data property that
+ overrides an inherited data property on an Array
+---*/
+
+var storeProtoLength;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+storeProtoLength = Array.prototype.length;
+Array.prototype.length = 0;
+
+assert.sameValue([12, 11].reduce(callbackfn, 1), true, '[12, 11].reduce(callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-5.js
new file mode 100644
index 0000000000..f2143fdd03
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-5.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to Array-like object, 'length' is
+ an own data property that overrides an inherited accessor property
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "length", {
+ get: function() {
+ return 3;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+Object.defineProperty(child, "length", {
+ value: 2,
+ configurable: true
+});
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-6.js
new file mode 100644
index 0000000000..9419869526
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-6.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to Array-like object, 'length' is
+ an inherited data property
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+var proto = {
+ length: 2
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-7.js
new file mode 100644
index 0000000000..fc1f9989f0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-7.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to Array-like object, 'length' is
+ an own accessor property
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ return 2;
+ },
+ configurable: true
+});
+
+obj[0] = 12;
+obj[1] = 11;
+obj[2] = 9;
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-8.js
new file mode 100644
index 0000000000..7f42726b4d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-8.js
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to Array-like object, 'length' is
+ an own accessor property that overrides an inherited data property
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+var proto = {
+ length: 3
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+
+Object.defineProperty(child, "length", {
+ get: function() {
+ return 2;
+ },
+ configurable: true
+});
+
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-9.js
new file mode 100644
index 0000000000..1d074a9b15
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-2-9.js
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce applied to Array-like object, 'length' is
+ an own accessor property that overrides an inherited accessor
+ property
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (obj.length === 2);
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "length", {
+ get: function() {
+ return 3;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+
+Object.defineProperty(child, "length", {
+ get: function() {
+ return 2;
+ },
+ configurable: true
+});
+
+child[0] = 12;
+child[1] = 11;
+child[2] = 9;
+
+assert.sameValue(Array.prototype.reduce.call(child, callbackfn, 1), true, 'Array.prototype.reduce.call(child, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-1.js
new file mode 100644
index 0000000000..2ec0cf620b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-1.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - value of 'length' is undefined
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return 2;
+}
+
+var obj = {
+ 0: 0,
+ 1: 1,
+ length: undefined
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-10.js
new file mode 100644
index 0000000000..a1804686f8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-10.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is number primitive
+ (value is NaN)
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return 2;
+}
+
+var obj = {
+ 0: 9,
+ length: NaN
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-11.js
new file mode 100644
index 0000000000..3cbf90142b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-11.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is a string containing a
+ positive number
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "2"
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-12.js
new file mode 100644
index 0000000000..ffe6c68194
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-12.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is a string containing a
+ negative number
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "-4294967294"
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-13.js
new file mode 100644
index 0000000000..7e1c114565
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-13.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is a string containing a decimal
+ number
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "2.5"
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-14.js
new file mode 100644
index 0000000000..d1499f13bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-14.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - 'length' is a string containing -Infinity
+---*/
+
+var accessed2 = false;
+
+function callbackfn2(prevVal, curVal, idx, obj) {
+ accessed2 = true;
+ return 2;
+}
+
+var obj2 = {
+ 0: 9,
+ length: "-Infinity"
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj2, callbackfn2, 1), 1, 'Array.prototype.reduce.call(obj2, callbackfn2, 1)');
+assert.sameValue(accessed2, false, 'accessed2');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-15.js
new file mode 100644
index 0000000000..b4c5e25ea6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-15.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is a string containing an
+ exponential number
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "2E0"
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-16.js
new file mode 100644
index 0000000000..7928a8df66
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-16.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is a string containing a hex
+ number
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "0x0002"
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-17.js
new file mode 100644
index 0000000000..1911ddb867
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-17.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is a string containing a number
+ with leading zeros
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: "0002.00"
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-18.js
new file mode 100644
index 0000000000..8b2401ca82
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-18.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is a string that can't
+ convert to a number
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return 2;
+}
+
+var obj = {
+ 0: 9,
+ length: "asdf!_"
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-19.js
new file mode 100644
index 0000000000..06f303dd40
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-19.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is an Object which has
+ an own toString method
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: {
+ toString: function() {
+ return '2';
+ }
+ }
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-2.js
new file mode 100644
index 0000000000..d06dfa1602
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-2.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is a boolean (value is
+ true)
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 0);
+}
+
+var obj = {
+ 0: 11,
+ 1: 9,
+ length: true
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-20.js
new file mode 100644
index 0000000000..32acae269e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-20.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is an object which has
+ an own valueOf method
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: {
+ valueOf: function() {
+ return 2;
+ }
+ }
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-21.js
new file mode 100644
index 0000000000..1b7b79d77d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-21.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'length' is an object that has an own
+ valueOf method that returns an object and toString method that
+ returns a string
+---*/
+
+var valueOfOccured = false;
+var toStringOccured = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: {
+ valueOf: function() {
+ valueOfOccured = true;
+ return {};
+ },
+ toString: function() {
+ toStringOccured = true;
+ return '2';
+ }
+ }
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert(valueOfOccured, 'valueOfOccured !== true');
+assert(toStringOccured, 'toStringOccured !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-22.js
new file mode 100644
index 0000000000..bc8c06a453
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-22.js
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError exception - 'length' is an
+ object with toString and valueOf methods that don�t return
+ primitive values
+---*/
+
+var accessed = false;
+var valueOfAccessed = false;
+var toStringAccessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return true;
+}
+
+var obj = {
+ 1: 11,
+ 2: 12,
+
+ length: {
+ valueOf: function() {
+ valueOfAccessed = true;
+ return {};
+ },
+ toString: function() {
+ toStringAccessed = true;
+ return {};
+ }
+ }
+};
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(obj, callbackfn, 1);
+});
+assert.sameValue(accessed, false, 'accessed');
+assert(toStringAccessed, 'toStringAccessed !== true');
+assert(valueOfAccessed, 'valueOfAccessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-23.js
new file mode 100644
index 0000000000..3080520795
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-23.js
@@ -0,0 +1,45 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce uses inherited valueOf method - 'length' is
+ an object with an own toString and inherited valueOf methods
+---*/
+
+var valueOfAccessed = false;
+var toStringAccessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var proto = {
+ valueOf: function() {
+ valueOfAccessed = true;
+ return 2;
+ }
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+
+child.toString = function() {
+ toStringAccessed = true;
+ return '1';
+};
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: child
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert(valueOfAccessed, 'valueOfAccessed !== true');
+assert.sameValue(toStringAccessed, false, 'toStringAccessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-24.js
new file mode 100644
index 0000000000..7c26c88bfd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-24.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is a positive
+ non-integer, ensure truncation occurs in the proper direction
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: 2.685
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-25.js
new file mode 100644
index 0000000000..8f78496005
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-25.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is a negative
+ non-integer
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: -4294967294.5
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-3.js
new file mode 100644
index 0000000000..9e21add920
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-3.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - value of 'length' is a number (value is 0)
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return 2;
+}
+
+var obj = {
+ 0: 1,
+ 1: 1,
+ length: 0
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-4.js
new file mode 100644
index 0000000000..fa4858f288
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-4.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is a number (value is
+ +0)
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return 2;
+}
+
+var obj = {
+ 0: 11,
+ length: +0
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-5.js
new file mode 100644
index 0000000000..27702d5054
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-5.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is a number (value is
+ -0)
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return 2;
+}
+
+var obj = {
+ 0: 11,
+ length: -0
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-6.js
new file mode 100644
index 0000000000..e9de26b232
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-6.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is a number (value is
+ positive)
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: 2
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), true, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-7.js
new file mode 100644
index 0000000000..1cd375b0e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-7.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is a number (value is
+ negative)
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal === 11 && idx === 1);
+}
+
+var obj = {
+ 1: 11,
+ 2: 9,
+ length: -4294967294
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-9.js
new file mode 100644
index 0000000000..adc4a1728c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-3-9.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'length' is a number (value is
+ -Infinity)
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+}
+
+var obj = {
+ 0: 9,
+ length: -Infinity
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 1), 1, 'Array.prototype.reduce.call(obj, callbackfn, 1)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-1.js
new file mode 100644
index 0000000000..138fd34848
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-1.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce throws TypeError if callbackfn is undefined
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.reduce();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js
new file mode 100644
index 0000000000..14b99fc322
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-10.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - the exception is not thrown if exception
+ was thrown by step 2
+---*/
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+});
+
+assert.throws(Test262Error, function() {
+ Array.prototype.reduce.call(obj, undefined);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js
new file mode 100644
index 0000000000..d073715f5a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-11.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - the exception is not thrown if exception
+ was thrown by step 3
+---*/
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ return {
+ toString: function() {
+ throw new Test262Error();
+ }
+ };
+ },
+ configurable: true
+});
+
+assert.throws(Test262Error, function() {
+ Array.prototype.reduce.call(obj, undefined);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-12.js
new file mode 100644
index 0000000000..9389b2b64c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-12.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - 'callbackfn' is a function
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return curVal > 10;
+}
+
+assert.sameValue([11, 9].reduce(callbackfn, 1), false, '[11, 9].reduce(callbackfn, 1)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-15.js
new file mode 100644
index 0000000000..4b4237e65d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-15.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - calling with no callbackfn is the same as
+ passing undefined for callbackfn
+---*/
+
+var obj = {
+ 10: 10
+};
+var lengthAccessed = false;
+var loopAccessed = false;
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ lengthAccessed = true;
+ return 20;
+ },
+ configurable: true
+});
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ loopAccessed = true;
+ return 10;
+ },
+ configurable: true
+});
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(obj);
+});
+assert(lengthAccessed, 'lengthAccessed !== true');
+assert.sameValue(loopAccessed, false, 'loopAccessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-2.js
new file mode 100644
index 0000000000..9bea9ce912
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-2.js
@@ -0,0 +1,16 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws ReferenceError if callbackfn is
+ unreferenced
+---*/
+
+var arr = new Array(10);
+assert.throws(ReferenceError, function() {
+ arr.reduce(foo);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-3.js
new file mode 100644
index 0000000000..b9232b42ed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-3.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce throws TypeError if callbackfn is null
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.reduce(null);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-4.js
new file mode 100644
index 0000000000..e0a4572124
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-4.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce throws TypeError if callbackfn is boolean
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.reduce(true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-5.js
new file mode 100644
index 0000000000..7fb3d394d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-5.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce throws TypeError if callbackfn is number
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.reduce(5);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-6.js
new file mode 100644
index 0000000000..7a47ca27b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-6.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce throws TypeError if callbackfn is string
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.reduce("abc");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-7.js
new file mode 100644
index 0000000000..57a4a96a02
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-7.js
@@ -0,0 +1,16 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError if callbackfn is Object
+ without [[Call]] internal method
+---*/
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.reduce(new Object());
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-8.js
new file mode 100644
index 0000000000..54061e6426
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-8.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - side effects produced by step 2 are
+ visible when an exception occurs
+---*/
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+var accessed = false;
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ accessed = true;
+ return 2;
+ },
+ configurable: true
+});
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(obj, null);
+});
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-9.js
new file mode 100644
index 0000000000..f5b1c92d75
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-4-9.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - side effects produced by step 3 are
+ visible when an exception occurs
+---*/
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+var accessed = false;
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ return {
+ toString: function() {
+ accessed = true;
+ return "2";
+ }
+ };
+ },
+ configurable: true
+});
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(obj, null);
+});
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-1.js
new file mode 100644
index 0000000000..c665eff2ab
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-1.js
@@ -0,0 +1,16 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError if 'length' is 0 (empty
+ array), no initVal
+---*/
+
+function cb() {}
+assert.throws(TypeError, function() {
+ [].reduce(cb);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-10.js
new file mode 100644
index 0000000000..d59f525060
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-10.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - if exception occurs, it occurs after any
+ side-effects that might be produced by step 2
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal > 10);
+}
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+var accessed = false;
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ accessed = true;
+ return 0;
+ },
+ configurable: true
+});
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(obj, callbackfn);
+});
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-11.js
new file mode 100644
index 0000000000..672956e033
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-11.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - if the exception occurs, it occurs after
+ any side-effects that might be produced by step 3
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal > 10);
+}
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+var accessed = false;
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ return {
+ toString: function() {
+ accessed = true;
+ return "0";
+ }
+ };
+ },
+ configurable: true
+});
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(obj, callbackfn);
+});
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js
new file mode 100644
index 0000000000..db3cb0f5d7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-12.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - the exception is not thrown if exception
+ was thrown by step 2
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal > 10);
+}
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+});
+
+assert.throws(Test262Error, function() {
+ Array.prototype.reduce.call(obj, callbackfn);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js
new file mode 100644
index 0000000000..20f6727d71
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-13.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - the exception is not thrown if exception
+ was thrown by step 3
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return (curVal > 10);
+}
+
+var obj = {
+ 0: 11,
+ 1: 12
+};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ return {
+ toString: function() {
+ throw new Test262Error();
+ }
+ };
+ },
+ configurable: true
+});
+
+assert.throws(Test262Error, function() {
+ Array.prototype.reduce.call(obj, callbackfn);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-2.js
new file mode 100644
index 0000000000..4f9fe2d884
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-2.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError if 'length' is 0
+ (subclassed Array, length overridden to null (type conversion)),
+ no initVal
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = null;
+
+function cb() {}
+assert.throws(TypeError, function() {
+ f.reduce(cb);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-3.js
new file mode 100644
index 0000000000..54fbaf0e0c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-3.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError if 'length' is 0
+ (subclassed Array, length overridden to false (type conversion)),
+ no initVal
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = false;
+
+function cb() {}
+assert.throws(TypeError, function() {
+ f.reduce(cb);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-4.js
new file mode 100644
index 0000000000..c1873c8b9f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-4.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError if 'length' is 0
+ (subclassed Array, length overridden to 0 (type conversion)), no
+ initVal
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = 0;
+
+function cb() {}
+assert.throws(TypeError, function() {
+ f.reduce(cb);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-5.js
new file mode 100644
index 0000000000..6ae8488fb8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-5.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError if 'length' is 0
+ (subclassed Array, length overridden to '0' (type conversion)), no
+ initVal
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = '0';
+
+function cb() {}
+assert.throws(TypeError, function() {
+ f.reduce(cb);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-6.js
new file mode 100644
index 0000000000..9dd7b8e094
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-6.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError if 'length' is 0
+ (subclassed Array, length overridden with obj with valueOf), no
+ initVal
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+var o = {
+ valueOf: function() {
+ return 0;
+ }
+};
+f.length = o;
+
+function cb() {}
+assert.throws(TypeError, function() {
+ f.reduce(cb);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-7.js
new file mode 100644
index 0000000000..b6777f6da2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-7.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError if 'length' is 0
+ (subclassed Array, length overridden with obj w/o valueOf
+ (toString)), no initVal
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+var o = {
+ toString: function() {
+ return '0';
+ }
+};
+f.length = o;
+
+// objects inherit the default valueOf method of the Object object;
+// that simply returns the itself. Since the default valueOf() method
+// does not return a primitive value, ES next tries to convert the object
+// to a number by calling its toString() method and converting the
+// resulting string to a number.
+
+function cb() {}
+assert.throws(TypeError, function() {
+ f.reduce(cb);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-8.js
new file mode 100644
index 0000000000..c49b1f8484
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-8.js
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError if 'length' is 0
+ (subclassed Array, length overridden with []), no initVal
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+f.length = [];
+
+// objects inherit the default valueOf method of the Object object;
+// that simply returns the itself. Since the default valueOf() method
+// does not return a primitive value, ES next tries to convert the object
+// to a number by calling its toString() method and converting the
+// resulting string to a number.
+//
+// The toString( ) method on Array converts the array elements to strings,
+// then returns the result of concatenating these strings, with commas in
+// between. An array with no elements converts to the empty string, which
+// converts to the number 0. If an array has a single element that is a
+// number n, the array converts to a string representation of n, which is
+// then converted back to n itself. If an array contains more than one element,
+// or if its one element is not a number, the array converts to NaN.
+
+function cb() {}
+assert.throws(TypeError, function() {
+ f.reduce(cb);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-9.js
new file mode 100644
index 0000000000..4b21500a96
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-5-9.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'initialValue' is returned if 'len' is 0
+ and 'initialValue' is present
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+}
+
+assert.sameValue([].reduce(callbackfn, 3), 3, '[].reduce(callbackfn, 3)');
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-1.js
new file mode 100644
index 0000000000..841d275bd8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-1.js
@@ -0,0 +1,14 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce returns initialValue if 'length' is 0 and
+ initialValue is present (empty array)
+---*/
+
+function cb() {}
+assert.sameValue([].reduce(cb, 1), 1, '[].reduce(cb,1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-10.js
new file mode 100644
index 0000000000..f21f2f1247
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-10.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - 'initialValue' is present
+---*/
+
+var str = "initialValue is present";
+
+assert.sameValue([].reduce(function() {}, str), str, '[].reduce(function () { }, str)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-11.js
new file mode 100644
index 0000000000..4e2a9f7495
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-11.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - 'initialValue' is not present
+---*/
+
+var str = "initialValue is not present";
+
+assert.sameValue([str].reduce(function() {}), str, '[str].reduce(function () { })');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-2.js
new file mode 100644
index 0000000000..6ecd4b1d9b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-2.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce returns initialValue if 'length' is 0 and
+ initialValue is present (subclassed Array, length overridden to
+ null (type conversion))
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = null;
+
+function cb() {}
+assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-3.js
new file mode 100644
index 0000000000..66e92ed670
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-3.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce returns initialValue if 'length' is 0 and
+ initialValue is present (subclassed Array, length overridden to
+ false (type conversion))
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = false;
+
+function cb() {}
+assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-4.js
new file mode 100644
index 0000000000..7100e153bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-4.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce returns initialValue if 'length' is 0 and
+ initialValue is present (subclassed Array, length overridden to 0
+ (type conversion))
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = 0;
+
+function cb() {}
+assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-5.js
new file mode 100644
index 0000000000..56027062b7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-5.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce returns initialValue if 'length' is 0 and
+ initialValue is present (subclassed Array, length overridden to
+ '0' (type conversion))
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+f.length = '0';
+
+function cb() {}
+assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-6.js
new file mode 100644
index 0000000000..b70cb41afb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-6.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce returns initialValue if 'length' is 0 and
+ initialValue is present (subclassed Array, length overridden with
+ obj with valueOf)
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+var o = {
+ valueOf: function() {
+ return 0;
+ }
+};
+f.length = o;
+
+function cb() {}
+assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js
new file mode 100644
index 0000000000..4b97710d3b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce returns initialValue if 'length' is 0 and
+ initialValue is present (subclassed Array, length overridden with
+ obj w/o valueOf (toString))
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+var o = {
+ toString: function() {
+ return '0';
+ }
+};
+f.length = o;
+
+// objects inherit the default valueOf method of the Object object;
+// that simply returns the itself. Since the default valueOf() method
+// does not return a primitive value, ES next tries to convert the object
+// to a number by calling its toString() method and converting the
+// resulting string to a number.
+
+function cb() {}
+assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-8.js
new file mode 100644
index 0000000000..f9ca7bb91e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-8.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce returns initialValue if 'length' is 0 and
+ initialValue is present (subclassed Array, length overridden with
+ [])
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+f.length = [];
+
+// objects inherit the default valueOf method of the Object object;
+// that simply returns the itself. Since the default valueOf() method
+// does not return a primitive value, ES next tries to convert the object
+// to a number by calling its toString() method and converting the
+// resulting string to a number.
+//
+// The toString( ) method on Array converts the array elements to strings,
+// then returns the result of concatenating these strings, with commas in
+// between. An array with no elements converts to the empty string, which
+// converts to the number 0. If an array has a single element that is a
+// number n, the array converts to a string representation of n, which is
+// then converted back to n itself. If an array contains more than one element,
+// or if its one element is not a number, the array converts to NaN.
+
+function cb() {}
+assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-9.js
new file mode 100644
index 0000000000..4df53a76ec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-7-9.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce returns initialValue if 'length' is 0 and
+ initialValue is present (subclassed Array, length overridden with
+ [0])
+---*/
+
+foo.prototype = new Array(1, 2, 3);
+
+function foo() {}
+var f = new foo();
+
+f.length = [0];
+
+// objects inherit the default valueOf method of the Object object;
+// that simply returns the itself. Since the default valueOf() method
+// does not return a primitive value, ES next tries to convert the object
+// to a number by calling its toString() method and converting the
+// resulting string to a number.
+//
+// The toString( ) method on Array converts the array elements to strings,
+// then returns the result of concatenating these strings, with commas in
+// between. An array with no elements converts to the empty string, which
+// converts to the number 0. If an array has a single element that is a
+// number n, the array converts to a string representation of n, which is
+// then converted back to n itself. If an array contains more than one element,
+// or if its one element is not a number, the array converts to NaN.
+
+function cb() {}
+assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js
new file mode 100644
index 0000000000..7c1604fef4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-1.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - no observable effects occur if 'len' is 0
+---*/
+
+var accessed = false;
+
+var obj = {
+ length: 0
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ accessed = true;
+ return 10;
+ },
+ configurable: true
+});
+
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(obj, function() {});
+});
+
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-2.js
new file mode 100644
index 0000000000..f53cc471bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-2.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - modifications to length don't change
+ number of iterations in step 9
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ return idx;
+}
+
+var obj = {
+ 3: 12,
+ 4: 9,
+ length: 4
+};
+
+Object.defineProperty(obj, "2", {
+ get: function() {
+ obj.length = 10;
+ return 11;
+ },
+ configurable: true
+});
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn), 3, 'Array.prototype.reduce.call(obj, callbackfn)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-3.js
new file mode 100644
index 0000000000..c55ae70d3a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-3.js
@@ -0,0 +1,45 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - loop is broken once 'kPresent' is true
+---*/
+
+var called = 0;
+var testResult = false;
+var firstCalled = 0;
+var secondCalled = 0;
+
+function callbackfn(prevVal, val, idx, obj) {
+ if (called === 0) {
+ testResult = (idx === 1);
+ }
+ called++;
+}
+
+var arr = [, , ];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ firstCalled++;
+ return 11;
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ secondCalled++;
+ return 9;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert.sameValue(firstCalled, 1, 'firstCalled');
+assert.sameValue(secondCalled, 1, 'secondCalled');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js
new file mode 100644
index 0000000000..6bc328baf5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - added properties in step 2 are visible
+ here
+---*/
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ obj[1] = "accumulator";
+ return 3;
+ },
+ configurable: true
+});
+
+assert.sameValue(Array.prototype.reduce.call(obj, function() {}), "accumulator", 'Array.prototype.reduce.call(obj, function () { })');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js
new file mode 100644
index 0000000000..735d8bf329
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleted properties in step 2 are visible
+ here
+---*/
+
+var obj = {
+ 1: "accumulator",
+ 2: "another"
+};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ delete obj[1];
+ return 3;
+ },
+ configurable: true
+});
+
+assert.notSameValue(Array.prototype.reduce.call(obj, function() {}), "accumulator", 'Array.prototype.reduce.call(obj, function () { })');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js
new file mode 100644
index 0000000000..cc6bba40cd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+var obj = {
+ 0: 0,
+ 1: 1,
+ 2: 2,
+ length: 2
+};
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js
new file mode 100644
index 0000000000..fab5c23ddf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - when element to be retrieved is own
+ accessor property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+var arr = [, 1, 2];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ return 0;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js
new file mode 100644
index 0000000000..f56f6cb024
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property that overrides an inherited data property on an
+ Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === "9");
+ }
+}
+
+var proto = {
+ 0: 0,
+ 1: 1,
+ 2: 2
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 3;
+
+Object.defineProperty(child, "0", {
+ get: function() {
+ return "9";
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js
new file mode 100644
index 0000000000..4e58b106d9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property that overrides an inherited data property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === "9");
+ }
+}
+
+Array.prototype[0] = 0;
+var arr = [, 1, 2];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ return "9";
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js
new file mode 100644
index 0000000000..928bdb2c49
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property that overrides an inherited accessor property on an
+ Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === "9");
+ }
+}
+
+var proto = {
+ 1: 1,
+ 2: 2
+};
+
+Object.defineProperty(proto, "0", {
+ get: function() {
+ return 0;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 3;
+
+Object.defineProperty(child, "0", {
+ get: function() {
+ return "9";
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js
new file mode 100644
index 0000000000..11c3c24f5c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property that overrides an inherited accessor property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === "9");
+ }
+}
+
+Object.defineProperty(Array.prototype, "0", {
+ get: function() {
+ return 0;
+ },
+ configurable: true
+});
+
+var arr = [, 1, 2];
+Object.defineProperty(arr, "0", {
+ get: function() {
+ return "9";
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js
new file mode 100644
index 0000000000..3a4d3abc0c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited
+ accessor property on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+var proto = {
+ 1: 1,
+ 2: 2
+};
+
+Object.defineProperty(proto, "0", {
+ get: function() {
+ return 0;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 3;
+
+Array.prototype.reduce.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js
new file mode 100644
index 0000000000..8d5a927e5c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited
+ accessor property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+Object.defineProperty(Array.prototype, "0", {
+ get: function() {
+ return 0;
+ },
+ configurable: true
+});
+
+var arr = [, 1, 2];
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js
new file mode 100644
index 0000000000..7317cde753
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property without a get function on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === undefined);
+ }
+}
+
+var obj = {
+ 1: 1,
+ 2: 2,
+ length: 3
+};
+
+Object.defineProperty(obj, "0", {
+ set: function() {},
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js
new file mode 100644
index 0000000000..ed6be4721b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property without a get function on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === undefined);
+ }
+}
+
+var arr = [, 1, 2];
+
+Object.defineProperty(arr, "0", {
+ set: function() {},
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js
new file mode 100644
index 0000000000..d9182b778d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property without a get function that overrides an inherited
+ accessor property on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === undefined);
+ }
+}
+
+Object.prototype[0] = 0;
+
+var obj = {
+ 1: 1,
+ 2: 2,
+ length: 3
+};
+
+Object.defineProperty(obj, "0", {
+ set: function() {},
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js
new file mode 100644
index 0000000000..f2ccbd2b59
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+var arr = [0, 1, 2];
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js
new file mode 100644
index 0000000000..03786c37da
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property without a get function that overrides an inherited
+ accessor property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === undefined);
+ }
+}
+
+Array.prototype[0] = 0;
+var arr = [, 1, 2];
+Object.defineProperty(arr, "0", {
+ set: function() {},
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js
new file mode 100644
index 0000000000..a28aa9ded6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited
+ accessor property without a get function on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === undefined);
+ }
+}
+
+var proto = {
+ 1: 1,
+ 2: 2
+};
+
+Object.defineProperty(proto, "0", {
+ set: function() {},
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 3;
+
+Array.prototype.reduce.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js
new file mode 100644
index 0000000000..9ab02ad487
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited
+ accessor property without a get function on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === undefined);
+ }
+}
+
+Object.defineProperty(Array.prototype, "0", {
+ set: function() {},
+ configurable: true
+});
+
+var arr = [, 1, 2];
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js
new file mode 100644
index 0000000000..fc0c264a5c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - This object is the Arguments object which
+ implements its own property get method (number of arguments is
+ less than number of parameters)
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+var func = function(a, b, c) {
+ Array.prototype.reduce.call(arguments, callbackfn);
+};
+
+func(0, 1);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js
new file mode 100644
index 0000000000..13645e0c23
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - This object is the Arguments object which
+ implements its own property get method (number of arguments equals
+ number of parameters)
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 2) {
+ testResult = (prevVal === 1);
+ }
+}
+
+var func = function(a, b, c) {
+ delete arguments[0];
+ Array.prototype.reduce.call(arguments, callbackfn);
+};
+
+func(0, 1, 2);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js
new file mode 100644
index 0000000000..2a674e5e2a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - This object is the Arguments object which
+ implements its own property get method (number of arguments is
+ greater than number of parameters)
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 3) {
+ testResult = (prevVal === 2);
+ }
+}
+
+var func = function(a, b, c) {
+ delete arguments[0];
+ delete arguments[1];
+ Array.prototype.reduce.call(arguments, callbackfn);
+};
+
+func(0, 1, 2, 3);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js
new file mode 100644
index 0000000000..3cdea44286
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - applied to String object, which
+ implements its own property get method
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === "0");
+ }
+}
+
+var str = new String("012");
+Array.prototype.reduce.call(str, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js
new file mode 100644
index 0000000000..6b4b9ccf9c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - applied to Function object which
+ implements its own property get method
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+var obj = function(a, b, c) {
+ return a + b + c;
+};
+obj[0] = 0;
+obj[1] = 1;
+obj[2] = 2;
+obj[3] = 3;
+
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js
new file mode 100644
index 0000000000..4250f525c7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property that overrides an inherited data property on an
+ Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === "9");
+ }
+}
+
+var proto = {
+ 0: 0,
+ 1: 1,
+ 2: 2,
+ length: 3
+};
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child[0] = "9";
+child[1] = "1";
+child.length = 3;
+
+Array.prototype.reduce.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js
new file mode 100644
index 0000000000..901d503f04
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js
@@ -0,0 +1,45 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element changed by getter on current
+ iterations is observed in subsequent iterations on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var arr = [, , 2];
+var preIterVisible = false;
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ preIterVisible = true;
+ return 0;
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ if (preIterVisible) {
+ return 1;
+ } else {
+ return 100;
+ }
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js
new file mode 100644
index 0000000000..acf21c758a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js
@@ -0,0 +1,48 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element changed by getter on current
+ iterations is observed in subsequent iterations on an Array-like
+ object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var obj = {
+ length: 2
+};
+var preIterVisible = false;
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ preIterVisible = true;
+ return 0;
+ },
+ configurable: true
+});
+
+Object.defineProperty(obj, "1", {
+ get: function() {
+ if (preIterVisible) {
+ return 1;
+ } else {
+ return 100;
+ }
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js
new file mode 100644
index 0000000000..683b42c417
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - exception in getter terminates iteration
+ on an Array-like object
+---*/
+
+var accessed = false;
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx >= 1) {
+ accessed = true;
+ testResult = (prevVal === 0);
+ }
+}
+
+var obj = {
+ 2: 2,
+ 1: 1,
+ length: 3
+};
+Object.defineProperty(obj, "0", {
+ get: function() {
+ throw new RangeError("unhandle exception happened in getter");
+ },
+ configurable: true
+});
+assert.throws(RangeError, function() {
+ Array.prototype.reduce.call(obj, callbackfn);
+});
+assert.sameValue(accessed, false, 'accessed');
+assert.sameValue(testResult, false, 'testResult');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js
new file mode 100644
index 0000000000..bdb2286cd6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - exception in getter terminates iteration
+ on an Array
+---*/
+
+var accessed = false;
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx >= 1) {
+ accessed = true;
+ testResult = (prevVal === 0);
+ }
+}
+
+var arr = [, 1, 2];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ throw new RangeError("unhandle exception happened in getter");
+ },
+ configurable: true
+});
+assert.throws(RangeError, function() {
+ arr.reduce(callbackfn);
+});
+assert.sameValue(accessed, false, 'accessed');
+assert.sameValue(testResult, false, 'testResult');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js
new file mode 100644
index 0000000000..43dc373a3d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property that overrides an inherited data property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+Array.prototype[0] = "9";
+[0, 1, 2].reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js
new file mode 100644
index 0000000000..d14d46865c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property that overrides an inherited accessor property on an
+ Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === "9");
+ }
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "0", {
+ get: function() {
+ return 0;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 2;
+Object.defineProperty(child, "0", {
+ value: "9",
+ configurable: true
+});
+child[1] = "1";
+
+Array.prototype.reduce.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js
new file mode 100644
index 0000000000..7ee7621226
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property that overrides an inherited accessor property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+Object.defineProperty(Array.prototype, "0", {
+ get: function() {
+ return "5";
+ },
+ configurable: true
+});
+
+[0, 1, 2].reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js
new file mode 100644
index 0000000000..2ec2ee0b38
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited data
+ property on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+var proto = {
+ 0: 0,
+ 1: 1,
+ 2: 2,
+ length: 3
+};
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 3;
+
+Array.prototype.reduce.call(child, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js
new file mode 100644
index 0000000000..af606108f7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited data
+ property on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+Array.prototype[0] = 0;
+Array.prototype[1] = 1;
+Array.prototype[2] = 2;
+[, , , ].reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js
new file mode 100644
index 0000000000..1fd31f3566
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (prevVal === 0);
+ }
+}
+
+var obj = {
+ 1: 1,
+ 2: 2,
+ length: 3
+};
+Object.defineProperty(obj, "0", {
+ get: function() {
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-1.js
new file mode 100644
index 0000000000..0fced6464d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-1.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError when Array is empty and
+ initialValue is not present
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{}
+
+var arr = new Array(10);
+assert.throws(TypeError, function() {
+ arr.reduce(callbackfn);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-2.js
new file mode 100644
index 0000000000..f16665bf36
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-2.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError when elements assigned
+ values are deleted by reducing array length and initialValue is
+ not present
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{}
+
+var arr = new Array(10);
+arr[9] = 1;
+arr.length = 5;
+assert.throws(TypeError, function() {
+ arr.reduce(callbackfn);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-3.js
new file mode 100644
index 0000000000..e112cf748e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-3.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce throws TypeError when elements assigned
+ values are deleted and initialValue is not present
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{}
+
+var arr = [1, 2, 3, 4, 5];
+delete arr[0];
+delete arr[1];
+delete arr[2];
+delete arr[3];
+delete arr[4];
+assert.throws(TypeError, function() {
+ arr.reduce(callbackfn);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js
new file mode 100644
index 0000000000..432919dc10
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-4.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce doesn't throw error when array has no own
+ properties but prototype contains a single property
+---*/
+
+var arr = [, , , ];
+
+try {
+ Array.prototype[1] = "prototype";
+ arr.reduce(function() {});
+} finally {
+ delete Array.prototype[1];
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-5.js
new file mode 100644
index 0000000000..a45a73094b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-5.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - if exception occurs, it occurs after any
+ side-effects that might be produced by step 2
+---*/
+
+var obj = {};
+
+var accessed = false;
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ accessed = true;
+ return 2;
+ },
+ configurable: true
+});
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(obj, function() {});
+});
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-6.js
new file mode 100644
index 0000000000..446552144b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-6.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - if exception occurs, it occurs after any
+ side-effects that might be produced by step 3
+---*/
+
+var obj = {};
+
+var accessed = false;
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ return {
+ toString: function() {
+ accessed = true;
+ return "2";
+ }
+ };
+ },
+ configurable: true
+});
+assert.throws(TypeError, function() {
+ Array.prototype.reduce.call(obj, function() {});
+});
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js
new file mode 100644
index 0000000000..4716787468
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-7.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - the exception is not thrown if exception
+ was thrown by step 2
+---*/
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+});
+
+assert.throws(Test262Error, function() {
+ Array.prototype.reduce.call(obj, function() {});
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js
new file mode 100644
index 0000000000..15d23e11b9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-8-c-8.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - the exception is not thrown if exception
+ was thrown by step 3
+---*/
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ return {
+ toString: function() {
+ throw new Test262Error();
+ }
+ };
+ },
+ configurable: true
+});
+
+assert.throws(Test262Error, function() {
+ Array.prototype.reduce.call(obj, function() {});
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-1.js
new file mode 100644
index 0000000000..3e8387e96a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-1.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce doesn't consider new elements added to
+ array after it is called
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ arr[5] = 6;
+ arr[2] = 3;
+ return prevVal + curVal;
+}
+
+var arr = [1, 2, , 4, '5'];
+
+assert.sameValue(arr.reduce(callbackfn), "105", 'arr.reduce(callbackfn)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-10.js
new file mode 100644
index 0000000000..d9b5928953
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-10.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce called with an initial value doesn't
+ consider new elements added to array after it is called
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ arr[5] = 6;
+ arr[2] = 3;
+ return prevVal + curVal;
+}
+
+var arr = [1, 2, , 4, '5'];
+
+assert.sameValue(arr.reduce(callbackfn, ""), "12345", 'arr.reduce(callbackfn, "")');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-2.js
new file mode 100644
index 0000000000..ae74f029a7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-2.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce considers new value of elements in array
+ after it is called
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ arr[3] = -2;
+ arr[4] = -1;
+ return prevVal + curVal;
+}
+
+var arr = [1, 2, 3, 4, 5];
+
+assert.sameValue(arr.reduce(callbackfn), 3, 'arr.reduce(callbackfn)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js
new file mode 100644
index 0000000000..d83ac8f89d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-3.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce doesn't visit deleted elements in array
+ after the call
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ delete arr[3];
+ delete arr[4];
+ return prevVal + curVal;
+}
+
+var arr = ['1', 2, 3, 4, 5];
+
+// two elements deleted
+assert.sameValue(arr.reduce(callbackfn), "123", 'arr.reduce(callbackfn)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-4.js
new file mode 100644
index 0000000000..3a3e10d2df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-4.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce doesn't visit deleted elements when
+ Array.length is decreased
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ arr.length = 2;
+ return prevVal + curVal;
+}
+
+var arr = [1, 2, 3, 4, 5];
+
+assert.sameValue(arr.reduce(callbackfn), 3, 'arr.reduce(callbackfn)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-5.js
new file mode 100644
index 0000000000..20255d50cd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-5.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - callbackfn not called for array with one
+ element
+---*/
+
+var callCnt = 0;
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ callCnt++;
+ return 2;
+}
+
+var arr = [1];
+
+assert.sameValue(arr.reduce(callbackfn), 1, 'arr.reduce(callbackfn)');
+assert.sameValue(callCnt, 0, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js
new file mode 100644
index 0000000000..635d08b6e5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-6.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce visits deleted element in array after the
+ call when same index is also present in prototype
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ delete arr[3];
+ delete arr[4];
+ return prevVal + curVal;
+}
+
+Array.prototype[4] = 5;
+var arr = ['1', 2, 3, 4, 5];
+var res = arr.reduce(callbackfn);
+delete Array.prototype[4];
+
+//one element acually deleted
+assert.sameValue(res, "1235", 'res');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-7.js
new file mode 100644
index 0000000000..658bc8a8bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-7.js
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce stops calling callbackfn once the array is
+ deleted during the call
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ delete o.arr;
+ return prevVal + curVal;
+}
+
+var o = new Object();
+o.arr = ['1', 2, 3, 4, 5];
+
+assert.sameValue(o.arr.reduce(callbackfn), "12345", 'o.arr.reduce(callbackfn)');
+assert.sameValue(o.hasOwnProperty("arr"), false, 'o.hasOwnProperty("arr")');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-8.js
new file mode 100644
index 0000000000..bfee2b4417
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-8.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - no observable effects occur if 'len' is 0
+---*/
+
+var accessed = false;
+var callbackAccessed = false;
+
+function callbackfn() {
+ callbackAccessed = true;
+}
+
+var obj = {
+ length: 0
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ accessed = true;
+ return 10;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn, "initialValue");
+
+assert.sameValue(accessed, false, 'accessed');
+assert.sameValue(callbackAccessed, false, 'callbackAccessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-9.js
new file mode 100644
index 0000000000..9d6ce4d023
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-9.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - modifications to length don't change
+ number of iterations in step 9
+---*/
+
+var called = 0;
+
+function callbackfn(accum, val, idx, obj) {
+ called++;
+ return accum + val;
+}
+
+var arr = [0, 1, 2, 3];
+Object.defineProperty(arr, "0", {
+ get: function() {
+ arr.length = 2;
+ return 0;
+ },
+ configurable: true
+});
+
+var newAccum = arr.reduce(callbackfn, "initialValue");
+
+assert.sameValue(newAccum, "initialValue01", 'newAccum');
+assert.sameValue(called, 2, 'called');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-1.js
new file mode 100644
index 0000000000..44157ae461
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-1.js
@@ -0,0 +1,18 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce returns initialvalue when Array is empty
+ and initialValue is present
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{}
+
+var arr = new Array(10);
+
+assert.sameValue(arr.reduce(callbackfn, 5), 5, 'arr.reduce(callbackfn,5)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-10.js
new file mode 100644
index 0000000000..60a6f7769a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-10.js
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting property of prototype in step 8
+ causes deleted index property not to be visited on an Array-like
+ Object
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 3) {
+ testResult = false;
+ }
+}
+
+var obj = {
+ 2: 2,
+ length: 20
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ delete Object.prototype[3];
+ return 0;
+ },
+ configurable: true
+});
+
+Object.prototype[3] = 1;
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-11.js
new file mode 100644
index 0000000000..b156e88812
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-11.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting property of prototype in step 8
+ causes deleted index property not to be visited on an Array
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 1) {
+ testResult = false;
+ }
+}
+
+var arr = [, , , 3];
+Object.defineProperty(arr, "0", {
+ get: function() {
+ delete Array.prototype[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype[1] = 1;
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-12.js
new file mode 100644
index 0000000000..e3e9450048
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-12.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting own property with prototype
+ property in step 8 causes prototype index property to be visited
+ on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 1 && val === 1) {
+ testResult = true;
+ }
+}
+
+var obj = {
+ 0: 0,
+ 1: 111,
+ 4: 10,
+ length: 10
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ delete obj[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Object.prototype[1] = 1;
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-13.js
new file mode 100644
index 0000000000..a5d1456e2f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-13.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting own property with prototype
+ property in step 8 causes prototype index property to be visited
+ on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 1 && val === 1) {
+ testResult = true;
+ }
+}
+var arr = [0, 111];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ delete arr[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype[1] = 1;
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-14.js
new file mode 100644
index 0000000000..edbd8ad8b9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-14.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - decreasing length of array in step 8
+ causes deleted index property not to be visited
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 2) {
+ testResult = false;
+ }
+}
+
+var arr = [0, 1, 2, 3];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ arr.length = 2;
+ return 0;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-15.js
new file mode 100644
index 0000000000..c34e872187
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-15.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - decreasing length of array with prototype
+ property in step 8 causes prototype index property to be visited
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 2 && val === "prototype") {
+ testResult = true;
+ }
+}
+var arr = [0, 1, 2, 3];
+
+Object.defineProperty(Array.prototype, "2", {
+ get: function() {
+ return "prototype";
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ arr.length = 2;
+ return 1;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-16.js
new file mode 100644
index 0000000000..ec284d7ce6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-16.js
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - decreasing length of array in step 8 does
+ not delete non-configurable properties
+flags: [noStrict]
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 2 && val === "unconfigurable") {
+ testResult = true;
+ }
+}
+
+var arr = [0, 1, 2, 3];
+
+Object.defineProperty(arr, "2", {
+ get: function() {
+ return "unconfigurable";
+ },
+ configurable: false
+});
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ arr.length = 2;
+ return 1;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-17.js
new file mode 100644
index 0000000000..a498629a11
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-17.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - properties added into own object are
+ visited on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 3 && val === 3) {
+ testResult = true;
+ }
+}
+
+var obj = {
+ length: 5
+};
+
+Object.defineProperty(obj, "1", {
+ get: function() {
+ Object.defineProperty(obj, "3", {
+ get: function() {
+ return 3;
+ },
+ configurable: true
+ });
+ return 1;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-18.js
new file mode 100644
index 0000000000..3071d8509d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-18.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - properties added into own object are
+ visited on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 1 && val === 1) {
+ testResult = true;
+ }
+}
+
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ Object.defineProperty(arr, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+ });
+ return 0;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-19.js
new file mode 100644
index 0000000000..3fc99ff400
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-19.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - properties added to prototype are visited
+ on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 1 && val === 6.99) {
+ testResult = true;
+ }
+}
+
+var obj = {
+ length: 6
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ Object.defineProperty(Object.prototype, "1", {
+ get: function() {
+ return 6.99;
+ },
+ configurable: true
+ });
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-2.js
new file mode 100644
index 0000000000..2d19d3bb2f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-2.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - added properties in step 2 are visible
+ here
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 2 && val === "2") {
+ testResult = true;
+ }
+}
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ obj[2] = "2";
+ return 3;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-20.js
new file mode 100644
index 0000000000..11593423e1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-20.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - properties can be added to prototype are
+ visited on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 1 && val === 6.99) {
+ testResult = true;
+ }
+}
+
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ Object.defineProperty(Array.prototype, "1", {
+ get: function() {
+ return 6.99;
+ },
+ configurable: true
+ });
+ return 0;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-21.js
new file mode 100644
index 0000000000..42099d8cad
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-21.js
@@ -0,0 +1,46 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting own property causes deleted
+ index property not to be visited on an Array-like object
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 1) {
+ testResult = false;
+ }
+}
+
+var obj = {
+ 5: 10,
+ length: 10
+};
+
+Object.defineProperty(obj, "1", {
+ get: function() {
+ return 6.99;
+ },
+ configurable: true
+});
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ delete obj[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-22.js
new file mode 100644
index 0000000000..7967244ed9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-22.js
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting own property causes deleted
+ index property not to be visited on an Array
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 1) {
+ testResult = false;
+ }
+}
+
+var arr = [1, 2, 4];
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ return "6.99";
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ delete arr[1];
+ return 0;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-23.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-23.js
new file mode 100644
index 0000000000..2bff04ecb3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-23.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting property of prototype causes
+ deleted index property not to be visited on an Array-like Object
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 3) {
+ testResult = false;
+ }
+}
+
+var obj = {
+ 2: 2,
+ length: 20
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ delete Object.prototype[3];
+ return 0;
+ },
+ configurable: true
+});
+
+Object.prototype[3] = 1;
+Array.prototype.reduce.call(obj, callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-24.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-24.js
new file mode 100644
index 0000000000..8c6f24ae3c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-24.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting property of prototype causes
+ deleted index property not to be visited on an Array
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 1) {
+ testResult = false;
+ }
+}
+
+var arr = [0, , , 3];
+Object.defineProperty(arr, "0", {
+ get: function() {
+ delete Array.prototype[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype[1] = 1;
+arr.reduce(callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-25.js
new file mode 100644
index 0000000000..7d5a359b7b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-25.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting own property with prototype
+ property causes prototype index property to be visited on an
+ Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 1 && val === 1) {
+ testResult = true;
+ }
+}
+
+var obj = {
+ 0: 0,
+ 1: 111,
+ 4: 10,
+ length: 10
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ delete obj[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Object.prototype[1] = 1;
+Array.prototype.reduce.call(obj, callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-26.js
new file mode 100644
index 0000000000..a0939b0528
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-26.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting own property with prototype
+ property causes prototype index property to be visited on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 1 && val === 1) {
+ testResult = true;
+ }
+}
+var arr = [0, 111];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ delete arr[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype[1] = 1;
+arr.reduce(callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-27.js
new file mode 100644
index 0000000000..81d71e0551
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-27.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - decreasing length of array causes deleted
+ index property not to be visited
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 2) {
+ testResult = false;
+ }
+}
+
+var arr = [0, 1, 2, 3];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ arr.length = 2;
+ return 0;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-28.js
new file mode 100644
index 0000000000..c382d3c049
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-28.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - decreasing length of array with prototype
+ property causes prototype index property to be visited
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 2 && val === "prototype") {
+ testResult = true;
+ }
+}
+var arr = [0, 1, 2, 3];
+
+Object.defineProperty(Array.prototype, "2", {
+ get: function() {
+ return "prototype";
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ arr.length = 2;
+ return 1;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-29.js
new file mode 100644
index 0000000000..bb036b1942
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-29.js
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - decreasing length of array does not
+ delete non-configurable properties
+flags: [noStrict]
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 2 && val === "unconfigurable") {
+ testResult = true;
+ }
+}
+
+var arr = [0, 1, 2, 3];
+
+Object.defineProperty(arr, "2", {
+ get: function() {
+ return "unconfigurable";
+ },
+ configurable: false
+});
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ arr.length = 2;
+ return 1;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn, "initialValue");
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-3.js
new file mode 100644
index 0000000000..d2b61c380b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-3.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleted properties in step 2 are visible
+ here
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 2) {
+ testResult = false;
+ }
+}
+
+var obj = {
+ 2: "2",
+ 3: 10
+};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ delete obj[2];
+ return 5;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn, "initialValue");
+
+assert(accessed, 'accessed !== true');
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-4.js
new file mode 100644
index 0000000000..11e541c5ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-4.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - properties added into own object in step
+ 8 are visited on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 3 && val === 3) {
+ testResult = true;
+ }
+}
+
+var obj = {
+ length: 5
+};
+
+Object.defineProperty(obj, "1", {
+ get: function() {
+ Object.defineProperty(obj, "3", {
+ get: function() {
+ return 3;
+ },
+ configurable: true
+ });
+ return 1;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-5.js
new file mode 100644
index 0000000000..c909df54cf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-5.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - properties added into own object in step
+ 8 are visited on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 1 && val === 1) {
+ testResult = true;
+ }
+}
+
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ Object.defineProperty(arr, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+ });
+ return 0;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-6.js
new file mode 100644
index 0000000000..80a02f023d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-6.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - properties added to prototype in step 8
+ are visited on an Array-like object
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 1 && val === 6.99) {
+ testResult = true;
+ }
+}
+
+var obj = {
+ length: 6
+};
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ Object.defineProperty(Object.prototype, "1", {
+ get: function() {
+ return 6.99;
+ },
+ configurable: true
+ });
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-7.js
new file mode 100644
index 0000000000..5f31131b59
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-7.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - properties added to prototype in step 8
+ are visited on an Array
+---*/
+
+var testResult = false;
+
+function callbackfn(accum, val, idx, obj) {
+ if (idx === 1 && val === 6.99) {
+ testResult = true;
+ }
+}
+
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ Object.defineProperty(Array.prototype, "1", {
+ get: function() {
+ return 6.99;
+ },
+ configurable: true
+ });
+ return 0;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-8.js
new file mode 100644
index 0000000000..91ca865f39
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-8.js
@@ -0,0 +1,46 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting own property in step 8 causes
+ deleted index property not to be visited on an Array-like object
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 1) {
+ testResult = false;
+ }
+}
+
+var obj = {
+ 5: 10,
+ length: 10
+};
+
+Object.defineProperty(obj, "1", {
+ get: function() {
+ return 6.99;
+ },
+ configurable: true
+});
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ delete obj[1];
+ return 0;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-9.js
new file mode 100644
index 0000000000..9ccd019873
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-b-9.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - deleting own property in step 8 causes
+ deleted index property not to be visited on an Array
+---*/
+
+var accessed = false;
+var testResult = true;
+
+function callbackfn(accum, val, idx, obj) {
+ accessed = true;
+ if (idx === 1) {
+ testResult = false;
+ }
+}
+
+var arr = [1, 2, 4];
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ delete arr[1];
+ return 0;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn);
+
+assert(testResult, 'testResult !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-1.js
new file mode 100644
index 0000000000..749f146c19
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-1.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - callbackfn not called for indexes never
+ been assigned values
+---*/
+
+var callCnt = 0;
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ callCnt++;
+ return curVal;
+}
+
+var arr = new Array(10);
+arr[0] = arr[1] = undefined; //explicitly assigning a value
+
+assert.sameValue(arr.reduce(callbackfn), undefined, 'arr.reduce(callbackfn)');
+assert.sameValue(callCnt, 1, 'callCnt');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js
new file mode 100644
index 0000000000..e7639b790b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property on an Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var obj = {
+ 0: 0,
+ 1: 1,
+ 2: 2,
+ length: 2
+};
+Array.prototype.reduce.call(obj, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js
new file mode 100644
index 0000000000..4c7c666a42
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js
new file mode 100644
index 0000000000..d188f7d158
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property that overrides an inherited data property on an
+ Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === "11");
+ }
+}
+
+var proto = {
+ 0: 0,
+ 1: 1,
+ 2: 2
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 3;
+
+Object.defineProperty(child, "1", {
+ get: function() {
+ return "11";
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(child, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js
new file mode 100644
index 0000000000..325721cdb3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property that overrides an inherited data property on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === "11");
+ }
+}
+
+Array.prototype[1] = 1;
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ return "11";
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js
new file mode 100644
index 0000000000..3eed9913f7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property that overrides an inherited accessor property on an
+ Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === "11");
+ }
+}
+
+var proto = {
+ 0: 0,
+ 2: 2
+};
+
+Object.defineProperty(proto, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 3;
+
+Object.defineProperty(child, "1", {
+ get: function() {
+ return "11";
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(child, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js
new file mode 100644
index 0000000000..ccf3277480
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property that overrides an inherited accessor property on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === "11");
+ }
+}
+
+Object.defineProperty(Array.prototype, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+});
+
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ return "11";
+ },
+ configurable: true
+});
+arr.reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js
new file mode 100644
index 0000000000..9d3c2e3eea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js
@@ -0,0 +1,42 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited
+ accessor property on an Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var proto = {
+ 0: 0,
+ 2: 2
+};
+
+Object.defineProperty(proto, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 3;
+
+Array.prototype.reduce.call(child, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js
new file mode 100644
index 0000000000..611db7802a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited
+ accessor property on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+Object.defineProperty(Array.prototype, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+});
+
+var arr = [0, , 2, ];
+
+arr.reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js
new file mode 100644
index 0000000000..720b3fa366
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property without a get function on an Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === undefined);
+ }
+}
+
+var obj = {
+ 0: 0,
+ 2: 2,
+ length: 3
+};
+
+Object.defineProperty(obj, "1", {
+ set: function() {},
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js
new file mode 100644
index 0000000000..2c2018cafc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property without a get function on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === undefined);
+ }
+}
+
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "1", {
+ set: function() {},
+ configurable: true
+});
+
+arr.reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js
new file mode 100644
index 0000000000..aa81d7149c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property without a get function that overrides an inherited
+ accessor property on an Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === undefined);
+ }
+}
+
+Object.defineProperty(Object.prototype, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+});
+
+var obj = {
+ 0: 0,
+ 2: 2,
+ length: 3
+};
+
+Object.defineProperty(obj, "1", {
+ set: function() {},
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js
new file mode 100644
index 0000000000..2ae2989b74
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var arr = [0, 1];
+arr.reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js
new file mode 100644
index 0000000000..5268899bc3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property without a get function that overrides an inherited
+ accessor property on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === undefined);
+ }
+}
+
+Object.defineProperty(Array.prototype, "1", {
+ get: function() {
+ return 11;
+ },
+ configurable: true
+});
+
+var arr = [0, , 2];
+Object.defineProperty(arr, "1", {
+ set: function() {},
+ configurable: true
+});
+
+arr.reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js
new file mode 100644
index 0000000000..e8bdb0bc83
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited
+ accessor property without a get function on an Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === undefined);
+ }
+}
+
+var proto = {
+ 0: 0,
+ 2: 2
+};
+
+Object.defineProperty(proto, "1", {
+ set: function() {},
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 3;
+
+Array.prototype.reduce.call(child, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js
new file mode 100644
index 0000000000..d6c37f0def
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited
+ accessor property without a get function on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === undefined);
+ }
+}
+
+Object.defineProperty(Array.prototype, "1", {
+ set: function() {},
+ configurable: true
+});
+
+var arr = [0, , 2];
+
+arr.reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js
new file mode 100644
index 0000000000..cf14798787
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - This object is the Arguments object which
+ implements its own property get method (number of arguments is
+ less than number of parameters)
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var func = function(a, b, c) {
+ Array.prototype.reduce.call(arguments, callbackfn, initialValue);
+};
+
+func(0, 1);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js
new file mode 100644
index 0000000000..790beb9588
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - This object is the Arguments object which
+ implements its own property get method (number of arguments equals
+ number of parameters)
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 2) {
+ testResult = (curVal === 2);
+ }
+}
+
+var func = function(a, b, c) {
+ Array.prototype.reduce.call(arguments, callbackfn, initialValue);
+};
+
+func(0, 1, 2);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js
new file mode 100644
index 0000000000..59cd5addbc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - This object is the Arguments object which
+ implements its own property get method (number of arguments is
+ greater than number of parameters)
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 3) {
+ testResult = (curVal === 3);
+ }
+}
+
+var func = function(a, b, c) {
+ Array.prototype.reduce.call(arguments, callbackfn, initialValue);
+};
+
+func(0, 1, 2, 3);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js
new file mode 100644
index 0000000000..8be9460f76
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - applied to String object, which
+ implements its own property get method
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === "1");
+ }
+}
+
+var str = new String("012");
+
+Array.prototype.reduce.call(str, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js
new file mode 100644
index 0000000000..8f9873722d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - applied to Function object which
+ implements its own property get method
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var obj = function(a, b, c) {
+ return a + b + c;
+};
+obj[0] = 0;
+obj[1] = 1;
+obj[2] = 2;
+obj[3] = 3;
+
+Array.prototype.reduce.call(obj, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js
new file mode 100644
index 0000000000..569a310e2d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property that overrides an inherited data property on an
+ Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === "11");
+ }
+}
+
+var proto = {
+ 0: 0,
+ 1: 1,
+ 2: 2,
+ length: 2
+};
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child[1] = "11";
+child[2] = "22";
+child.length = 3;
+
+Array.prototype.reduce.call(child, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js
new file mode 100644
index 0000000000..1380973eb6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js
@@ -0,0 +1,46 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element changed by getter on previous
+ iterations is observed on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var arr = [, , 2];
+var preIterVisible = false;
+
+Object.defineProperty(arr, "0", {
+ get: function() {
+ preIterVisible = true;
+ return 0;
+ },
+ configurable: true
+});
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ if (preIterVisible) {
+ return 1;
+ } else {
+ return 100;
+ }
+ },
+ configurable: true
+});
+
+arr.reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js
new file mode 100644
index 0000000000..7853d46bb7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element changed by getter on previous
+ iterations is observed on an Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var obj = {
+ 2: 2,
+ length: 3
+};
+var preIterVisible = false;
+
+Object.defineProperty(obj, "0", {
+ get: function() {
+ preIterVisible = true;
+ return 0;
+ },
+ configurable: true
+});
+
+Object.defineProperty(obj, "1", {
+ get: function() {
+ if (preIterVisible) {
+ return 1;
+ } else {
+ return "11";
+ }
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js
new file mode 100644
index 0000000000..7d676d5d01
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - unnhandled exceptions happened in getter
+ terminate iteration on an Array-like object
+---*/
+
+var accessed = false;
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx >= 1) {
+ accessed = true;
+ testResult = (curVal >= 1);
+ }
+}
+
+var obj = {
+ 0: 0,
+ 2: 2,
+ length: 3
+};
+Object.defineProperty(obj, "1", {
+ get: function() {
+ throw new RangeError("unhandle exception happened in getter");
+ },
+ configurable: true
+});
+assert.throws(RangeError, function() {
+ Array.prototype.reduce.call(obj, callbackfn, initialValue);
+});
+assert.sameValue(accessed, false, 'accessed');
+assert.sameValue(testResult, false, 'testResult');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js
new file mode 100644
index 0000000000..0e7cc93359
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - unnhandled exceptions happened in getter
+ terminate iteration on an Array
+---*/
+
+var accessed = false;
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx >= 1) {
+ accessed = true;
+ testResult = (curVal >= 1);
+ }
+}
+
+var arr = [0, , 2];
+
+Object.defineProperty(arr, "1", {
+ get: function() {
+ throw new RangeError("unhandle exception happened in getter");
+ },
+ configurable: true
+});
+assert.throws(RangeError, function() {
+ arr.reduce(callbackfn, initialValue);
+});
+assert.sameValue(accessed, false, 'accessed');
+assert.sameValue(testResult, false, 'testResult');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js
new file mode 100644
index 0000000000..a50f6085f1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property that overrides an inherited data property on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+Array.prototype[1] = "3";
+[0, 1, 2].reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js
new file mode 100644
index 0000000000..c6fbbd7b9a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property that overrides an inherited accessor property on an
+ Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 0) {
+ testResult = (curVal === "9");
+ }
+}
+
+var proto = {};
+
+Object.defineProperty(proto, "0", {
+ get: function() {
+ return 0;
+ },
+ configurable: true
+});
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 2;
+
+Object.defineProperty(child, "0", {
+ value: "9",
+ configurable: true
+});
+
+child[1] = "1";
+
+Array.prototype.reduce.call(child, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js
new file mode 100644
index 0000000000..804f3abf62
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own data
+ property that overrides an inherited accessor property on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+Object.defineProperty(Array.prototype, "1", {
+ get: function() {
+ return "9";
+ },
+ configurable: true
+});
+[0, 1, 2].reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js
new file mode 100644
index 0000000000..fcab20dd03
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited data
+ property on an Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var proto = {
+ 0: 0,
+ 1: 1,
+ 2: 2,
+ length: 3
+};
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.length = 3;
+
+Array.prototype.reduce.call(child, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js
new file mode 100644
index 0000000000..643caa660c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is inherited data
+ property on an Array
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+Array.prototype[0] = 0;
+Array.prototype[1] = 1;
+Array.prototype[2] = 2;
+[, , , ].reduce(callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js
new file mode 100644
index 0000000000..015237b068
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element to be retrieved is own accessor
+ property on an Array-like object
+---*/
+
+var testResult = false;
+var initialValue = 0;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 1) {
+ testResult = (curVal === 1);
+ }
+}
+
+var obj = {
+ 0: 0,
+ 2: 2,
+ length: 3
+};
+Object.defineProperty(obj, "1", {
+ get: function() {
+ return 1;
+ },
+ configurable: true
+});
+
+Array.prototype.reduce.call(obj, callbackfn, initialValue);
+
+assert(testResult, 'testResult !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js
new file mode 100644
index 0000000000..01a67c6ee7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - callbackfn called with correct parameters
+ (initialvalue not passed)
+---*/
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ if (idx > 0 && obj[idx] === curVal && obj[idx - 1] === prevVal)
+ return curVal;
+ else
+ return false;
+}
+
+var arr = [0, 1, true, null, new Object(), "five"];
+
+assert.sameValue(arr.reduce(callbackfn), "five", 'arr.reduce(callbackfn)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js
new file mode 100644
index 0000000000..7ed02502e4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - callbackfn is called with 1 formal
+ parameter
+---*/
+
+var result = false;
+
+function callbackfn(prevVal) {
+ result = (prevVal === 1);
+}
+
+[11].reduce(callbackfn, 1);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js
new file mode 100644
index 0000000000..531891ff92
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - callbackfn is called with 2 formal
+ parameter
+---*/
+
+var result = false;
+
+function callbackfn(prevVal, curVal) {
+ result = (curVal > 10 && 1 === prevVal);
+}
+
+[11].reduce(callbackfn, 1);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js
new file mode 100644
index 0000000000..61cdd93308
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - callbackfn is called with 3 formal
+ parameter
+---*/
+
+var result = false;
+
+function callbackfn(prevVal, curVal, idx) {
+ result = (prevVal === 1 && arguments[3][idx] === curVal);
+}
+
+[11].reduce(callbackfn, 1);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js
new file mode 100644
index 0000000000..3a2029f943
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - callbackfn is called with 4 formal
+ parameter
+---*/
+
+var result = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ result = (prevVal === 1 && obj[idx] === curVal);
+}
+
+[11].reduce(callbackfn, 1);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js
new file mode 100644
index 0000000000..5b6b548b7d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - callbackfn that uses arguments
+---*/
+
+var result = false;
+
+function callbackfn() {
+ result = (arguments[0] === 1 && arguments[3][arguments[2]] === arguments[1]);
+}
+
+[11].reduce(callbackfn, 1);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js
new file mode 100644
index 0000000000..bd1c1e68f9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - non-indexed properties are not called
+---*/
+
+var accessed = false;
+var result1 = true;
+var result2 = true;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ if (curVal === 8) {
+ result1 = false;
+ }
+
+ if (prevVal === 8) {
+ result2 = false;
+ }
+}
+
+var obj = {
+ 0: 11,
+ 10: 12,
+ non_index_property: 8,
+ length: 20
+};
+
+Array.prototype.reduce.call(obj, callbackfn, 1);
+
+assert(result1, 'result1 !== true');
+assert(result2, 'result2 !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js
new file mode 100644
index 0000000000..6389a25655
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - 'accumulator' used for current iteration
+ is the result of previous iteration on an Array
+---*/
+
+var result = true;
+var accessed = false;
+var preIteration = 1;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ if (preIteration !== prevVal) {
+ result = false;
+ }
+ preIteration = curVal;
+ return curVal;
+}
+
+[11, 12, 13].reduce(callbackfn, 1);
+
+assert(result, 'result !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js
new file mode 100644
index 0000000000..0bcaab5cb3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'accumulator' used for first
+ iteration is the value of 'initialValue' when it is present on an
+ Array-like object
+---*/
+
+var result = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 0) {
+ result = (arguments[0] === 1);
+ }
+}
+
+var obj = {
+ 0: 11,
+ 1: 9,
+ length: 2
+};
+
+Array.prototype.reduce.call(obj, callbackfn, 1);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js
new file mode 100644
index 0000000000..e4332b2cef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - value of 'accumulator' used for first
+ iteration is the value of least index property which is not
+ undefined when 'initialValue' is not present on an Array
+---*/
+
+var called = 0;
+var result = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ called++;
+ if (idx === 1) {
+ result = (prevVal === 11) && curVal === 9;
+ }
+}
+
+[11, 9].reduce(callbackfn);
+
+assert(result, 'result !== true');
+assert.sameValue(called, 1, 'called');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js
new file mode 100644
index 0000000000..9221d07ff2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - callbackfn called with correct parameters
+ (initialvalue passed)
+---*/
+
+var bParCorrect = false;
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ if (idx === 0 && obj[idx] === curVal && prevVal === initialValue)
+ return curVal;
+ else if (idx > 0 && obj[idx] === curVal && obj[idx - 1] === prevVal)
+ return curVal;
+ else
+ return false;
+}
+
+var arr = [0, 1, true, null, new Object(), "five"];
+var initialValue = 5.5;
+
+assert.sameValue(arr.reduce(callbackfn, initialValue), "five", 'arr.reduce(callbackfn,initialValue)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js
new file mode 100644
index 0000000000..51594de3c5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - undefined can be used as accumulator
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return typeof prevVal === "undefined";
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, undefined), true, 'Array.prototype.reduce.call(obj, callbackfn, undefined)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js
new file mode 100644
index 0000000000..48f16b2c1b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - null can be used as accumulator
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === null;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, null), true, 'Array.prototype.reduce.call(obj, callbackfn, null)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js
new file mode 100644
index 0000000000..a418171cec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - boolean primitive can be used as
+ accumulator
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === false;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, false), true, 'Array.prototype.reduce.call(obj, callbackfn, false)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js
new file mode 100644
index 0000000000..93676ebf11
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - number primitive can be used as
+ accumulator
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === 12;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, 12), true, 'Array.prototype.reduce.call(obj, callbackfn, 12)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js
new file mode 100644
index 0000000000..937acec0b2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - string primitive can be used as
+ accumulator
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === "hello_";
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, "hello_"), true, 'Array.prototype.reduce.call(obj, callbackfn, "hello_")');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js
new file mode 100644
index 0000000000..58bcbd7f40
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - Function object can be used as accumulator
+---*/
+
+var objFunction = function() {};
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === objFunction;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objFunction), true, 'Array.prototype.reduce.call(obj, callbackfn, objFunction)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js
new file mode 100644
index 0000000000..e610d26a66
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - Array object can be used as accumulator
+---*/
+
+var objArray = new Array(10);
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === objArray;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objArray), true, 'Array.prototype.reduce.call(obj, callbackfn, objArray)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js
new file mode 100644
index 0000000000..52c7a8d870
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - String object can be used as accumulator
+---*/
+
+var objString = new String();
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === objString;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objString), true, 'Array.prototype.reduce.call(obj, callbackfn, objString)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js
new file mode 100644
index 0000000000..b36d411d9d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - Boolean object can be used as accumulator
+---*/
+
+var objBoolean = new Boolean();
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === objBoolean;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objBoolean), true, 'Array.prototype.reduce.call(obj, callbackfn, objBoolean)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js
new file mode 100644
index 0000000000..ef666f11a8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - Number object can be used as accumulator
+---*/
+
+var objNumber = new Number();
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === objNumber;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objNumber), true, 'Array.prototype.reduce.call(obj, callbackfn, objNumber)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js
new file mode 100644
index 0000000000..484f4def97
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - callbackfn takes 4 arguments
+---*/
+
+var bCalled = false;
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ bCalled = true;
+ if (prevVal === true && arguments.length === 4)
+ return true;
+ else
+ return false;
+}
+var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+
+assert.sameValue(arr.reduce(callbackfn, true), true, 'arr.reduce(callbackfn,true)');
+assert.sameValue(bCalled, true, 'bCalled');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js
new file mode 100644
index 0000000000..3fbc3f2276
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - the Math object can be used as accumulator
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === Math;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, Math), true, 'Array.prototype.reduce.call(obj, callbackfn, Math)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js
new file mode 100644
index 0000000000..009e44f687
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - Date object can be used as accumulator
+---*/
+
+var objDate = new Date();
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === objDate;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objDate), true, 'Array.prototype.reduce.call(obj, callbackfn, objDate)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js
new file mode 100644
index 0000000000..1e226ccbc4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - RegExp object can be used as accumulator
+---*/
+
+var objRegExp = new RegExp();
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === objRegExp;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objRegExp), true, 'Array.prototype.reduce.call(obj, callbackfn, objRegExp)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js
new file mode 100644
index 0000000000..f73446cdfc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - the JSON can be used as accumulator
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === JSON;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, JSON), true, 'Array.prototype.reduce.call(obj, callbackfn, JSON)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js
new file mode 100644
index 0000000000..84a311f748
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce - Error object can be used as accumulator
+---*/
+
+var objError = new RangeError();
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === objError;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, objError), true, 'Array.prototype.reduce.call(obj, callbackfn, objError)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js
new file mode 100644
index 0000000000..62801208a0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - the Arguments object can be used as
+ accumulator
+---*/
+
+var accessed = false;
+var arg;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === arg;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+(function fun() {
+ arg = arguments;
+}(10, 11, 12, 13));
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, arg), true, 'Array.prototype.reduce.call(obj, callbackfn, arg)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js
new file mode 100644
index 0000000000..8c736bc96b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - the global object can be used as
+ accumulator
+---*/
+
+var global = this;
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ return prevVal === global;
+}
+
+var obj = {
+ 0: 11,
+ length: 1
+};
+
+assert.sameValue(Array.prototype.reduce.call(obj, callbackfn, this), true, 'Array.prototype.reduce.call(obj, callbackfn, this)');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js
new file mode 100644
index 0000000000..deff6b06a3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - undefined passed as thisValue to strict
+ callbackfn
+flags: [noStrict]
+---*/
+
+var innerThisCorrect = false;
+
+function callbackfn(prevVal, curVal, idx, obj)
+{
+ "use strict";
+ innerThisCorrect = this === undefined;
+ return true;
+}
+[0].reduce(callbackfn, true);
+
+assert(innerThisCorrect, 'innerThisCorrect !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js
new file mode 100644
index 0000000000..31dbdaea73
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - k values are passed in acending numeric
+ order on an Array
+---*/
+
+var arr = [0, 1, 2];
+var lastIdx = 0;
+var result = true;
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ accessed = true;
+ if (lastIdx !== idx) {
+ result = false;
+ } else {
+ lastIdx++;
+ }
+}
+
+arr.reduce(callbackfn, 11);
+
+assert(result, 'result !== true');
+assert(accessed, 'accessed !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js
new file mode 100644
index 0000000000..efb6db149f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - k values are accessed during each
+ iteration and not prior to starting the loop on an Array
+---*/
+
+var result = true;
+var kIndex = [];
+var called = 0;
+
+//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time.
+function callbackfn(prevVal, curVal, idx, obj) {
+ //Each position should be visited one time, which means k is accessed one time during iterations.
+ called++;
+ if (typeof kIndex[idx] === "undefined") {
+ //when current position is visited, its previous index should has been visited.
+ if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") {
+ result = false;
+ }
+ kIndex[idx] = 1;
+ } else {
+ result = false;
+ }
+}
+
+[11, 12, 13, 14].reduce(callbackfn, 1);
+
+assert(result, 'result !== true');
+assert.sameValue(called, 4, 'called');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js
new file mode 100644
index 0000000000..03ebf20fba
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - unhandled exceptions happened in
+ callbackfn terminate iteration
+---*/
+
+var accessed = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx > 0) {
+ accessed = true;
+ }
+ if (idx === 0) {
+ throw new Error("Exception occurred in callbackfn");
+ }
+}
+
+var obj = {
+ 0: 11,
+ 4: 10,
+ 10: 8,
+ length: 20
+};
+assert.throws(Error, function() {
+ Array.prototype.reduce.call(obj, callbackfn, 1);
+});
+assert.sameValue(accessed, false, 'accessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js
new file mode 100644
index 0000000000..135566d8a4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - element changed by callbackfn on previous
+ iterations is observed
+---*/
+
+var result = false;
+
+function callbackfn(prevVal, curVal, idx, obj) {
+ if (idx === 0) {
+ obj[idx + 1] = 8;
+ }
+
+ if (idx === 1) {
+ result = (curVal === 8);
+ }
+}
+
+var obj = {
+ 0: 11,
+ 1: 12,
+ length: 2
+};
+
+Array.prototype.reduce.call(obj, callbackfn, 1);
+
+assert(result, 'result !== true');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js
new file mode 100644
index 0000000000..1d317d4d44
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce - callbackfn is called with 0 formal
+ parameter
+---*/
+
+var called = 0;
+
+function callbackfn() {
+ called++;
+}
+
+[11, 12].reduce(callbackfn, 1);
+
+assert.sameValue(called, 2, 'called');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/browser.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/browser.js
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/call-with-boolean.js
new file mode 100644
index 0000000000..f7063cd6c9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/call-with-boolean.js
@@ -0,0 +1,20 @@
+// Copyright (c) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: Array.prototype.reduce applied to boolean primitive
+---*/
+
+assert.sameValue(
+ Array.prototype.reduce.call(true, () => {}, -1),
+ -1,
+ 'Array.prototype.reduce.call(true, () => {}, -1) must return -1'
+);
+assert.sameValue(
+ Array.prototype.reduce.call(false, () => {}, -1),
+ -1,
+ 'Array.prototype.reduce.call(false, () => {}, -1) must return -1'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js
new file mode 100644
index 0000000000..7196680bec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js
@@ -0,0 +1,76 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-array.prototype.reduce
+description: TypedArray instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3});
+ var sample = new TA(buffer);
+ var expectedPrevs, expectedNexts, expectedIndices, expectedArrays;
+ var prevs, nexts, indices, arrays, result;
+
+ prevs = [];
+ nexts = [];
+ indices = [];
+ arrays = [];
+ result = Array.prototype.reduce.call(sample, function(prev, next, index, array) {
+ if (prevs.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ expectedPrevs = [262, 0];
+ expectedNexts = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ expectedPrevs = [262, 0, 1];
+ expectedNexts = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ prevs.push(prev);
+ nexts.push(next);
+ indices.push(index);
+ arrays.push(array);
+ return index;
+ }, 262);
+
+ assert.compareArray(prevs, expectedPrevs, 'prevs (shrink)');
+ assert.compareArray(nexts, expectedNexts, 'nexts (shrink)');
+ assert.compareArray(indices, expectedIndices, 'indices (shrink)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (shrink)');
+ assert.sameValue(result, expectedIndices[expectedIndices.length - 1], 'result (shrink)');
+
+ prevs = [];
+ nexts = [];
+ indices = [];
+ arrays = [];
+ result = Array.prototype.reduce.call(sample, function(prev, next, index, array) {
+ if (prevs.length === 0) {
+ try {
+ buffer.resize(3 * BPE);
+ } catch (_) {}
+ }
+
+ prevs.push(prev);
+ nexts.push(next);
+ indices.push(index);
+ arrays.push(array);
+ return index;
+ }, 262);
+
+ assert.compareArray(prevs, expectedPrevs, 'prevs (grow)');
+ assert.compareArray(nexts, expectedNexts, 'nexts (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, expectedIndices[expectedIndices.length - 1], 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/length.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/length.js
new file mode 100644
index 0000000000..46705546bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/length.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ The "length" property of Array.prototype.reduce
+info: |
+ 17 ECMAScript Standard Built-in Objects
+
+ Every built-in function object, including constructors, has a length property
+ whose value is an integer. Unless otherwise specified, this value is equal to
+ the largest number of named arguments shown in the subclause headings for the
+ function description. Optional parameters (which are indicated with brackets:
+ [ ]) or rest parameters (which are shown using the form «...name») are not
+ included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in function object
+ has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Array.prototype.reduce.length, 1);
+
+verifyNotEnumerable(Array.prototype.reduce, 'length');
+verifyNotWritable(Array.prototype.reduce, 'length');
+verifyConfigurable(Array.prototype.reduce, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/name.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/name.js
new file mode 100644
index 0000000000..0b368568bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/name.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ Array.prototype.reduce.name is "reduce".
+info: |
+ Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Array.prototype.reduce.name, "reduce");
+
+verifyNotEnumerable(Array.prototype.reduce, "name");
+verifyNotWritable(Array.prototype.reduce, "name");
+verifyConfigurable(Array.prototype.reduce, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js
new file mode 100644
index 0000000000..66a7e1f277
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ Array.prototype.reduce does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, arrow-function]
+---*/
+
+assert.sameValue(
+ isConstructor(Array.prototype.reduce),
+ false,
+ 'isConstructor(Array.prototype.reduce) must return false'
+);
+
+assert.throws(TypeError, () => {
+ new Array.prototype.reduce(() => {}, []);
+}, '`new Array.prototype.reduce(() => {}, [])` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/prop-desc.js
new file mode 100644
index 0000000000..c2bdef04e7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/prop-desc.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.reduce
+description: >
+ "reduce" property of Array.prototype
+info: |
+ 17 ECMAScript Standard Built-in Objects
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2
+ has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(typeof Array.prototype.reduce, 'function', 'typeof');
+
+verifyNotEnumerable(Array.prototype, "reduce");
+verifyWritable(Array.prototype, "reduce");
+verifyConfigurable(Array.prototype, "reduce");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/shell.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/shell.js
new file mode 100644
index 0000000000..05fecd6ef1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/shell.js
@@ -0,0 +1,161 @@
+// GENERATED, DO NOT EDIT
+// file: testTypedArray.js
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ Collection of functions used to assert the correctness of TypedArray objects.
+defines:
+ - floatArrayConstructors
+ - nonClampedIntArrayConstructors
+ - intArrayConstructors
+ - typedArrayConstructors
+ - TypedArray
+ - testWithTypedArrayConstructors
+ - nonAtomicsFriendlyTypedArrayConstructors
+ - testWithAtomicsFriendlyTypedArrayConstructors
+ - testWithNonAtomicsFriendlyTypedArrayConstructors
+ - testTypedArrayConversions
+---*/
+
+var floatArrayConstructors = [
+ Float64Array,
+ Float32Array
+];
+
+var nonClampedIntArrayConstructors = [
+ Int32Array,
+ Int16Array,
+ Int8Array,
+ Uint32Array,
+ Uint16Array,
+ Uint8Array
+];
+
+var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]);
+
+// Float16Array is a newer feature
+// adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it
+if (typeof Float16Array !== 'undefined') {
+ floatArrayConstructors.push(Float16Array);
+}
+
+/**
+ * Array containing every non-bigint typed array constructor.
+ */
+
+var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors);
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Callback for testing a typed array constructor.
+ *
+ * @callback typedArrayConstructorCallback
+ * @param {Function} Constructor the constructor object to test with.
+ */
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithTypedArrayConstructors(f, selected) {
+ var constructors = selected || typedArrayConstructors;
+ for (var i = 0; i < constructors.length; ++i) {
+ var constructor = constructors[i];
+ try {
+ f(constructor);
+ } catch (e) {
+ e.message += " (Testing with " + constructor.name + ".)";
+ throw e;
+ }
+ }
+}
+
+var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]);
+/**
+ * Calls the provided function for every non-"Atomics Friendly" typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithNonAtomicsFriendlyTypedArrayConstructors(f) {
+ testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors);
+}
+
+/**
+ * Calls the provided function for every "Atomics Friendly" typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithAtomicsFriendlyTypedArrayConstructors(f) {
+ testWithTypedArrayConstructors(f, [
+ Int32Array,
+ Int16Array,
+ Int8Array,
+ Uint32Array,
+ Uint16Array,
+ Uint8Array,
+ ]);
+}
+
+/**
+ * Helper for conversion operations on TypedArrays, the expected values
+ * properties are indexed in order to match the respective value for each
+ * TypedArray constructor
+ * @param {Function} fn - the function to call for each constructor and value.
+ * will be called with the constructor, value, expected
+ * value, and a initial value that can be used to avoid
+ * a false positive with an equivalent expected value.
+ */
+function testTypedArrayConversions(byteConversionValues, fn) {
+ var values = byteConversionValues.values;
+ var expected = byteConversionValues.expected;
+
+ testWithTypedArrayConstructors(function(TA) {
+ var name = TA.name.slice(0, -5);
+
+ return values.forEach(function(value, index) {
+ var exp = expected[name][index];
+ var initial = 0;
+ if (exp === 0) {
+ initial = 1;
+ }
+ fn(TA, value, exp, initial);
+ });
+ });
+}
+
+/**
+ * Checks if the given argument is one of the float-based TypedArray constructors.
+ *
+ * @param {constructor} ctor - the value to check
+ * @returns {boolean}
+ */
+function isFloatTypedArrayConstructor(arg) {
+ return floatArrayConstructors.indexOf(arg) !== -1;
+}
+
+/**
+ * Determines the precision of the given float-based TypedArray constructor.
+ *
+ * @param {constructor} ctor - the value to check
+ * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively.
+ */
+function floatTypedArrayConstructorPrecision(FA) {
+ if (typeof Float16Array !== "undefined" && FA === Float16Array) {
+ return "half";
+ } else if (FA === Float32Array) {
+ return "single";
+ } else if (FA === Float64Array) {
+ return "double";
+ } else {
+ throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray");
+ }
+}