diff options
| author | Ben Ripkens | 2013-05-20 19:10:04 +0200 |
|---|---|---|
| committer | Igor Minar | 2013-07-13 22:35:17 -0700 |
| commit | a357649da5d9f0633fa8e8a249f58dfc1105698e (patch) | |
| tree | c98e309767a8fb0c0a5fdc832fa575ea5deda807 /test/AngularSpec.js | |
| parent | 332a3c7984229a7e3a9a8a277f92942299616fdb (diff) | |
| download | angular.js-a357649da5d9f0633fa8e8a249f58dfc1105698e.tar.bz2 | |
fix(angular.equals): add support for regular expressions
Regular expression objects didn't used to be considered to be equal when using
'angular.equals'. Dirty checking therefore failed to recognize a
property modification.
Closes #2685
Conflicts:
test/AngularSpec.js
Diffstat (limited to 'test/AngularSpec.js')
| -rw-r--r-- | test/AngularSpec.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 8e4fbb1a..bcb110d7 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -268,6 +268,17 @@ describe('angular', function() { expect(equals(new Date(0), 0)).toBe(false); expect(equals(0, new Date(0))).toBe(false); }); + + it('should compare regular expressions', function() { + expect(equals(/abc/, /abc/)).toBe(true); + expect(equals(/abc/i, new RegExp('abc', 'i'))).toBe(true); + expect(equals(new RegExp('abc', 'i'), new RegExp('abc', 'i'))).toBe(true); + expect(equals(new RegExp('abc', 'i'), new RegExp('abc'))).toBe(false); + expect(equals(/abc/i, /abc/)).toBe(false); + expect(equals(/abc/, /def/)).toBe(false); + expect(equals(/^abc/, /abc/)).toBe(false); + expect(equals(/^abc/, '/^abc/')).toBe(false); + }); }); describe('size', function() { @@ -625,6 +636,23 @@ describe('angular', function() { }); }); + + describe('isRegExp', function() { + it('should return true for RegExp object', function() { + expect(isRegExp(/^foobar$/)).toBe(true); + expect(isRegExp(new RegExp('^foobar$/'))).toBe(true); + }); + + it('should return false for non RegExp objects', function() { + expect(isRegExp([])).toBe(false); + expect(isRegExp('')).toBe(false); + expect(isRegExp(23)).toBe(false); + expect(isRegExp({})).toBe(false); + expect(isRegExp(new Date())).toBe(false); + }); + }); + + describe('compile', function() { it('should link to existing node and create scope', inject(function($rootScope, $compile) { var template = angular.element('<div>{{greeting = "hello world"}}</div>'); |
