1 // Copyright 2013 the V8 project authors. All rights reserved. 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions 6 // are met: 7 // 1. Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // 2. Redistributions in binary form must reproduce the above copyright 10 // notice, this list of conditions and the following disclaimer in the 11 // documentation and/or other materials provided with the distribution. 12 // 13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY 14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 24 description("https://bugs.webkit.org/show_bug.cgi?id=82063"); 25 26 shouldBeTrue('//i.test("")'); 27 shouldBeTrue('//i.test("")'); 28 shouldBeTrue('//i.test("")'); 29 shouldBeTrue('//i.test("")'); 30 31 // Simple case, has no canonical equivalents 32 shouldBeTrue('/\u1f16/i.test("\u1f16")') 33 34 // Test the sets of USC2 code points that have more than one canonically equivalent value. 35 function ucs2CodePoint(x) 36 { 37 var s = x.toString(16); 38 while (s.length < 4) 39 s = 0 + s; 40 return eval('"\\u' + s + '"'); 41 } 42 function testSet(set) 43 { 44 for (i in set) { 45 for (j in set) { 46 shouldBeTrue('/' + ucs2CodePoint(set[i]) + '/i.test("' + ucs2CodePoint(set[j]) + '")') 47 shouldBeTrue('/[' + ucs2CodePoint(set[i] - 1) + '-' + ucs2CodePoint(set[i] + 1) + ']/i.test("' + ucs2CodePoint(set[j]) + '")') 48 } 49 } 50 } 51 testSet([ 0x01c4, 0x01c5, 0x01c6 ]); 52 testSet([ 0x01c7, 0x01c8, 0x01c9 ]); 53 testSet([ 0x01ca, 0x01cb, 0x01cc ]); 54 testSet([ 0x01f1, 0x01f2, 0x01f3 ]); 55 testSet([ 0x0392, 0x03b2, 0x03d0 ]); 56 testSet([ 0x0395, 0x03b5, 0x03f5 ]); 57 testSet([ 0x0398, 0x03b8, 0x03d1 ]); 58 testSet([ 0x0345, 0x0399, 0x03b9, 0x1fbe ]); 59 testSet([ 0x039a, 0x03ba, 0x03f0 ]); 60 testSet([ 0x00b5, 0x039c, 0x03bc ]); 61 testSet([ 0x03a0, 0x03c0, 0x03d6 ]); 62 testSet([ 0x03a1, 0x03c1, 0x03f1 ]); 63 testSet([ 0x03a3, 0x03c2, 0x03c3 ]); 64 testSet([ 0x03a6, 0x03c6, 0x03d5 ]); 65 testSet([ 0x1e60, 0x1e61, 0x1e9b ]); 66 67 // Test a couple of lo/hi pairs 68 shouldBeTrue('/\u03cf/i.test("\u03cf")') 69 shouldBeTrue('/\u03d7/i.test("\u03cf")') 70 shouldBeTrue('/\u03cf/i.test("\u03d7")') 71 shouldBeTrue('/\u03d7/i.test("\u03d7")') 72 shouldBeTrue('/\u1f11/i.test("\u1f11")') 73 shouldBeTrue('/\u1f19/i.test("\u1f11")') 74 shouldBeTrue('/\u1f11/i.test("\u1f19")') 75 shouldBeTrue('/\u1f19/i.test("\u1f19")') 76 77 // Test an aligned alternating capitalization pair. 78 shouldBeFalse('/\u0489/i.test("\u048a")') 79 shouldBeTrue('/\u048a/i.test("\u048a")') 80 shouldBeTrue('/\u048b/i.test("\u048a")') 81 shouldBeFalse('/\u048c/i.test("\u048a")') 82 shouldBeFalse('/\u0489/i.test("\u048b")') 83 shouldBeTrue('/\u048a/i.test("\u048b")') 84 shouldBeTrue('/\u048b/i.test("\u048b")') 85 shouldBeFalse('/\u048c/i.test("\u048b")') 86 shouldBeTrue('/[\u0489-\u048a]/i.test("\u048b")') 87 shouldBeTrue('/[\u048b-\u048c]/i.test("\u048a")') 88 89 // Test an unaligned alternating capitalization pair. 90 shouldBeFalse('/\u04c4/i.test("\u04c5")') 91 shouldBeTrue('/\u04c5/i.test("\u04c5")') 92 shouldBeTrue('/\u04c6/i.test("\u04c5")') 93 shouldBeFalse('/\u04c7/i.test("\u04c5")') 94 shouldBeFalse('/\u04c4/i.test("\u04c6")') 95 shouldBeTrue('/\u04c5/i.test("\u04c6")') 96 shouldBeTrue('/\u04c6/i.test("\u04c6")') 97 shouldBeFalse('/\u04c7/i.test("\u04c6")') 98 shouldBeTrue('/[\u04c4-\u04c5]/i.test("\u04c6")') 99 shouldBeTrue('/[\u04c6-\u04c7]/i.test("\u04c5")') 100 101 var successfullyParsed = true; 102