Tester\Assert::nan PHP Method

nan() public static method

Checks Not a Number assertion.
public static nan ( $actual, $description = NULL ) : void
return void
    public static function nan($actual, $description = NULL)
    {
        self::$counter++;
        if (!is_float($actual) || !is_nan($actual)) {
            self::fail(self::describe('%1 should be NAN', $description), $actual);
        }
    }

Usage Example

示例#1
0
Assert::equal(true, r('["~#\'",true]'));
Assert::equal(false, r('["~#\'",false]'));
Assert::equal(['~foo'], r('["~~foo"]'));
Assert::equal(['^foo'], r('["~^foo"]'));
Assert::equal([], r('[]'));
Assert::equal(['foo'], r('["foo"]'));
Assert::equal([0], r('[0]'));
Assert::equal([1], r('[1]'));
Assert::equal([2], r('[2]'));
Assert::equal([2.5], r('[2.5]'));
Assert::equal([null], r('[null]'));
Assert::equal([true], r('[true]'));
Assert::equal([false], r('[false]'));
Assert::equal([1, 2, 3], r('[1,2,3]'));
Assert::equal(['', 'a', 'ab', 'abc'], r('["","a","ab","abc"]'));
Assert::nan(r('["~zNaN"]')[0]);
Assert::equal([INF], r('["~zINF"]'));
Assert::equal([-INF], r('["~z-INF"]'));
Assert::equal(new Map([]), r('["^ "]'));
Assert::equal(new Map(['foo', 'bar']), r('["^ ","foo","bar"]'));
Assert::equal(new Map([6, 'six']), r('["^ ","~i6","six"]'));
Assert::equal(new Map([1.25, 'x']), r('["^ ","~d1.25","x"]'));
Assert::equal(new Map([true, 'x']), r('["^ ","~?t","x"]'));
Assert::equal(new Map([false, 'x']), r('["^ ","~?f","x"]'));
Assert::equal(new Map([null, 'x']), r('["^ ","~_","x"]'));
//Assert::equal(new Map([NAN, 'x']), r('["^ ","~zNaN","x"]'));
Assert::equal(new Map([INF, 'x']), r('["^ ","~zINF","x"]'));
Assert::equal(new Map([-INF, 'x']), r('["^ ","~z-INF","x"]'));
Assert::equal(new Map([new Symbol('a'), 'b']), r('["^ ","~$a","b"]'));
Assert::equal(new Map([new Keyword('a'), 'b']), r('["^ ","~:a","b"]'));
Assert::equal(new Map([['a'], 'b']), r('["~#cmap",[["a"],"b"]]'));