assertNan()
最后更新于:2022-04-01 03:47:55
# assertNan()
>[info] ## assertNan(mixed $variable[, string $message = ''])
当 `$variable` 不是 `NAN` 时报告错误,错误讯息由 `$message` 指定。
**Example A.31. assertNan() 的用法**
~~~
<?php
class NanTest extends PHPUnit_Framework_TestCase
{
public function testFailure()
{
$this->assertNan(1);
}
}
?>
~~~
~~~
phpunit NanTest
PHPUnit 5.0.0 by Sebastian Bergmann and contributors.
F
Time: 0 seconds, Memory: 5.00Mb
There was 1 failure:
1) NanTest::testFailure
Failed asserting that 1 is nan.
/home/sb/NanTest.php:6
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
~~~