| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = '15.5.4.9-1.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 |
|
| 36 |
|
| 37 |
|
| 38 |
var SECTION = "15.5.4.9-1"; |
| 39 |
var VERSION = "ECMA_1"; |
| 40 |
startTest(); |
| 41 |
var TITLE = "String.prototype.substring( start )"; |
| 42 |
|
| 43 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 44 |
|
| 45 |
new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); |
| 46 |
new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); |
| 47 |
new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
new TestCase( SECTION, |
| 54 |
"var s = new String('this is a string object'); typeof s.substring()", |
| 55 |
"string", |
| 56 |
eval("var s = new String('this is a string object'); typeof s.substring()") ); |
| 57 |
|
| 58 |
new TestCase( SECTION, |
| 59 |
"var s = new String(''); s.substring()", |
| 60 |
"", |
| 61 |
eval("var s = new String(''); s.substring()") ); |
| 62 |
|
| 63 |
|
| 64 |
new TestCase( SECTION, |
| 65 |
"var s = new String('this is a string object'); s.substring()", |
| 66 |
"this is a string object", |
| 67 |
eval("var s = new String('this is a string object'); s.substring()") ); |
| 68 |
|
| 69 |
new TestCase( SECTION, |
| 70 |
"var s = new String('this is a string object'); s.substring(NaN)", |
| 71 |
"this is a string object", |
| 72 |
eval("var s = new String('this is a string object'); s.substring(NaN)") ); |
| 73 |
|
| 74 |
|
| 75 |
new TestCase( SECTION, |
| 76 |
"var s = new String('this is a string object'); s.substring(-0.01)", |
| 77 |
"this is a string object", |
| 78 |
eval("var s = new String('this is a string object'); s.substring(-0.01)") ); |
| 79 |
|
| 80 |
|
| 81 |
new TestCase( SECTION, |
| 82 |
"var s = new String('this is a string object'); s.substring(s.length)", |
| 83 |
"", |
| 84 |
eval("var s = new String('this is a string object'); s.substring(s.length)") ); |
| 85 |
|
| 86 |
new TestCase( SECTION, |
| 87 |
"var s = new String('this is a string object'); s.substring(s.length+1)", |
| 88 |
"", |
| 89 |
eval("var s = new String('this is a string object'); s.substring(s.length+1)") ); |
| 90 |
|
| 91 |
|
| 92 |
new TestCase( SECTION, |
| 93 |
"var s = new String('this is a string object'); s.substring(Infinity)", |
| 94 |
"", |
| 95 |
eval("var s = new String('this is a string object'); s.substring(Infinity)") ); |
| 96 |
|
| 97 |
new TestCase( SECTION, |
| 98 |
"var s = new String('this is a string object'); s.substring(-Infinity)", |
| 99 |
"this is a string object", |
| 100 |
eval("var s = new String('this is a string object'); s.substring(-Infinity)") ); |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
new TestCase( SECTION, |
| 106 |
"var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()", |
| 107 |
"1,2,3,4,5", |
| 108 |
eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()") ); |
| 109 |
|
| 110 |
new TestCase( SECTION, |
| 111 |
"var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)", |
| 112 |
",2,3,4,5", |
| 113 |
eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)") ); |
| 114 |
|
| 115 |
new TestCase( SECTION, |
| 116 |
"var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')", |
| 117 |
"3,4,5", |
| 118 |
eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')") ); |
| 119 |
|
| 120 |
new TestCase( SECTION, |
| 121 |
"var s = new Array(); s.substring = String.prototype.substring; s.substring('4')", |
| 122 |
"", |
| 123 |
eval("var s = new Array(); s.substring = String.prototype.substring; s.substring('4')") ); |
| 124 |
|
| 125 |
|
| 126 |
new TestCase( SECTION, |
| 127 |
"var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)", |
| 128 |
"Object]", |
| 129 |
eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)") ); |
| 130 |
|
| 131 |
|
| 132 |
new TestCase( SECTION, |
| 133 |
"var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)", |
| 134 |
"Function]", |
| 135 |
eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)") ); |
| 136 |
|
| 137 |
new TestCase( SECTION, |
| 138 |
"var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)", |
| 139 |
"NaN", |
| 140 |
eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)") ); |
| 141 |
|
| 142 |
|
| 143 |
new TestCase( SECTION, |
| 144 |
"var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)", |
| 145 |
"ject Math]", |
| 146 |
eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)") ); |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
new TestCase( SECTION, |
| 151 |
"var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())", |
| 152 |
"false", |
| 153 |
eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())") ); |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
new TestCase( SECTION, |
| 158 |
"var obj = new MyObject( null ); obj.substring(0)", |
| 159 |
"null", |
| 160 |
eval( "var obj = new MyObject( null ); obj.substring(0)") ); |
| 161 |
|
| 162 |
|
| 163 |
test(); |
| 164 |
|
| 165 |
function MyObject( value ) { |
| 166 |
this.value = value; |
| 167 |
this.substring = String.prototype.substring; |
| 168 |
this.toString = new Function ( "return this.value+''" ); |
| 169 |
} |