fix(angular.copy): clone regexp flags correctly

Closes #5781
Closes #8337
This commit is contained in:
Shahar Talmi
2014-07-25 15:31:56 +03:00
committed by Peter Bacon Darwin
parent c03b9e5ec4
commit 86340a59bf
2 changed files with 16 additions and 1 deletions

View File

@@ -55,6 +55,20 @@ describe('angular', function() {
expect(copy(re) === re).toBeFalsy();
});
it("should copy RegExp with flags", function() {
var re = new RegExp('.*', 'gim');
expect(copy(re).global).toBe(true);
expect(copy(re).ignoreCase).toBe(true);
expect(copy(re).multiline).toBe(true);
});
it("should copy RegExp with lastIndex", function() {
var re = /a+b+/g;
var str = 'ab aabb';
expect(re.exec(str)[0]).toEqual('ab');
expect(copy(re).exec(str)[0]).toEqual('aabb');
});
it("should deeply copy literal RegExp", function() {
var objWithRegExp = {
re: /.*/