| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-435345-01.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 435345; |
| 9 |
var summary = 'Watch the length property of arrays'; |
| 10 |
var actual = ''; |
| 11 |
var expect = ''; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
test(); |
| 17 |
|
| 18 |
|
| 19 |
function test() |
| 20 |
{ |
| 21 |
enterFunc ('test'); |
| 22 |
printBugNumber(BUGNUMBER); |
| 23 |
printStatus (summary); |
| 24 |
|
| 25 |
var arr; |
| 26 |
|
| 27 |
try |
| 28 |
{ |
| 29 |
expect = 'watcher: propname=length, oldval=0, newval=1; '; |
| 30 |
actual = ''; |
| 31 |
arr = []; |
| 32 |
arr.watch('length', watcher); |
| 33 |
arr[0] = '0'; |
| 34 |
} |
| 35 |
catch(ex) |
| 36 |
{ |
| 37 |
actual = ex + ''; |
| 38 |
} |
| 39 |
reportCompare(expect, actual, summary + ': 1'); |
| 40 |
|
| 41 |
try |
| 42 |
{ |
| 43 |
expect = 'watcher: propname=length, oldval=1, newval=2; ' + |
| 44 |
'watcher: propname=length, oldval=2, newval=2; '; |
| 45 |
actual = ''; |
| 46 |
arr.push(5); |
| 47 |
} |
| 48 |
catch(ex) |
| 49 |
{ |
| 50 |
actual = ex + ''; |
| 51 |
} |
| 52 |
reportCompare(expect, actual, summary + ': 2'); |
| 53 |
|
| 54 |
try |
| 55 |
{ |
| 56 |
expect = 'watcher: propname=length, oldval=2, newval=1; '; |
| 57 |
actual = ''; |
| 58 |
arr.pop(); |
| 59 |
} |
| 60 |
catch(ex) |
| 61 |
{ |
| 62 |
actual = ex + ''; |
| 63 |
} |
| 64 |
reportCompare(expect, actual, summary + ': 3'); |
| 65 |
|
| 66 |
try |
| 67 |
{ |
| 68 |
expect = 'watcher: propname=length, oldval=1, newval=2; '; |
| 69 |
actual = ''; |
| 70 |
arr.length++; |
| 71 |
} |
| 72 |
catch(ex) |
| 73 |
{ |
| 74 |
actual = ex + ''; |
| 75 |
} |
| 76 |
reportCompare(expect, actual, summary + ': 4'); |
| 77 |
|
| 78 |
try |
| 79 |
{ |
| 80 |
expect = 'watcher: propname=length, oldval=2, newval=5; '; |
| 81 |
actual = ''; |
| 82 |
arr.length = 5; |
| 83 |
} |
| 84 |
catch(ex) |
| 85 |
{ |
| 86 |
actual = ex + ''; |
| 87 |
} |
| 88 |
reportCompare(expect, actual, summary + ': 5'); |
| 89 |
|
| 90 |
exitFunc ('test'); |
| 91 |
} |
| 92 |
|
| 93 |
function watcher(propname, oldval, newval) |
| 94 |
{ |
| 95 |
actual += 'watcher: propname=' + propname + ', oldval=' + oldval + |
| 96 |
', newval=' + newval + '; '; |
| 97 |
|
| 98 |
return newval; |
| 99 |
} |
| 100 |
|