| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'function-002.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
var SECTION = "function-002.js"; |
| 36 |
var VERSION = "JS1_4"; |
| 37 |
var TITLE = "Regression test case for 325843"; |
| 38 |
var BUGNUMBER="330462"; |
| 39 |
|
| 40 |
startTest(); |
| 41 |
|
| 42 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 43 |
|
| 44 |
dec1 = "function f1(x,y){++x, --y}"; |
| 45 |
dec2 = "function f2(){var y; f1(1,2); y=new Date(); print(y.toString())}"; |
| 46 |
|
| 47 |
eval(dec1); |
| 48 |
eval(dec2); |
| 49 |
|
| 50 |
new TestCase( |
| 51 |
SECTION, |
| 52 |
"typeof f1", |
| 53 |
"function", |
| 54 |
typeof f1 ); |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
new TestCase( |
| 59 |
SECTION, |
| 60 |
"f1.toString() == dec1", |
| 61 |
true, |
| 62 |
StripSpaces(f1.toString()) == StripSpaces(dec1)); |
| 63 |
|
| 64 |
new TestCase( |
| 65 |
SECTION, |
| 66 |
"typeof f2", |
| 67 |
"function", |
| 68 |
typeof f2 ); |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
new TestCase( |
| 73 |
SECTION, |
| 74 |
"f2.toString() == dec2", |
| 75 |
true, |
| 76 |
StripSpaces(f2.toString().replace(/new Date\(\)/g, 'new Date')) == |
| 77 |
StripSpaces(dec2.replace(/new Date\(\)/g, 'new Date'))); |
| 78 |
|
| 79 |
test(); |
| 80 |
|
| 81 |
function StripSpaces( s ) { |
| 82 |
var strippedString = ""; |
| 83 |
for ( var currentChar = 0; currentChar < s.length; currentChar++ ) { |
| 84 |
if (!IsWhiteSpace(s.charAt(currentChar))) { |
| 85 |
strippedString += s.charAt(currentChar); |
| 86 |
} |
| 87 |
} |
| 88 |
return strippedString; |
| 89 |
} |
| 90 |
|
| 91 |
function IsWhiteSpace( string ) { |
| 92 |
var cc = string.charCodeAt(0); |
| 93 |
|
| 94 |
switch (cc) { |
| 95 |
case (0x0009): |
| 96 |
case (0x000B): |
| 97 |
case (0x000C): |
| 98 |
case (0x0020): |
| 99 |
case (0x000A): |
| 100 |
case (0x000D): |
| 101 |
case ( 59 ): |
| 102 |
return true; |
| 103 |
break; |
| 104 |
default: |
| 105 |
return false; |
| 106 |
} |
| 107 |
} |
| 108 |
|