Skip to content

Commit

Permalink
[Type] add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
azjezz committed Feb 17, 2021
1 parent 9ad1b77 commit 25f2ed7
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Psl/Type/IsBoolTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Psl\Tests\Type;

use PHPUnit\Framework\TestCase;
use Psl\Math;
use Psl\Type;

final class IsBoolTest extends TestCase
{
public function testIsBool(): void
{
static::assertTrue(Type\is_bool(true));

static::assertFalse(Type\is_bool(123));
static::assertFalse(Type\is_bool(0));
static::assertFalse(Type\is_bool(Math\INT16_MAX));
static::assertFalse(Type\is_bool('5'));
static::assertFalse(Type\is_bool(null));
static::assertFalse(Type\is_bool(5.0));
}
}
24 changes: 24 additions & 0 deletions tests/Psl/Type/IsFloatTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Psl\Tests\Type;

use PHPUnit\Framework\TestCase;
use Psl\Math;
use Psl\Type;

final class IsFloatTest extends TestCase
{
public function testIsFloat(): void
{
static::assertTrue(Type\is_float(5.0));

static::assertFalse(Type\is_float(123));
static::assertFalse(Type\is_float(0));
static::assertFalse(Type\is_float(Math\INT16_MAX));
static::assertFalse(Type\is_float('5'));
static::assertFalse(Type\is_float(true));
static::assertFalse(Type\is_float(null));
}
}
24 changes: 24 additions & 0 deletions tests/Psl/Type/IsNullTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Psl\Tests\Type;

use PHPUnit\Framework\TestCase;
use Psl\Math;
use Psl\Type;

final class IsNullTest extends TestCase
{
public function testIsNull(): void
{
static::assertTrue(Type\is_null(null));

static::assertFalse(Type\is_null(123));
static::assertFalse(Type\is_null(0));
static::assertFalse(Type\is_null(Math\INT16_MAX));
static::assertFalse(Type\is_null('5'));
static::assertFalse(Type\is_null(true));
static::assertFalse(Type\is_null(5.0));
}
}
27 changes: 27 additions & 0 deletions tests/Psl/Type/IsResourceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Psl\Tests\Type;

use PHPUnit\Framework\TestCase;
use Psl\Math;
use Psl\Type;

use const STDOUT;

final class IsResourceTest extends TestCase
{
public function testIsResource(): void
{
static::assertTrue(Type\is_resource(STDOUT));

static::assertFalse(Type\is_resource(null));
static::assertFalse(Type\is_resource(123));
static::assertFalse(Type\is_resource(0));
static::assertFalse(Type\is_resource(Math\INT16_MAX));
static::assertFalse(Type\is_resource('5'));
static::assertFalse(Type\is_resource(true));
static::assertFalse(Type\is_resource(5.0));
}
}

0 comments on commit 25f2ed7

Please sign in to comment.