diff options
Diffstat (limited to 'test/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js')
-rw-r--r-- | test/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/test/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js b/test/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js index 3d7783369..db7132e8a 100644 --- a/test/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js +++ b/test/built-ins/Array/prototype/reduce/15.4.4.21-7-7.js @@ -10,18 +10,23 @@ description: > obj w/o valueOf (toString)) ---*/ - foo.prototype = new Array(1, 2, 3); - function foo() {} - var f = new foo(); +foo.prototype = new Array(1, 2, 3); - var o = { toString: function () { return '0';}}; - f.length = o; +function foo() {} +var f = new foo(); - // 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. +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; - function cb(){} -assert.sameValue(f.reduce(cb,1), 1, 'f.reduce(cb,1)'); +// 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)'); |