Skip to content

Commit d855953

Browse files
elitvyakovljharb
authored andcommitted
s-string: add two tests for String.replace method
1 parent e938fda commit d855953

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/spec/s-string.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,35 @@ describe('String', function () {
3333
);
3434
}).not.toThrow();
3535
});
36+
37+
it('should be 10 arguments in Firefox prior 34 version', function () {
38+
var size = null;
39+
40+
'* alef\n* beth \n* gimel~0\n'.replace(
41+
/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
42+
function (match, m1, m2, m3, m4) {
43+
size = arguments.length;
44+
}
45+
);
46+
47+
expect(size).toBe(10);
48+
});
49+
50+
it('first group have to be undefined and second have to be empty string', function () {
51+
var firstGroup,
52+
secondGroup;
53+
54+
'x'.replace(
55+
/x(.)?(.*)/gm,
56+
function (match, m1, m2) {
57+
firstGroup = m1;
58+
secondGroup = m2;
59+
}
60+
);
61+
62+
expect(firstGroup).toBe(undefined);
63+
expect(secondGroup).toBe('');
64+
});
3665
});
3766

3867
describe('#split()', function () {

0 commit comments

Comments
 (0)