Skip to content

Commit

Permalink
Merge branch 'xregexp-tostring' of git://github.com/rwstauner/SyntaxH…
Browse files Browse the repository at this point in the history
…ighlighter into merges
  • Loading branch information
alexgorbatchev committed Oct 4, 2011
2 parents 13ef664 + e0207f6 commit 51049e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/XRegExp.js
Expand Up @@ -277,7 +277,7 @@ if (XRegExp) {
r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
// Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed
// matching due to characters outside the match
real.replace.call(str.slice(match.index), r2, function () {
real.replace.call(str.toString().slice(match.index), r2, function () {
for (var i = 1; i < arguments.length - 2; i++) {
if (arguments[i] === undefined)
match[i] = undefined;
Expand Down
28 changes: 28 additions & 0 deletions tests/cases/015_xregexp.html
@@ -0,0 +1,28 @@
<pre id="sh_015_xregexp" class="brush: js;" title="XRegExp tests">
// test XRegExp
</pre>

<script type="text/javascript">
queue(function()
{
module('015_xregexp');

test('test XRegExp', function()
{
(function(){
var desc = 'Overridden RegExp.exec on numeric arguments with empty captures',
match;
try {
match = /(x)?(\d)(\d)/.exec( 213 );
ok(match, desc);
ok(match[0] === "21", 'matched string');
ok(match[1] === undefined, 'empty capture group is undefined');
ok(match[2] === "2", 'matched capture group returned expected string');
ok(match[3] === "1", 'matched capture group returned expected string');
} catch( ex ) {
ok(false, 'Caught Exception: ' + desc + '(' + ex.description + ')');
}
})();
});
});
</script>
3 changes: 2 additions & 1 deletion tests/syntaxhighlighter_tests.html
Expand Up @@ -101,7 +101,8 @@ <h2 id="qunit-userAgent"></h2>
'011_smart_tabs',
'012_server_side',
'013_html_script',
'014_legacy'
'014_legacy',
'015_xregexp'
],
interactionTests = [
'007_collapse_interaction'
Expand Down

0 comments on commit 51049e8

Please sign in to comment.