blob: f2c7b278bfb1484858f71f2c000df268a1af6070 [file] [log] [blame]
Test some array functions on non-array objects.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS properties(['b', 'a']) is '0:b, 1:a, length:2(DontDelete, DontEnum)'
PASS properties({ length:2, 0:'b', 1:'a' }) is '0:b, 1:a, length:2'
PASS properties(new OneItemConstructor) is '0:a(FromPrototype), length:1(FromPrototype)'
PASS properties(new TwoItemConstructor) is '0:b(FromPrototype), 1:a(FromPrototype), length:2(FromPrototype)'
PASS Array.prototype.toString.call({}) is "[object Object]"
PASS Array.prototype.toString.call(new Date) is "[object Date]"
PASS Array.prototype.toString.call({sort: function() { return 'sort' }}) is "[object Object]"
PASS Array.prototype.toString.call({join: function() { return 'join' }}) is "join"
PASS Array.prototype.toString.call({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3}) is "a,b,c"
PASS ({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3}).toString() is "a,b,c"
PASS Array.prototype.toString.call({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3, join: function() { return 'join' }}) is "join"
PASS ({__proto__: Array.prototype, 0: 'a', 1: 'b', 2: 'c', length: 3, join: function() { return 'join' }}).toString() is "join"
PASS Array.prototype.toString.call(42) is "Number.prototype.join:42"
PASS [0, 1, 2].toString() is "array-join"
PASS Array.prototype.toLocaleString.call({}) is ""
PASS Array.prototype.concat.call(x = { length:2, 0:'b', 1:'a' }) is [x]
PASS Array.prototype.join.call({}) is ''
PASS Array.prototype.join.call(['b', 'a']) is 'b,a'
PASS Array.prototype.join.call({ length:2, 0:'b', 1:'a' }) is 'b,a'
PASS Array.prototype.join.call(new TwoItemConstructor) is 'b,a'
PASS Array.prototype.pop.call({}) is undefined
PASS Array.prototype.pop.call({ length:2, 0:'b', 1:'a' }) is 'a'
PASS Array.prototype.pop.call({ length:2, 0:'b', 1:'a' }) is 'a'
PASS Array.prototype.pop.call(new TwoItemConstructor) is 'a'
PASS Array.prototype.pop.call(x = {}); properties(x) is 'length:0'
PASS Array.prototype.pop.call(x = ['b', 'a']); properties(x) is '0:b, length:1(DontDelete, DontEnum)'
PASS Array.prototype.pop.call(x = { length:2, 0:'b', 1:'a' }); properties(x) is '0:b, length:1'
PASS Array.prototype.pop.call(x = new TwoItemConstructor); properties(x) is '0:b(FromPrototype), 1:a(FromPrototype), length:1'
PASS Array.prototype.push.call({}) is 0
PASS Array.prototype.push.call(['b', 'a']) is 2
PASS Array.prototype.push.call({ length:2, 0:'b', 1:'a' }) is 2
PASS Array.prototype.push.call(new TwoItemConstructor) is 2
PASS Array.prototype.push.call(x = {}); properties(x) is 'length:0'
PASS Array.prototype.push.call(x = ['b', 'a']); properties(x) is '0:b, 1:a, length:2(DontDelete, DontEnum)'
PASS Array.prototype.push.call(x = { length:2, 0:'b', 1:'a' }); properties(x) is '0:b, 1:a, length:2'
PASS Array.prototype.push.call(x = new TwoItemConstructor); properties(x) is '0:b(FromPrototype), 1:a(FromPrototype), length:2'
PASS Array.prototype.push.call({}, 'c') is 1
PASS Array.prototype.push.call(['b', 'a'], 'c') is 3
PASS Array.prototype.push.call({ length:2, 0:'b', 1:'a' }, 'c') is 3
PASS Array.prototype.push.call(new TwoItemConstructor, 'c') is 3
PASS Array.prototype.push.call(x = {}, 'c'); properties(x) is '0:c, length:1'
PASS Array.prototype.push.call(x = ['b', 'a'], 'c'); properties(x) is '0:b, 1:a, 2:c, length:3(DontDelete, DontEnum)'
PASS Array.prototype.push.call(x = { length:2, 0:'b', 1:'a' }, 'c'); properties(x) is '0:b, 1:a, 2:c, length:3'
PASS Array.prototype.push.call(x = new TwoItemConstructor, 'c'); properties(x) is '0:b(FromPrototype), 1:a(FromPrototype), 2:c, length:3'
PASS properties(Array.prototype.reverse.call({})) is ''
PASS properties(Array.prototype.reverse.call(['b', 'a'])) is '0:a, 1:b, length:2(DontDelete, DontEnum)'
PASS properties(Array.prototype.reverse.call({ length:2, 0:'b', 1:'a' })) is '0:a, 1:b, length:2'
PASS properties(Array.prototype.reverse.call(new OneItemConstructor)) is '0:a(FromPrototype), length:1(FromPrototype)'
PASS properties(Array.prototype.reverse.call(new TwoItemConstructor)) is '0:a, 1:b, length:2(FromPrototype)'
PASS Array.prototype.shift.call({}) is undefined
PASS Array.prototype.shift.call(['b', 'a']) is 'b'
PASS Array.prototype.shift.call({ length:2, 0:'b', 1:'a' }) is 'b'
PASS Array.prototype.shift.call(new TwoItemConstructor) is 'b'
PASS Array.prototype.shift.call(x = {}); properties(x) is 'length:0'
PASS Array.prototype.shift.call(x = ['b', 'a']); properties(x) is '0:a, length:1(DontDelete, DontEnum)'
PASS Array.prototype.shift.call(x = { length:2, 0:'b', 1:'a' }); properties(x) is '0:a, length:1'
PASS Array.prototype.shift.call(x = new TwoItemConstructor); properties(x) is '0:a, 1:a(FromPrototype), length:1'
PASS Array.prototype.slice.call({}, 0, 1) is []
PASS Array.prototype.slice.call(['b', 'a'], 0, 1) is ['b']
PASS Array.prototype.slice.call({ length:2, 0:'b', 1:'a' }, 0, 1) is ['b']
PASS Array.prototype.slice.call(new TwoItemConstructor, 0, 1) is ['b']
PASS properties(Array.prototype.sort.call({})) is ''
PASS properties(Array.prototype.sort.call(['b', 'a'])) is '0:a, 1:b, length:2(DontDelete, DontEnum)'
PASS properties(Array.prototype.sort.call({ length:2, 0:'b', 1:'a' })) is '0:a, 1:b, length:2'
PASS properties(Array.prototype.sort.call(new OneItemConstructor)) is '0:a(FromPrototype), length:1(FromPrototype)'
PASS properties(Array.prototype.sort.call(new TwoItemConstructor)) is '0:a, 1:b, length:2(FromPrototype)'
PASS Array.prototype.splice.call({}, 0, 1) is []
PASS Array.prototype.splice.call(['b', 'a'], 0, 1) is ['b']
PASS Array.prototype.splice.call({ length:2, 0:'b', 1:'a' }, 0, 1) is ['b']
PASS Array.prototype.splice.call(new TwoItemConstructor, 0, 1) is ['b']
PASS Array.prototype.splice.call(x = {}, 0, 1); properties(x) is 'length:0'
PASS Array.prototype.splice.call(x = ['b', 'a'], 0, 1); properties(x) is '0:a, length:1(DontDelete, DontEnum)'
PASS Array.prototype.splice.call(x = { length:2, 0:'b', 1:'a' }, 0, 1); properties(x) is '0:a, length:1'
PASS Array.prototype.splice.call(x = new TwoItemConstructor, 0, 1); properties(x) is '0:a, 1:a(FromPrototype), length:1'
PASS Array.prototype.unshift.call({}) is 0
PASS Array.prototype.unshift.call(['b', 'a']) is 2
PASS Array.prototype.unshift.call({ length:2, 0:'b', 1:'a' }) is 2
PASS Array.prototype.unshift.call(new TwoItemConstructor) is 2
PASS Array.prototype.unshift.call(x = {}); properties(x) is 'length:0'
PASS Array.prototype.unshift.call(x = ['b', 'a']); properties(x) is '0:b, 1:a, length:2(DontDelete, DontEnum)'
PASS Array.prototype.unshift.call(x = { length:2, 0:'b', 1:'a' }); properties(x) is '0:b, 1:a, length:2'
PASS Array.prototype.unshift.call(x = new TwoItemConstructor); properties(x) is '0:b(FromPrototype), 1:a(FromPrototype), length:2'
PASS Array.prototype.unshift.call({}, 'c') is 1
PASS Array.prototype.unshift.call(['b', 'a'], 'c') is 3
PASS Array.prototype.unshift.call({ length:2, 0:'b', 1:'a' }, 'c') is 3
PASS Array.prototype.unshift.call(new TwoItemConstructor, 'c') is 3
PASS Array.prototype.unshift.call(x = {}, 'c'); properties(x) is '0:c, length:1'
PASS Array.prototype.unshift.call(x = ['b', 'a'], 'c'); properties(x) is '0:c, 1:b, 2:a, length:3(DontDelete, DontEnum)'
PASS Array.prototype.unshift.call(x = { length:2, 0:'b', 1:'a' }, 'c'); properties(x) is '0:c, 1:b, 2:a, length:3'
PASS Array.prototype.unshift.call(x = new TwoItemConstructor, 'c'); properties(x) is '0:c, 1:b, 2:a, length:3'
Array-like object with invalid lengths
PASS var obj = { 0: 1, 1: 2, 2: 3, length: 0 }; Array.prototype.forEach.call(obj, throwError) is undefined.
PASS var obj = { 0: 1, 1: 2, 2: 3, length: -0 }; Array.prototype.forEach.call(obj, throwError) is undefined.
PASS var obj = { 0: 1, 1: 2, 2: 3, length: -3 }; Array.prototype.forEach.call(obj, throwError) is undefined.
PASS var obj = { 0: 1, 1: 2, 2: 3, length: 0 }; Array.prototype.map.call(obj, throwError) is []
PASS var obj = { 0: 1, 1: 2, 2: 3, length: -0 }; Array.prototype.map.call(obj, throwError) is []
PASS var obj = { 0: 1, 1: 2, 2: 3, length: -3 }; Array.prototype.map.call(obj, throwError) is []
PASS var obj = { 0: 1, 1: 2, 2: 3, length: 0 }; Array.prototype.some.call(obj, throwError) is false
PASS var obj = { 0: 1, 1: 2, 2: 3, length: -0 }; Array.prototype.some.call(obj, throwError) is false
PASS var obj = { 0: 1, 1: 2, 2: 3, length: -3 }; Array.prototype.some.call(obj, throwError) is false
PASS successfullyParsed is true
TEST COMPLETE