return actual.getTime() === expected.getTime();
// 7.3 If the expected value is a RegExp object, the actual value is
- // equivalent if it is also a RegExp object with the same source.
+ // equivalent if it is also a RegExp object with the same source and
+ // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
} else if (actual instanceof RegExp && expected instanceof RegExp) {
- return actual.source === expected.source;
+ return actual.source === expected.source &&
+ actual.global === expected.global &&
+ actual.multiline === expected.multiline &&
+ actual.lastIndex === expected.lastIndex &&
+ actual.ignoreCase === expected.ignoreCase;
// 7.4. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
// 7.3
assert.doesNotThrow(makeBlock(a.deepEqual, /a/, /a/));
+assert.doesNotThrow(makeBlock(a.deepEqual, /a/g, /a/g));
+assert.doesNotThrow(makeBlock(a.deepEqual, /a/i, /a/i));
+assert.doesNotThrow(makeBlock(a.deepEqual, /a/m, /a/m));
+assert.doesNotThrow(makeBlock(a.deepEqual, /a/igm, /a/igm));
assert.throws(makeBlock(a.deepEqual, /ab/, /a/));
+assert.throws(makeBlock(a.deepEqual, /a/g, /a/));
+assert.throws(makeBlock(a.deepEqual, /a/i, /a/));
+assert.throws(makeBlock(a.deepEqual, /a/m, /a/));
+assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im));
+
+var re1 = /a/;
+re1.lastIndex = 3;
+assert.throws(makeBlock(a.deepEqual, re1, /a/));
// 7.4