-
Notifications
You must be signed in to change notification settings - Fork 780
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( 0, "0 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( 1, "1 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
0a0b7b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This noteworthy change didn't make it into History.md
0a0b7b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raycohen History is updated upon release. This has not yet been released.
https://github.com/qunitjs/qunit/commits/2.10.1
0a0b7b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I was confused as the commit to prep 2.10.1 came later than this.
0a0b7b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the release notes were backported from the
2.10.x-dev
branch. I should have mentioned that in the commit message :)