diff --git a/.gitignore b/.gitignore
index 97854c5..41f3f21 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
/node_modules/
/tmp/
*.tgz
+.idea
diff --git a/README.md b/README.md
index a5d2fc8..f6c4afa 100644
--- a/README.md
+++ b/README.md
@@ -230,11 +230,11 @@ Must.js, please see the [Must.js API Documentation][api].
- [null](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.null)()
- [number](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.number)()
- [object](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.object)()
-- [own](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.own)(property, [value])
+- [own](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.own)(property, [value, strict])
- [ownKeys](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.ownKeys)(keys)
-- [ownProperty](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.ownProperty)(property, [value])
+- [ownProperty](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.ownProperty)(property, [value, strict])
- [permutationOf](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.permutationOf)(expected)
-- [property](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.property)(property, [value])
+- [property](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.property)(property, [value, strict])
- [regexp](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.regexp)()
- [string](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.string)()
- [throw](https://github.com/moll/js-must/blob/master/doc/API.md#Must.prototype.throw)([constructor], [expected])
diff --git a/doc/API.md b/doc/API.md
index 759d61d..86d0f1f 100644
--- a/doc/API.md
+++ b/doc/API.md
@@ -44,11 +44,11 @@ Must.js API Documentation
- [null](#Must.prototype.null)()
- [number](#Must.prototype.number)()
- [object](#Must.prototype.object)()
-- [own](#Must.prototype.own)(property, [value])
+- [own](#Must.prototype.own)(property, [value, strict])
- [ownKeys](#Must.prototype.ownKeys)(keys)
-- [ownProperty](#Must.prototype.ownProperty)(property, [value])
+- [ownProperty](#Must.prototype.ownProperty)(property, [value, strict])
- [permutationOf](#Must.prototype.permutationOf)(expected)
-- [property](#Must.prototype.property)(property, [value])
+- [property](#Must.prototype.property)(property, [value, strict])
- [regexp](#Must.prototype.regexp)()
- [string](#Must.prototype.string)()
- [throw](#Must.prototype.throw)([constructor], [expected])
@@ -566,7 +566,7 @@ Assert object is an.. object.
```
-### Must.prototype.own(property, [value])
+### Must.prototype.own(property, [value, strict])
Alias of [`ownProperty`](#Must.prototype.ownProperty).
@@ -583,9 +583,10 @@ Pass an array of strings as `keys`.
```
-### Must.prototype.ownProperty(property, [value])
+### Must.prototype.ownProperty(property, [value, strict])
Assert that an object has own property `property`.
Optionally assert it *equals* (`===`) to `value`.
+Third parameter `false` makes the equality check non-strict.
**Does not** take **inherited properties** into account. To do so, see
[`property`](#Must.prototype.property).
@@ -610,9 +611,10 @@ Elements are checked with strict equals (`===`).
```
-### Must.prototype.property(property, [value])
+### Must.prototype.property(property, [value, strict])
Assert that an object has property `property`.
Optionally assert it *equals* (`===`) to `value`.
+Third parameter `false` makes the equality check non-strict.
Takes **inherited properties** into account. To not do so, see
[`ownProperty`](#Must.prototype.ownProperty).
diff --git a/lib/assertions.js b/lib/assertions.js
index 72a1058..37e336a 100644
--- a/lib/assertions.js
+++ b/lib/assertions.js
@@ -692,6 +692,7 @@ exports.frozen = function() {
/**
* Assert that an object has property `property`.
* Optionally assert it *equals* (`===`) to `value`.
+ * For non-strict equality, provide 'false' as third parameter
*
* Takes **inherited properties** into account. To not do so, see
* [`ownProperty`](#Must.prototype.ownProperty).
@@ -703,20 +704,23 @@ exports.frozen = function() {
* @method property
* @param property
* @param [value]
+ * @param [strict_equals]
*/
-exports.property = function(property, expected) {
+exports.property = function(property, expected, strict_equals) {
var ok = this.actual != null
ok = ok && property in Object(this.actual)
if (ok && arguments.length > 1) ok = this.actual[property] === expected
+ if (ok && arguments.length > 2 && strict_equals === false) ok = eql(this.actual[property], expected)
var msg = "have property \"" + property + "\""
- if (arguments.length > 1) msg += " equal to " + inspect(expected)
+ if (arguments.length > 1) msg += " equal to " + inspect(expected) + ", but is " + inspect(this.actual[property])
insist.call(this, ok, msg)
}
/**
* Assert that an object has own property `property`.
* Optionally assert it *equals* (`===`) to `value`.
+ * For non-strict equality, provide 'false' as third parameter
*
* **Does not** take **inherited properties** into account. To do so, see
* [`property`](#Must.prototype.property).
@@ -727,14 +731,16 @@ exports.property = function(property, expected) {
* @method ownProperty
* @param property
* @param [value]
+ * @param [strict_equals]
*/
-exports.ownProperty = function(property, expected) {
+exports.ownProperty = function(property, expected, strict_equals) {
var ok = this.actual != null
ok = ok && Object.prototype.hasOwnProperty.call(this.actual, property)
if (ok && arguments.length > 1) ok = this.actual[property] === expected
+ if (ok && arguments.length > 2 && strict_equals === false) ok = eql(this.actual[property], expected)
var msg = "have own property \"" + property + "\""
- if (arguments.length > 1) msg += " equal to " + inspect(expected)
+ if (arguments.length > 1) msg += " equal to " + inspect(expected) + ", but is " + inspect(this.actual[property])
insist.call(this, ok, msg)
}
diff --git a/test/assertions_test.js b/test/assertions_test.js
index 9eed40d..47bfe9c 100644
--- a/test/assertions_test.js
+++ b/test/assertions_test.js
@@ -2150,7 +2150,7 @@ function mustPassProperty(name, inheritable) {
mustThrowAssertionError(function() { Must({}).have[name]("love", 69) }, {
actual: {},
- message: "{} must have "+errName+" \"love\" equal to 69"
+ message: "{} must have "+errName+" \"love\" equal to 69, but is undefined"
})
describe(".not", function() {
@@ -2162,7 +2162,7 @@ function mustPassProperty(name, inheritable) {
mustThrowAssertionError(not, {
actual: {love: 69},
- message: "{\"love\":69} must not have "+errName+" \"love\" equal to 69"
+ message: "{\"love\":69} must not have "+errName+" \"love\" equal to 69, but is 69"
})
})
})