-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assert: Introduce strict boolean true/false assertions
- Loading branch information
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
layout: default | ||
title: false | ||
description: A strict boolean false comparison. | ||
categories: | ||
- assert | ||
--- | ||
|
||
## `false( actual [, message ] )` | ||
|
||
A boolean check, equivalent to JUnit's `assertFalse()`. Passes if the first argument is false. | ||
|
||
| name | description | | ||
|--------------------|--------------------------------------| | ||
| `actual` | Expression being tested | | ||
| `message` (string) | A short description of the assertion | | ||
|
||
### Description | ||
|
||
`false()` requires just one argument. If the argument evaluates to false, the assertion passes; otherwise, it fails. | ||
|
||
[`true()`](/assert/true) can be used to explicitly test for a true value. | ||
|
||
### Examples | ||
|
||
```js | ||
QUnit.test( "false test", function( assert ) { | ||
assert.false( false, "false succeeds" ); | ||
|
||
assert.false( "not-empty", "not-empty string fails" ); | ||
assert.false( "", "empty string fails" ); | ||
assert.false( 1, "1 fails" ); | ||
assert.false( true, "true fails" ); | ||
assert.false( NaN, "NaN fails" ); | ||
assert.false( null, "null fails" ); | ||
assert.false( undefined, "undefined fails" ); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
layout: default | ||
title: true | ||
description: A strict boolean true comparison. | ||
categories: | ||
- assert | ||
--- | ||
|
||
## `true( actual [, message ] )` | ||
|
||
A boolean check, equivalent to JUnit's `assertTrue()`. Passes if the first argument is `true`. | ||
|
||
| name | description | | ||
|--------------------|--------------------------------------| | ||
| `actual` | Expression being tested | | ||
| `message` (string) | A short description of the assertion | | ||
|
||
### Description | ||
|
||
`true()` requires just one argument. If the argument evaluates to true, the assertion passes; otherwise, it fails. | ||
|
||
[`false()`](/assert/false) can be used to explicitly test for a false value. | ||
|
||
### Examples | ||
|
||
```js | ||
QUnit.test( "true test", function( assert ) { | ||
assert.true( true, "true succeeds" ); | ||
|
||
assert.true( "non-empty", "non-empty string fails" ); | ||
assert.true( "", "empty string fails" ); | ||
assert.true( 0, "0 fails" ); | ||
assert.true( false, "false fails" ); | ||
assert.true( NaN, "NaN fails" ); | ||
assert.true( null, "null fails" ); | ||
assert.true( undefined, "undefined fails" ); | ||
}); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters