Skip to content

Commit

Permalink
s-string: add two tests for String.replace method
Browse files Browse the repository at this point in the history
  • Loading branch information
elitvyakov committed Nov 24, 2016
1 parent b291cfa commit 58f4419
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/spec/s-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@ describe('String', function () {
);
}).not.toThrow();
});

it('should be 10 arguments in Firefox prior 34 version', function () {
var size = null;

'* alef\n* beth \n* gimel~0\n'.replace(
/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
function (match, m1, m2, m3, m4) {
size = arguments.length;
}
);

expect(size).toBe(10);
});

it('first group have to be undefined and second have to be empty string', function () {
var firstGroup,
secondGroup;

'x'.replace(
/x(.)?(.*)/gm,
function (match, m1, m2) {
firstGroup = m1;
secondGroup = m2;
}
);

expect(firstGroup).toBe(undefined);
expect(secondGroup).toBe('');
});
});

describe('#split()', function () {
Expand Down

0 comments on commit 58f4419

Please sign in to comment.