Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | |
| 2 // Redistribution and use in source and binary forms, with or without | |
| 3 // modification, are permitted provided that the following conditions are | |
| 4 // met: | |
| 5 // | |
| 6 // * Redistributions of source code must retain the above copyright | |
| 7 // notice, this list of conditions and the following disclaimer. | |
| 8 // * Redistributions in binary form must reproduce the above | |
| 9 // copyright notice, this list of conditions and the following | |
| 10 // disclaimer in the documentation and/or other materials provided | |
| 11 // with the distribution. | |
| 12 // * Neither the name of Google Inc. nor the names of its | |
| 13 // contributors may be used to endorse or promote products derived | |
| 14 // from this software without specific prior written permission. | |
| 15 // | |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 27 | |
| 28 // Flags: --harmony-regexps | |
| 29 | |
| 30 var re = /foo.bar/; | |
| 31 | |
| 32 assertTrue(!!"foo*bar".match(re)); | |
| 33 assertTrue(!!"..foo*bar".match(re)); | |
| 34 | |
| 35 var plain = /foobar/; | |
| 36 | |
| 37 assertTrue(!!"foobar".match(plain)); | |
| 38 assertTrue(!!"..foobar".match(plain)); | |
| 39 | |
| 40 var sticky = /foo.bar/y; | |
| 41 | |
| 42 assertTrue(!!"foo*bar".match(sticky)); | |
| 43 assertFalse(!!"..foo*bar".match(sticky)); | |
| 44 | |
| 45 var stickyplain = /foobar/y; | |
| 46 | |
| 47 assertTrue(!!"foobar".match(stickyplain)); | |
| 48 assertFalse(!!"..foobar".match(stickyplain)); | |
|
Yang
2014/09/15 09:23:16
According to 21.2.5.2.2, 19, we should set .lastIn
Erik Corry
2014/09/16 17:49:40
Done.
| |
| 49 | |
| 50 var global = /foo.bar/g; | |
| 51 | |
| 52 assertTrue(global.test("foo*bar")); | |
| 53 assertFalse(global.test("..foo*bar")); | |
| 54 global.lastIndex = 0; | |
| 55 assertTrue(global.test("..foo*bar")); | |
| 56 | |
| 57 var plainglobal = /foobar/g; | |
| 58 | |
| 59 assertTrue(plainglobal.test("foobar")); | |
| 60 assertFalse(plainglobal.test("foobar")); | |
| 61 plainglobal.lastIndex = 0; | |
| 62 assertTrue(plainglobal.test("foobar")); | |
| 63 | |
| 64 var stickyglobal = /foo.bar/gy; | |
| 65 | |
| 66 assertTrue(stickyglobal.test("foo*bar")); | |
| 67 assertFalse(stickyglobal.test("..foo*bar")); | |
| 68 stickyglobal.lastIndex = 0; | |
| 69 assertFalse(stickyglobal.test("..foo*bar")); | |
| 70 stickyglobal.lastIndex = 2; | |
| 71 assertTrue(stickyglobal.test("..foo*bar")); | |
| 72 | |
| 73 var stickyplainglobal = /foobar/yg; | |
| 74 assertTrue(stickyplainglobal.sticky); | |
| 75 stickyplainglobal.sticky = false; | |
| 76 | |
| 77 assertTrue(stickyplainglobal.test("foobar")); | |
| 78 assertFalse(stickyplainglobal.test("..foobar")); | |
| 79 stickyplainglobal.lastIndex = 0; | |
| 80 assertFalse(stickyplainglobal.test("..foobar")); | |
| 81 stickyplainglobal.lastIndex = 2; | |
| 82 assertTrue(stickyplainglobal.test("..foobar")); | |
| 83 | |
| 84 assertEquals("/foo.bar/gy", "" + stickyglobal); | |
| 85 assertEquals("/foo.bar/g", "" + global); | |
| 86 | |
| 87 assertTrue(stickyglobal.sticky); | |
| 88 stickyglobal.sticky = false; | |
| 89 assertTrue(stickyglobal.sticky); | |
| 90 | |
| 91 var stickyglobal2 = new RegExp("foo.bar", "gy"); | |
| 92 assertTrue(stickyglobal2.test("foo*bar")); | |
| 93 assertFalse(stickyglobal2.test("..foo*bar")); | |
| 94 stickyglobal2.lastIndex = 0; | |
| 95 assertFalse(stickyglobal2.test("..foo*bar")); | |
| 96 stickyglobal2.lastIndex = 2; | |
| 97 assertTrue(stickyglobal2.test("..foo*bar")); | |
| 98 | |
| 99 assertEquals("/foo.bar/gy", "" + stickyglobal2); | |
| 100 | |
| 101 assertTrue(stickyglobal2.sticky); | |
| 102 stickyglobal2.sticky = false; | |
| 103 assertTrue(stickyglobal2.sticky); | |
| OLD | NEW |