| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 assertFalse(new RegExp(regex).test(SIGMA), 53 + name); | 167 assertFalse(new RegExp(regex).test(SIGMA), 53 + name); |
| 168 | 168 |
| 169 // JSC and Tracemonkey fail this one. | 169 // JSC and Tracemonkey fail this one. |
| 170 assertTrue(new RegExp(regex, "i").test(sigma), 54 + name); | 170 assertTrue(new RegExp(regex, "i").test(sigma), 54 + name); |
| 171 assertTrue(new RegExp(regex, "i").test(alternative_sigma), 55 + name); | 171 assertTrue(new RegExp(regex, "i").test(alternative_sigma), 55 + name); |
| 172 // JSC and Tracemonkey fail this one. | 172 // JSC and Tracemonkey fail this one. |
| 173 assertTrue(new RegExp(regex, "i").test(SIGMA), 56 + name); | 173 assertTrue(new RegExp(regex, "i").test(SIGMA), 56 + name); |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 // Test all non-ASCII characters individually to ensure that our optimizations | |
| 178 // didn't break anything. | |
| 179 for (var i = 0x80; i <= 0xfffe; i++) { | |
| 180 var c = String.fromCharCode(i); | |
| 181 var c2 = String.fromCharCode(i + 1); | |
| 182 var re = new RegExp("[" + c + "-" + c2 + "]", "i"); | |
| 183 assertTrue(re.test(c), 57); | |
| 184 } | |
| 185 | |
| 186 for (var add_non_ascii_character_to_subject = 0; | 177 for (var add_non_ascii_character_to_subject = 0; |
| 187 add_non_ascii_character_to_subject < 2; | 178 add_non_ascii_character_to_subject < 2; |
| 188 add_non_ascii_character_to_subject++) { | 179 add_non_ascii_character_to_subject++) { |
| 189 var suffix = add_non_ascii_character_to_subject ? "\ufffe" : ""; | 180 var suffix = add_non_ascii_character_to_subject ? "\ufffe" : ""; |
| 190 // A range that covers both ASCII and non-ASCII. | 181 // A range that covers both ASCII and non-ASCII. |
| 191 for (var i = 0; i < 2; i++) { | 182 for (var i = 0; i < 2; i++) { |
| 192 var full = (i != 0); | 183 var full = (i != 0); |
| 193 var mixed = full ? "[a-\uffff]" : "[a-" + cyrillic.LAST + "]"; | 184 var mixed = full ? "[a-\uffff]" : "[a-" + cyrillic.LAST + "]"; |
| 194 var f = full ? "f" : "c"; | 185 var f = full ? "f" : "c"; |
| 195 for (var j = 0; j < 2; j++) { | 186 for (var j = 0; j < 2; j++) { |
| 196 var ignore_case = (j == 0); | 187 var ignore_case = (j == 0); |
| 197 var flag = ignore_case ? "i" : ""; | 188 var flag = ignore_case ? "i" : ""; |
| 198 var re = new RegExp(mixed, flag); | 189 var re = new RegExp(mixed, flag); |
| 199 assertEquals(ignore_case || (full && add_non_ascii_character_to_subject), | 190 assertEquals(ignore_case || (full && add_non_ascii_character_to_subject), |
| 200 re.test("A" + suffix), | 191 re.test("A" + suffix), |
| 201 58 + flag + f); | 192 58 + flag + f); |
| 202 assertTrue(re.test("a" + suffix), 59 + flag + f); | 193 assertTrue(re.test("a" + suffix), 59 + flag + f); |
| 203 assertTrue(re.test("~" + suffix), 60 + flag + f); | 194 assertTrue(re.test("~" + suffix), 60 + flag + f); |
| 204 assertTrue(re.test(cyrillic.MIDDLE), 61 + flag + f); | 195 assertTrue(re.test(cyrillic.MIDDLE), 61 + flag + f); |
| 205 assertEquals(ignore_case || full, re.test(cyrillic.middle), 62 + flag + f)
; | 196 assertEquals(ignore_case || full, re.test(cyrillic.middle), 62 + flag + f)
; |
| 206 } | 197 } |
| 207 } | 198 } |
| 208 } | 199 } |
| OLD | NEW |