OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 re_text += "(?:a(x))?"; | 148 re_text += "(?:a(x))?"; |
149 haystack += "bx"; | 149 haystack += "bx"; |
150 var re = new RegExp(re_text); | 150 var re = new RegExp(re_text); |
151 assertTrue(re.test(haystack), "$" + i + " setup"); | 151 assertTrue(re.test(haystack), "$" + i + " setup"); |
152 for (var j = 1; j < i - 1; j++) { | 152 for (var j = 1; j < i - 1; j++) { |
153 assertEquals("x", RegExp['$' + j], "$" + j + " in $" + i + " setup"); | 153 assertEquals("x", RegExp['$' + j], "$" + j + " in $" + i + " setup"); |
154 } | 154 } |
155 assertEquals("", RegExp['$' + (i)], "$" + i); | 155 assertEquals("", RegExp['$' + (i)], "$" + i); |
156 } | 156 } |
| 157 |
| 158 RegExp.multiline = "foo"; |
| 159 assertTrue(typeof RegExp.multiline == typeof Boolean(), "RegExp.multiline coerce
s values to booleans"); |
| 160 RegExp.input = Number(); |
| 161 assertTrue(typeof RegExp.input == typeof String(), "RegExp.input coerces values
to booleans"); |
| 162 |
| 163 // Ensure that we save the correct string as the last subject when |
| 164 // we do a match on a sliced string (the top one not the underlying). |
| 165 var foo = "lsdfj sldkfj sdklfj læsdfjl sdkfjlsdk fjsdl fjsdljskdj flsj flsdkj fl
skd regexp: /foobar/\nldkfj sdlkfj sdkl"; |
| 166 assertTrue(/^([a-z]+): (.*)/.test(foo.substring(foo.indexOf("regexp:"))), "regex
p: setup"); |
| 167 assertEquals("regexp", RegExp.$1, "RegExp.$1"); |
OLD | NEW |