diff options
author | Stig Bakken <ssb@php.net> | 2000-08-27 19:46:06 +0000 |
---|---|---|
committer | Stig Bakken <ssb@php.net> | 2000-08-27 19:46:06 +0000 |
commit | 315f4f5658cf22a17ba06fa2ca2f3d890355873f (patch) | |
tree | 3dd1134c1d1c3821b48fab806884123f09b2d21f /tests/func | |
parent | 7eeda99a055df5a510d3d20526e9adcb42fecdb0 (diff) | |
download | php-git-315f4f5658cf22a17ba06fa2ca2f3d890355873f.tar.gz |
@PHP 3 regression testing framework re-born (Stig)
Took the old PHP 3 regression testing framework and rewrote it in PHP.
Should work on both Windows and UNIX, however I have not tested it on
Windows. See tests/README for how to write tests. Added the PHP 3
tests and converted most of them.
Diffstat (limited to 'tests/func')
-rw-r--r-- | tests/func/001.phpt | 8 | ||||
-rw-r--r-- | tests/func/002.phpt | 22 | ||||
-rw-r--r-- | tests/func/003.phpt | 289 | ||||
-rw-r--r-- | tests/func/004.phpt | 65 | ||||
-rw-r--r-- | tests/func/005.phpt | 22 |
5 files changed, 406 insertions, 0 deletions
diff --git a/tests/func/001.phpt b/tests/func/001.phpt new file mode 100644 index 0000000000..c5553cd8a8 --- /dev/null +++ b/tests/func/001.phpt @@ -0,0 +1,8 @@ +--TEST-- +Strlen() function test +--POST-- +--GET-- +--FILE-- +<?php echo strlen("abcdef")?> +--EXPECT-- +6 diff --git a/tests/func/002.phpt b/tests/func/002.phpt new file mode 100644 index 0000000000..aa752ee13c --- /dev/null +++ b/tests/func/002.phpt @@ -0,0 +1,22 @@ +--TEST-- +Static variables in functions +--POST-- +--GET-- +--FILE-- +<?php +old_function blah ( + static $hey=0,$yo=0; + + echo "hey=".$hey++.", ",$yo--."\n"; +); + +blah(); +blah(); +blah(); +if (isset($hey) || isset($yo)) { + echo "Local variables became global :(\n"; +} +--EXPECT-- +hey=0, 0 +hey=1, -1 +hey=2, -2 diff --git a/tests/func/003.phpt b/tests/func/003.phpt new file mode 100644 index 0000000000..6f21a34a42 --- /dev/null +++ b/tests/func/003.phpt @@ -0,0 +1,289 @@ +--TEST-- +General function test +--POST-- +--GET-- +--FILE-- +<?php + +old_function a ( + echo "hey\n"; +); + +function b($i) +{ + echo "$i\n"; +} + + +function c($i,$j) +{ + echo "Counting from $i to $j\n"; + for ($k=$i; $k<=$j; $k++) { + echo "$k\n"; + } +} + + + +a(); +b("blah"); +a(); +b("blah","blah"); +c(7,14); + +a(); + + +old_function factorial $n ( + if ($n==0 || $n==1) { + return 1; + } else { + return factorial($n-1)*$n; + } +); + + +function factorial2($start, $n) +{ + if ($n<=$start) { + return $start; + } else { + return factorial2($start,$n-1)*$n; + } +} + + +for ($k=0; $k<10; $k++) { + for ($i=0; $i<=10; $i++) { + $n=factorial($i); + echo "factorial($i) = $n\n"; + } +} + + +echo "and now, from a function...\n"; + +old_function call_fact ( + echo "(it should break at 5...)\n"; + for ($i=0; $i<=10; $i++) { + if ($i == 5) break; + $n=factorial($i); + echo "factorial($i) = $n\n"; + } +); + +old_function return4 ( return 4; ); +old_function return7 ( return 7; ); + +for ($k=0; $k<10; $k++) { + call_fact(); +} + +echo "------\n"; +$result = factorial(factorial(3)); +echo "$result\n"; + +$result=factorial2(return4(),return7()); +echo "$result\n"; + +old_function andi $i, $j ( + for ($k=$i ; $k<=$j ; $k++) { + if ($k >5) continue; + echo "$k\n"; + } +); + +andi (3,10); +--EXPECT-- +hey +blah +hey +blah +Counting from 7 to 14 +7 +8 +9 +10 +11 +12 +13 +14 +hey +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +factorial(5) = 120 +factorial(6) = 720 +factorial(7) = 5040 +factorial(8) = 40320 +factorial(9) = 362880 +factorial(10) = 3628800 +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +factorial(5) = 120 +factorial(6) = 720 +factorial(7) = 5040 +factorial(8) = 40320 +factorial(9) = 362880 +factorial(10) = 3628800 +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +factorial(5) = 120 +factorial(6) = 720 +factorial(7) = 5040 +factorial(8) = 40320 +factorial(9) = 362880 +factorial(10) = 3628800 +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +factorial(5) = 120 +factorial(6) = 720 +factorial(7) = 5040 +factorial(8) = 40320 +factorial(9) = 362880 +factorial(10) = 3628800 +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +factorial(5) = 120 +factorial(6) = 720 +factorial(7) = 5040 +factorial(8) = 40320 +factorial(9) = 362880 +factorial(10) = 3628800 +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +factorial(5) = 120 +factorial(6) = 720 +factorial(7) = 5040 +factorial(8) = 40320 +factorial(9) = 362880 +factorial(10) = 3628800 +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +factorial(5) = 120 +factorial(6) = 720 +factorial(7) = 5040 +factorial(8) = 40320 +factorial(9) = 362880 +factorial(10) = 3628800 +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +factorial(5) = 120 +factorial(6) = 720 +factorial(7) = 5040 +factorial(8) = 40320 +factorial(9) = 362880 +factorial(10) = 3628800 +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +factorial(5) = 120 +factorial(6) = 720 +factorial(7) = 5040 +factorial(8) = 40320 +factorial(9) = 362880 +factorial(10) = 3628800 +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +factorial(5) = 120 +factorial(6) = 720 +factorial(7) = 5040 +factorial(8) = 40320 +factorial(9) = 362880 +factorial(10) = 3628800 +and now, from a function... +(it should break at 5...) +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +(it should break at 5...) +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +(it should break at 5...) +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +(it should break at 5...) +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +(it should break at 5...) +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +(it should break at 5...) +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +(it should break at 5...) +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +(it should break at 5...) +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +(it should break at 5...) +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +(it should break at 5...) +factorial(0) = 1 +factorial(1) = 1 +factorial(2) = 2 +factorial(3) = 6 +factorial(4) = 24 +------ +720 +840 +3 +4 +5 + diff --git a/tests/func/004.phpt b/tests/func/004.phpt new file mode 100644 index 0000000000..465cb5d2a1 --- /dev/null +++ b/tests/func/004.phpt @@ -0,0 +1,65 @@ +--TEST-- +General function test +--POST-- +--GET-- +--FILE-- +<?php + +echo "Before function declaration...\n"; + +old_function print_something_multiple_times $something,$times ( + echo "----\nIn function, printing the string \"$something\" $times times\n"; + for ($i=0; $i<$times; $i++) { + echo "$i) $something\n"; + } + echo "Done with function...\n-----\n"; +); + +old_function some_other_function ( + echo "This is some other function, to ensure more than just one function works fine...\n"; +); + + +echo "After function declaration...\n"; + +echo "Calling function for the first time...\n"; +print_something_multiple_times("This works!",10); +echo "Returned from function call...\n"; + +echo "Calling the function for the second time...\n"; +print_something_multiple_times("This like, really works and stuff...",3); +echo "Returned from function call...\n"; + +some_other_function(); + +?> +--EXPECT-- + +Before function declaration... +After function declaration... +Calling function for the first time... +---- +In function, printing the string "This works!" 10 times +0) This works! +1) This works! +2) This works! +3) This works! +4) This works! +5) This works! +6) This works! +7) This works! +8) This works! +9) This works! +Done with function... +----- +Returned from function call... +Calling the function for the second time... +---- +In function, printing the string "This like, really works and stuff..." 3 times +0) This like, really works and stuff... +1) This like, really works and stuff... +2) This like, really works and stuff... +Done with function... +----- +Returned from function call... +This is some other function, to ensure more than just one function works fine... diff --git a/tests/func/005.phpt b/tests/func/005.phpt new file mode 100644 index 0000000000..4a20786df0 --- /dev/null +++ b/tests/func/005.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing register_shutdown_function() +--POST-- +--GET-- +ab+cd+ef+123+test +--FILE-- +<?php + +function foo() +{ + print "foo"; +} + +register_shutdown_function("foo"); + +print "foo() will be called on shutdown...\n"; + +?> +--EXPECT-- +foo() will be called on shutdown... +foo + |