Skip to content

Commit

Permalink
Add missing test files
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jan 7, 2012
1 parent fe55403 commit 72ba140
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/Queue/iteration.phpt
@@ -0,0 +1,25 @@
--TEST--
Queue: Test iteration
--FILE--
<?php

$queue = new SPL\Datastructures\Queue;
var_dump($queue instanceof Traversable);

$queue->push('x');
$queue->push('y');
$queue->push('z');

foreach ($queue as $index => $item) {
var_dump($index, $item);
}

?>
--EXPECT--
bool(true)
int(0)
string(1) "x"
int(1)
string(1) "y"
int(2)
string(1) "z"
23 changes: 23 additions & 0 deletions tests/Queue/popPeekError.phpt
@@ -0,0 +1,23 @@
--TEST--
Queue: UnderflowException on $queue->peek() and $queue->pop() for empty queue
--FILE--
<?php

$queue = new SPL\Datastructures\Queue;

try {
$queue->peek();
} catch (UnderflowException $e) {
var_dump($e->getMessage());
}

try {
$queue->pop();
} catch (UnderflowException $e) {
var_dump($e->getMessage());
}

?>
--EXPECT--
string(25) "Can't peek an empty queue"
string(24) "Can't pop an empty queue"
25 changes: 25 additions & 0 deletions tests/Stack/iteration.phpt
@@ -0,0 +1,25 @@
--TEST--
Stack: Test iteration
--FILE--
<?php

$stack = new SPL\Datastructures\Stack;
var_dump($stack instanceof Traversable);

$stack->push('x');
$stack->push('y');
$stack->push('z');

foreach ($stack as $index => $item) {
var_dump($index, $item);
}

?>
--EXPECT--
bool(true)
int(0)
string(1) "x"
int(1)
string(1) "y"
int(2)
string(1) "z"
23 changes: 23 additions & 0 deletions tests/Stack/popPeekError.phpt
@@ -0,0 +1,23 @@
--TEST--
Stack: UnderflowException on $stack->peek() and $stack->pop() for empty stack
--FILE--
<?php

$stack = new SPL\Datastructures\Stack;

try {
$stack->peek();
} catch (UnderflowException $e) {
var_dump($e->getMessage());
}

try {
$stack->pop();
} catch (UnderflowException $e) {
var_dump($e->getMessage());
}

?>
--EXPECT--
string(25) "Can't peek an empty stack"
string(24) "Can't pop an empty stack"

0 comments on commit 72ba140

Please sign in to comment.