牛骨文教育服务平台(让学习变的简单)

assertNan()

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.