OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Tests taken from: | 5 // Tests taken from: |
6 // http://mathias.html5.org/tests/javascript/string/ | 6 // http://mathias.html5.org/tests/javascript/string/ |
7 | 7 |
8 assertEquals('_'.anchor('b'), '<a name="b">_</a>'); | 8 assertEquals('_'.anchor('b'), '<a name="b">_</a>'); |
9 assertEquals('<'.anchor('<'), '<a name="<"><</a>'); | 9 assertEquals('<'.anchor('<'), '<a name="<"><</a>'); |
10 assertEquals('_'.anchor(0x2A), '<a name="42">_</a>'); | 10 assertEquals('_'.anchor(0x2A), '<a name="42">_</a>'); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 assertEquals('_'.sup(), '<sup>_</sup>'); | 150 assertEquals('_'.sup(), '<sup>_</sup>'); |
151 assertEquals('<'.sup(), '<sup><</sup>'); | 151 assertEquals('<'.sup(), '<sup><</sup>'); |
152 assertEquals(String.prototype.sup.call(0x2A), '<sup>42</sup>'); | 152 assertEquals(String.prototype.sup.call(0x2A), '<sup>42</sup>'); |
153 assertThrows(function() { | 153 assertThrows(function() { |
154 String.prototype.sup.call(undefined); | 154 String.prototype.sup.call(undefined); |
155 }, TypeError); | 155 }, TypeError); |
156 assertThrows(function() { | 156 assertThrows(function() { |
157 String.prototype.sup.call(null); | 157 String.prototype.sup.call(null); |
158 }, TypeError); | 158 }, TypeError); |
159 assertEquals(String.prototype.sup.length, 0); | 159 assertEquals(String.prototype.sup.length, 0); |
| 160 |
| 161 |
| 162 (function TestToString() { |
| 163 var calls = 0; |
| 164 var obj = { |
| 165 toString() { |
| 166 calls++; |
| 167 return 'abc'; |
| 168 }, |
| 169 valueOf() { |
| 170 assertUnreachable(); |
| 171 } |
| 172 }; |
| 173 |
| 174 var methodNames = [ |
| 175 'anchor', |
| 176 'big', |
| 177 'blink', |
| 178 'bold', |
| 179 'fixed', |
| 180 'fontcolor', |
| 181 'fontsize', |
| 182 'italics', |
| 183 'link', |
| 184 'small', |
| 185 'strike', |
| 186 'sub', |
| 187 'sup', |
| 188 ]; |
| 189 for (var name of methodNames) { |
| 190 calls = 0; |
| 191 String.prototype[name].call(obj); |
| 192 assertEquals(1, calls); |
| 193 } |
| 194 })(); |
OLD | NEW |