| 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>'); // #2217 | 9 assertEquals('<'.anchor('<'), '<a name="<"><</a>'); |
| 10 assertEquals('_'.anchor(0x2A), '<a name="42">_</a>'); | 10 assertEquals('_'.anchor(0x2A), '<a name="42">_</a>'); |
| 11 assertEquals('_'.anchor('\x22'), '<a name=""">_</a>'); | 11 assertEquals('_'.anchor('\x22'), '<a name=""">_</a>'); |
| 12 assertEquals(String.prototype.anchor.call(0x2A, 0x2A), '<a name="42">42</a>'); | 12 assertEquals(String.prototype.anchor.call(0x2A, 0x2A), '<a name="42">42</a>'); |
| 13 assertThrows(function() { | 13 assertThrows(function() { |
| 14 String.prototype.anchor.call(undefined); | 14 String.prototype.anchor.call(undefined); |
| 15 }, TypeError); | 15 }, TypeError); |
| 16 assertThrows(function() { | 16 assertThrows(function() { |
| 17 String.prototype.anchor.call(null); | 17 String.prototype.anchor.call(null); |
| 18 }, TypeError); | 18 }, TypeError); |
| 19 assertEquals(String.prototype.anchor.length, 1); | 19 assertEquals(String.prototype.anchor.length, 1); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 assertEquals(String.prototype.fixed.call(0x2A), '<tt>42</tt>'); | 56 assertEquals(String.prototype.fixed.call(0x2A), '<tt>42</tt>'); |
| 57 assertThrows(function() { | 57 assertThrows(function() { |
| 58 String.prototype.fixed.call(undefined); | 58 String.prototype.fixed.call(undefined); |
| 59 }, TypeError); | 59 }, TypeError); |
| 60 assertThrows(function() { | 60 assertThrows(function() { |
| 61 String.prototype.fixed.call(null); | 61 String.prototype.fixed.call(null); |
| 62 }, TypeError); | 62 }, TypeError); |
| 63 assertEquals(String.prototype.fixed.length, 0); | 63 assertEquals(String.prototype.fixed.length, 0); |
| 64 | 64 |
| 65 assertEquals('_'.fontcolor('b'), '<font color="b">_</font>'); | 65 assertEquals('_'.fontcolor('b'), '<font color="b">_</font>'); |
| 66 //assertEquals('<'.fontcolor('<'), '<font color="<"><</font>'); // #2217 | 66 assertEquals('<'.fontcolor('<'), '<font color="<"><</font>'); |
| 67 assertEquals('_'.fontcolor(0x2A), '<font color="42">_</font>'); | 67 assertEquals('_'.fontcolor(0x2A), '<font color="42">_</font>'); |
| 68 assertEquals('_'.fontcolor('\x22'), '<font color=""">_</font>'); | 68 assertEquals('_'.fontcolor('\x22'), '<font color=""">_</font>'); |
| 69 assertEquals(String.prototype.fontcolor.call(0x2A, 0x2A), | 69 assertEquals(String.prototype.fontcolor.call(0x2A, 0x2A), |
| 70 '<font color="42">42</font>'); | 70 '<font color="42">42</font>'); |
| 71 assertThrows(function() { | 71 assertThrows(function() { |
| 72 String.prototype.fontcolor.call(undefined); | 72 String.prototype.fontcolor.call(undefined); |
| 73 }, TypeError); | 73 }, TypeError); |
| 74 assertThrows(function() { | 74 assertThrows(function() { |
| 75 String.prototype.fontcolor.call(null); | 75 String.prototype.fontcolor.call(null); |
| 76 }, TypeError); | 76 }, TypeError); |
| 77 assertEquals(String.prototype.fontcolor.length, 1); | 77 assertEquals(String.prototype.fontcolor.length, 1); |
| 78 | 78 |
| 79 assertEquals('_'.fontsize('b'), '<font size="b">_</font>'); | 79 assertEquals('_'.fontsize('b'), '<font size="b">_</font>'); |
| 80 //assertEquals('<'.fontsize('<'), '<font size="<"><</font>'); // #2217 | 80 assertEquals('<'.fontsize('<'), '<font size="<"><</font>'); |
| 81 assertEquals('_'.fontsize(0x2A), '<font size="42">_</font>'); | 81 assertEquals('_'.fontsize(0x2A), '<font size="42">_</font>'); |
| 82 assertEquals('_'.fontsize('\x22'), '<font size=""">_</font>'); | 82 assertEquals('_'.fontsize('\x22'), '<font size=""">_</font>'); |
| 83 assertEquals(String.prototype.fontsize.call(0x2A, 0x2A), | 83 assertEquals(String.prototype.fontsize.call(0x2A, 0x2A), |
| 84 '<font size="42">42</font>'); | 84 '<font size="42">42</font>'); |
| 85 assertThrows(function() { | 85 assertThrows(function() { |
| 86 String.prototype.fontsize.call(undefined); | 86 String.prototype.fontsize.call(undefined); |
| 87 }, TypeError); | 87 }, TypeError); |
| 88 assertThrows(function() { | 88 assertThrows(function() { |
| 89 String.prototype.fontsize.call(null); | 89 String.prototype.fontsize.call(null); |
| 90 }, TypeError); | 90 }, TypeError); |
| 91 assertEquals(String.prototype.fontsize.length, 1); | 91 assertEquals(String.prototype.fontsize.length, 1); |
| 92 | 92 |
| 93 assertEquals('_'.italics(), '<i>_</i>'); | 93 assertEquals('_'.italics(), '<i>_</i>'); |
| 94 assertEquals('<'.italics(), '<i><</i>'); | 94 assertEquals('<'.italics(), '<i><</i>'); |
| 95 assertEquals(String.prototype.italics.call(0x2A), '<i>42</i>'); | 95 assertEquals(String.prototype.italics.call(0x2A), '<i>42</i>'); |
| 96 assertThrows(function() { | 96 assertThrows(function() { |
| 97 String.prototype.italics.call(undefined); | 97 String.prototype.italics.call(undefined); |
| 98 }, TypeError); | 98 }, TypeError); |
| 99 assertThrows(function() { | 99 assertThrows(function() { |
| 100 String.prototype.italics.call(null); | 100 String.prototype.italics.call(null); |
| 101 }, TypeError); | 101 }, TypeError); |
| 102 assertEquals(String.prototype.italics.length, 0); | 102 assertEquals(String.prototype.italics.length, 0); |
| 103 | 103 |
| 104 assertEquals('_'.link('b'), '<a href="b">_</a>'); | 104 assertEquals('_'.link('b'), '<a href="b">_</a>'); |
| 105 //assertEquals('<'.link('<'), '<a href="<"><</a>'); // #2217 | 105 assertEquals('<'.link('<'), '<a href="<"><</a>'); |
| 106 assertEquals('_'.link(0x2A), '<a href="42">_</a>'); | 106 assertEquals('_'.link(0x2A), '<a href="42">_</a>'); |
| 107 assertEquals('_'.link('\x22'), '<a href=""">_</a>'); | 107 assertEquals('_'.link('\x22'), '<a href=""">_</a>'); |
| 108 assertEquals(String.prototype.link.call(0x2A, 0x2A), '<a href="42">42</a>'); | 108 assertEquals(String.prototype.link.call(0x2A, 0x2A), '<a href="42">42</a>'); |
| 109 assertThrows(function() { | 109 assertThrows(function() { |
| 110 String.prototype.link.call(undefined); | 110 String.prototype.link.call(undefined); |
| 111 }, TypeError); | 111 }, TypeError); |
| 112 assertThrows(function() { | 112 assertThrows(function() { |
| 113 String.prototype.link.call(null); | 113 String.prototype.link.call(null); |
| 114 }, TypeError); | 114 }, TypeError); |
| 115 assertEquals(String.prototype.link.length, 1); | 115 assertEquals(String.prototype.link.length, 1); |
| (...skipping 34 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); |
| OLD | NEW |