OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // 1. Redistributions of source code must retain the above copyright | 7 // 1. Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // 2. Redistributions in binary form must reproduce the above copyright | 9 // 2. Redistributions in binary form must reproduce the above copyright |
10 // notice, this list of conditions and the following disclaimer in the | 10 // notice, this list of conditions and the following disclaimer in the |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 shouldThrow("re.compile(new RegExp('c'), 'i');"); | 49 shouldThrow("re.compile(new RegExp('c'), 'i');"); |
50 | 50 |
51 // It's OK to supply a second argument, as long as the argument is "undefined". | 51 // It's OK to supply a second argument, as long as the argument is "undefined". |
52 re.compile(re, undefined); | 52 re.compile(re, undefined); |
53 shouldBe("re.toString()", "'/c/i'"); | 53 shouldBe("re.toString()", "'/c/i'"); |
54 | 54 |
55 shouldThrow("re.compile(new RegExp('+'));"); | 55 shouldThrow("re.compile(new RegExp('+'));"); |
56 | 56 |
57 re.compile(undefined); | 57 re.compile(undefined); |
58 shouldBe("re.toString()", "'/undefined/'"); | 58 shouldBe("re.toString()", "'/(?:)/'"); |
59 | 59 |
60 re.compile(null); | 60 re.compile(null); |
61 shouldBe("re.toString()", "'/null/'"); | 61 shouldBe("re.toString()", "'/null/'"); |
62 | 62 |
63 re.compile(); | 63 re.compile(); |
64 shouldBe("re.toString()", "'/(?:)/'"); | 64 shouldBe("re.toString()", "'/(?:)/'"); |
65 | 65 |
66 re.compile("z", undefined); | 66 re.compile("z", undefined); |
67 shouldBe("re.toString()", "'/z/'"); | 67 shouldBe("re.toString()", "'/z/'"); |
68 | 68 |
69 // Compiling should reset lastIndex. | 69 // Compiling should reset lastIndex. |
70 re.lastIndex = 100; | 70 re.lastIndex = 100; |
71 re.compile(/a/g); | 71 re.compile(/a/g); |
72 shouldBe("re.lastIndex", "0"); | 72 shouldBe("re.lastIndex", "0"); |
73 re.exec("aaa"); | 73 re.exec("aaa"); |
74 shouldBe("re.lastIndex", "1"); | 74 shouldBe("re.lastIndex", "1"); |
OLD | NEW |