| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-414098.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 414098; |
| 9 |
var summary = 'Getter behavior on arrays'; |
| 10 |
var actual = ''; |
| 11 |
var expect = ''; |
| 12 |
|
| 13 |
var a=[1,2,3]; |
| 14 |
var foo = 44; |
| 15 |
a.__defineGetter__(1, function() { return foo + 10; }); |
| 16 |
actual = String(a); |
| 17 |
reportCompare("1,54,3", actual, "getter 1"); |
| 18 |
|
| 19 |
actual = String(a.reverse()); |
| 20 |
reportCompare("3,54,1", actual, "reverse"); |
| 21 |
|
| 22 |
var s = ""; |
| 23 |
a.forEach(function(e) { s += e + "|"; }); |
| 24 |
actual = s; |
| 25 |
reportCompare("3|54|1|", actual, "forEach"); |
| 26 |
|
| 27 |
actual = a.join(' - '); |
| 28 |
reportCompare("3 - 54 - 1", actual, "join"); |
| 29 |
|
| 30 |
try |
| 31 |
{ |
| 32 |
actual = String(a.sort()); |
| 33 |
} |
| 34 |
catch(ex) |
| 35 |
{ |
| 36 |
actual = ex + ''; |
| 37 |
} |
| 38 |
reportCompare("TypeError: setting a property that has only a getter", actual, "sort"); |
| 39 |
|
| 40 |
try |
| 41 |
{ |
| 42 |
a[2]=3; |
| 43 |
} |
| 44 |
catch(ex) |
| 45 |
{ |
| 46 |
actual = ex + ''; |
| 47 |
} |
| 48 |
reportCompare("TypeError: setting a property that has only a getter", actual, "setter"); |
| 49 |
|
| 50 |
actual = a.pop(); |
| 51 |
reportCompare(3, actual, "pop"); |
| 52 |
|
| 53 |
actual = a.pop(); |
| 54 |
reportCompare(54, actual, "pop 2"); |