Skip to content

Commit

Permalink
Signed-off-by: Katsuki Shuto <stk2k@sazysoft.com>
Browse files Browse the repository at this point in the history
  • Loading branch information
stk2k committed Jun 5, 2021
1 parent b66af39 commit 0f9e216
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
11 changes: 8 additions & 3 deletions test/ArrayListTest.php
Expand Up @@ -218,9 +218,14 @@ public function testSort()

$list = new ArrayList([12, 3, -1, 0, 4, 1.2, 'kiwi', 'apple']);
$ret = $list->sort();
print_r($list->toArray());
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $list->toArray());
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $ret->toArray());
if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
$this->assertSame([-1, 0, 1.2, 3, 4, 12, 'apple', 'kiwi'], $list->toArray());
$this->assertSame([-1, 0, 1.2, 3, 4, 12, 'apple', 'kiwi'], $ret->toArray());
}
else{
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $list->toArray());
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $ret->toArray());
}
$this->assertInstanceOf(ArrayList::class, $ret);

$list = new ArrayList([12, 3, -1, 0, 4, 1.2, 'kiwi', 'apple']);
Expand Down
10 changes: 8 additions & 2 deletions test/QueueTest.php
Expand Up @@ -47,8 +47,14 @@ public function testSort()

$queue = new Queue([12, 3, -1, 0, 4, 1.2, 'kiwi', 'apple']);
$ret = $queue->sort();
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $queue->toArray());
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $ret->toArray());
if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
$this->assertSame([-1, 0, 1.2, 3, 4, 12, 'apple', 'kiwi'], $queue->toArray());
$this->assertSame([-1, 0, 1.2, 3, 4, 12, 'apple', 'kiwi'], $ret->toArray());
}
else{
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $queue->toArray());
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $ret->toArray());
}
$this->assertInstanceOf(Queue::class, $ret);

$queue = new Queue([12, 3, -1, 0, 4, 1.2, 'kiwi', 'apple']);
Expand Down
10 changes: 8 additions & 2 deletions test/StackTest.php
Expand Up @@ -98,8 +98,14 @@ public function testSort()

$list = new Stack([12, 3, -1, 0, 4, 1.2, 'kiwi', 'apple']);
$ret = $list->sort();
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $list->toArray());
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $ret->toArray());
if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
$this->assertSame([-1, 0, 1.2, 3, 4, 12, 'apple', 'kiwi'], $list->toArray());
$this->assertSame([-1, 0, 1.2, 3, 4, 12, 'apple', 'kiwi'], $ret->toArray());
}
else{
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $list->toArray());
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $ret->toArray());
}
$this->assertInstanceOf(Stack::class, $ret);

$list = new Stack([12, 3, -1, 0, 4, 1.2, 'kiwi', 'apple']);
Expand Down
10 changes: 8 additions & 2 deletions test/VectorTest.php
Expand Up @@ -290,8 +290,14 @@ public function testSort()

$vec = new Vector([12, 3, -1, 0, 4, 1.2, 'kiwi', 'apple']);
$ret = $vec->sort();
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $vec->toArray());
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $ret->toArray());
if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
$this->assertSame([-1, 0, 1.2, 3, 4, 12, 'apple', 'kiwi'], $vec->toArray());
$this->assertSame([-1, 0, 1.2, 3, 4, 12, 'apple', 'kiwi'], $ret->toArray());
}
else{
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $vec->toArray());
$this->assertSame([-1, 0, 'apple', 'kiwi', 1.2, 3, 4, 12], $ret->toArray());
}
$this->assertInstanceOf(Vector::class, $ret);

$vec = new Vector([12, 3, -1, 0, 4, 1.2, 'kiwi', 'apple']);
Expand Down

0 comments on commit 0f9e216

Please sign in to comment.