summaryrefslogtreecommitdiff
path: root/tests/quicktester.inc
diff options
context:
space:
mode:
authorJeroen van Wolffelaar <jeroen@php.net>2001-08-05 18:38:48 +0000
committerJeroen van Wolffelaar <jeroen@php.net>2001-08-05 18:38:48 +0000
commit860be31caee9fd58a31cb14fbd3f67ec9c76d344 (patch)
treea2eb628f027ab4e29a8fe335384ef3fcfcdf1470 /tests/quicktester.inc
parentba211eef91e6ad94d6aeecde9217da5f84c20657 (diff)
downloadphp-git-860be31caee9fd58a31cb14fbd3f67ec9c76d344.tar.gz
More tests
Diffstat (limited to 'tests/quicktester.inc')
-rw-r--r--tests/quicktester.inc35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/quicktester.inc b/tests/quicktester.inc
new file mode 100644
index 0000000000..08e3c0a40f
--- /dev/null
+++ b/tests/quicktester.inc
@@ -0,0 +1,35 @@
+<?php
+ /*
+ Helper for simple tests to check return-value. Usage:
+
+ $tests = <<<TESTS
+ expected_return_value === expression
+ 2 === 1+1
+ 4 === 2*2
+ FALSE === @ fopen('non_existent_file')
+TESTS;
+ include( '../../../(../)tests/quicktester.inc' );
+
+ Expect: OK
+
+ Remember to NOT put a trailing ; after a line!
+
+ */
+ error_reporting(E_ALL);
+ $tests = explode("\n",$tests);
+ $success = TRUE;
+ foreach ($tests as $test)
+ {
+ $res = eval("return ($test);");
+ $success = $success && $res;
+ if (!$res)
+ {
+ echo "\nAssert failed:\n";
+ echo "$test\n";
+ list($left,$right) = explode('===',$test);
+ echo "Left: ";var_dump(eval("return ($left );"));
+ echo "Right: ";var_dump(eval("return ($right);"));
+ }
+ }
+ if ($success) echo "OK";
+