OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 assertEquals(String.fromCharCode(97, 220, 256), 'a' + '\u00DC' + '\u0100'); | 28 assertEquals(String.fromCharCode(97, 220, 256), 'a' + '\u00DC' + '\u0100'); |
29 assertEquals(String.fromCharCode(97, 220, 256), 'a\u00DC\u0100'); | 29 assertEquals(String.fromCharCode(97, 220, 256), 'a\u00DC\u0100'); |
30 | 30 |
| 31 assertEquals(0x80, JSON.stringify("\x80").charCodeAt(1)); |
| 32 |
31 assertEquals(['a', 'b', '\xdc'], ['b', '\xdc', 'a'].sort()); | 33 assertEquals(['a', 'b', '\xdc'], ['b', '\xdc', 'a'].sort()); |
| 34 |
32 assertEquals(['\xfc\xdc', '\xfc'], new RegExp('(\xdc)\\1', 'i').exec('\xfc\xdc')
); | 35 assertEquals(['\xfc\xdc', '\xfc'], new RegExp('(\xdc)\\1', 'i').exec('\xfc\xdc')
); |
33 | 36 // Same test but for all values in Latin-1 range. |
| 37 var total_lo = 0; |
| 38 for (var i = 0; i < 0xff; i++) { |
| 39 var base = String.fromCharCode(i); |
| 40 var escaped = base; |
| 41 if (base == '(' || base == ')' || base == '*' || base == '+' || |
| 42 base == '?' || base == '[' || base == ']' || base == '\\' || |
| 43 base == '$' || base == '^' || base == '|') { |
| 44 escaped = '\\' + base; |
| 45 } |
| 46 var lo = String.fromCharCode(i + 0x20); |
| 47 base_result = new RegExp('(' + escaped + ')\\1', 'i').exec(base + base); |
| 48 assertEquals( base_result, [base + base, base]); |
| 49 lo_result = new RegExp('(' + escaped + ')\\1', 'i').exec(base + lo); |
| 50 if (base.toLowerCase() == lo) { |
| 51 assertEquals([base + lo, base], lo_result); |
| 52 total_lo++; |
| 53 } else { |
| 54 assertEquals(null, lo_result); |
| 55 } |
| 56 } |
| 57 // Should have hit the branch for the following char codes: |
| 58 // [A-Z], [192-222] but not 215 |
| 59 assertEquals((90-65+1)+(222-192-1+1), total_lo); |
OLD | NEW |