-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assert: Introduce strict boolean assertions. #1445
Changes from 3 commits
6ad47f3
7cb7885
bc45fb9
f59c95f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
layout: default | ||
title: false | ||
description: A boolean check. Passes if the first argument is false. | ||
categories: | ||
- assert | ||
--- | ||
|
||
## `false( state [, message ] )` | ||
|
||
A boolean check, inverse of `true()` equivalent to Chais's `assert.isFalse()`, and JUnit's `assertFalse()`. Passes if the first argument is false. | ||
|
||
| name | description | | ||
|--------------------|--------------------------------------| | ||
| state | Expression being tested | | ||
| message (string) | A short description of the assertion | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing backticks :) |
||
|
||
### Description | ||
|
||
`false()` requires just one argument. If the argument evaluates to false, the assertion passes; otherwise, it fails. If a second message argument is provided, it will be displayed in place of the result. | ||
Krinkle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Examples: | ||
ventuno marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```js | ||
QUnit.test( "false test", function( assert ) { | ||
assert.false( false, "false succeeds" ); | ||
|
||
assert.false( "", "empty string fails" ); | ||
assert.false( NaN, "NaN fails" ); | ||
assert.false( null, "null fails" ); | ||
assert.false( undefined, "undefined fails" ); | ||
assert.false( true, "true fails" ); | ||
assert.false( 1, "1 fails" ); | ||
assert.false( "not-empty", "not-empty string fails" ); | ||
}); | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
layout: default | ||
title: true | ||
description: A boolean check, equivalent to Chai's assert.isTrue() and JUnit's assertTrue(). Passes if the first argument is true. | ||
categories: | ||
- assert | ||
redirect_from: | ||
- "/true/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many files contain this for compat with URLs from an older iteration of the API doc site (which was based on WordPress and jquer-wp-content). Not needed for new pages. I'll omit this while landing. |
||
--- | ||
|
||
## `true( state [, message ] )` | ||
|
||
A boolean check, equivalent to Chai's assert.true() and JUnit's assertTrue(). Passes if the first argument is `true`. | ||
|
||
| name | description | | ||
|--------------------|--------------------------------------| | ||
| `state` | Expression being tested | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a left-over from |
||
| `message` (string) | A short description of the assertion | | ||
|
||
### Description | ||
|
||
The most basic assertion in QUnit, `true()` requires just one argument. If the argument evaluates to true, the assertion passes; otherwise, it fails. If a second message argument is provided, it will be displayed in place of the result. | ||
|
||
```js | ||
QUnit.test( "true test", function( assert ) { | ||
assert.true( true, "true succeeds" ); | ||
|
||
assert.true( "non-empty", "non-empty string fails" ); | ||
assert.true( false, "false fails" ); | ||
assert.true( 0, "0 fails" ); | ||
assert.true( NaN, "NaN fails" ); | ||
assert.true( "", "empty string fails" ); | ||
assert.true( null, "null fails" ); | ||
assert.true( undefined, "undefined fails" ); | ||
}); | ||
``` | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Chai's
:)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.
Good catch: fixed.