summaryrefslogtreecommitdiff
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
parentba211eef91e6ad94d6aeecde9217da5f84c20657 (diff)
downloadphp-git-860be31caee9fd58a31cb14fbd3f67ec9c76d344.tar.gz
More tests
-rw-r--r--ext/standard/tests/math/001.phpt62
-rw-r--r--ext/standard/tests/math/pow.phpt78
-rw-r--r--ext/standard/tests/strings/trim.phpt29
-rw-r--r--tests/quicktester.inc (renamed from ext/standard/tests/math/test_eval.inc)18
4 files changed, 123 insertions, 64 deletions
diff --git a/ext/standard/tests/math/001.phpt b/ext/standard/tests/math/001.phpt
index ccd19dc600..1e3a8217ad 100644
--- a/ext/standard/tests/math/001.phpt
+++ b/ext/standard/tests/math/001.phpt
@@ -4,28 +4,42 @@ Simple math tests
--GET--
--FILE--
<?php
- echo abs(-1) . "\n";
- echo abs(-1.5) . "\n";
- echo abs("-1") . "\n";
- echo abs("-1.5") . "\n";
- echo abs(-2147483647) . "\n";
- echo abs(-2147483648) . "\n";
- echo abs(-2147483649) . "\n";
- echo ceil(-1.5) . "\n";
- echo ceil(1.5) . "\n";
- echo floor(-1.5) . "\n";
- echo floor(1.5) . "\n";
-?>
---EXPECT--
-1
-1.5
-1
-1.5
-2147483647
-2147483648
-2147483649
--1
-2
--2
-1
+define('LONG_MAX', is_int(5000000000)? 9223372036854775807 : 0x7FFFFFFF);
+define('LONG_MIN', -LONG_MAX - 1);
+printf("%d,%d,%d,%d\n",is_int(LONG_MIN ),is_int(LONG_MAX ),
+ is_int(LONG_MIN-1),is_int(LONG_MAX+1));
+
+$tests = <<<TESTS
+ 1 === abs(-1)
+ 1.5 === abs(-1.5)
+ 1 === abs("-1")
+ 1.5 === abs("-1.5")
+-LONG_MIN+1 === abs(LONG_MIN-1)
+-LONG_MIN === abs(LONG_MIN)
+-LONG_MIN-1 === abs(LONG_MIN+1)
+-1 === ceil(-1.5)
+ 2 === ceil( 1.5)
+-2 === floor(-1.5)
+ 1 === floor(1.5)
+ LONG_MIN === ceil(LONG_MIN - 0.5)
+ LONG_MIN+1 === ceil(LONG_MIN + 0.5)
+ LONG_MIN-1 === round(LONG_MIN - 0.6)
+ LONG_MIN === round(LONG_MIN - 0.4)
+ LONG_MIN === round(LONG_MIN + 0.4)
+ LONG_MIN+1 === round(LONG_MIN + 0.6)
+ LONG_MIN-1 === floor(LONG_MIN - 0.5)
+ LONG_MIN === floor(LONG_MIN + 0.5)
+ LONG_MAX === ceil(LONG_MAX - 0.5)
+ LONG_MAX+1 === ceil(LONG_MAX + 0.5)
+ LONG_MAX-1 === round(LONG_MAX - 0.6)
+ LONG_MAX === round(LONG_MAX - 0.4)
+ LONG_MAX === round(LONG_MAX + 0.4)
+ LONG_MAX+1 === round(LONG_MAX + 0.6)
+ LONG_MAX-1 === floor(LONG_MAX - 0.5)
+ LONG_MAX === floor(LONG_MAX + 0.5)
+TESTS;
+
+include('../../../../tests/quicktester.inc');
+--EXPECT--
+OK
diff --git a/ext/standard/tests/math/pow.phpt b/ext/standard/tests/math/pow.phpt
index 3ba2c6e420..150db4ad38 100644
--- a/ext/standard/tests/math/pow.phpt
+++ b/ext/standard/tests/math/pow.phpt
@@ -20,8 +20,8 @@ $tests = <<<TESTS
1 === pow(-1, 0)
-1 === pow(-1, 1)
1 === pow(-1, 2)
-FALSE === pow( 0,-2)
-FALSE === pow( 0,-1)
+FALSE ===@pow( 0,-2)
+FALSE ===@pow( 0,-1)
1 === pow( 0, 0)
0 === pow( 0, 1)
0 === pow( 0, 2)
@@ -35,21 +35,21 @@ FALSE === pow( 0,-1)
1 === pow( 2, 0)
2 === pow( 2, 1)
4 === pow( 2, 2)
-FALSE === pow(-2,-2.0)
-FALSE === pow(-2,-1.0)
-FALSE === pow(-2, 0.0)
-FALSE === pow(-2, 1.0)
-FALSE === pow(-2, 2.0)
-FALSE === pow(-1,-2.0)
-FALSE === pow(-1,-1.0)
-FALSE === pow(-1, 0.0)
-FALSE === pow(-1, 1.0)
-FALSE === pow(-1, 2.0)
-FALSE === pow( 0,-2.0)
-FALSE === pow( 0,-1.0)
-FALSE === pow( 0, 0.0)
-FALSE === pow( 0, 1.0)
-FALSE === pow( 0, 2.0)
+FALSE ===@pow(-2,-2.0)
+FALSE ===@pow(-2,-1.0)
+FALSE ===@pow(-2, 0.0)
+FALSE ===@pow(-2, 1.0)
+FALSE ===@pow(-2, 2.0)
+FALSE ===@pow(-1,-2.0)
+FALSE ===@pow(-1,-1.0)
+FALSE ===@pow(-1, 0.0)
+FALSE ===@pow(-1, 1.0)
+FALSE ===@pow(-1, 2.0)
+FALSE ===@pow( 0,-2.0)
+FALSE ===@pow( 0,-1.0)
+FALSE ===@pow( 0, 0.0)
+FALSE ===@pow( 0, 1.0)
+FALSE ===@pow( 0, 2.0)
1.0 === pow( 1,-2.0)
1.0 === pow( 1,-1.0)
1.0 === pow( 1, 0.0)
@@ -67,21 +67,21 @@ FALSE === pow( 0, 2.0)
1 === pow(-1,1443279822)
-1 === pow(-1,1443279821)
sqrt(2) === pow(2,1/2)
-FALSE === pow(-2.0,-2.0)
-FALSE === pow(-2.0,-1.0)
-FALSE === pow(-2.0, 0.0)
-FALSE === pow(-2.0, 1.0)
-FALSE === pow(-2.0, 2.0)
-FALSE === pow(-1.0,-2.0)
-FALSE === pow(-1.0,-1.0)
-FALSE === pow(-1.0, 0.0)
-FALSE === pow(-1.0, 1.0)
-FALSE === pow(-1.0, 2.0)
-FALSE === pow( 0.0,-2.0)
-FALSE === pow( 0.0,-1.0)
-FALSE === pow( 0.0, 0.0)
-FALSE === pow( 0.0, 1.0)
-FALSE === pow( 0.0, 2.0)
+FALSE ===@pow(-2.0,-2.0)
+FALSE ===@pow(-2.0,-1.0)
+FALSE ===@pow(-2.0, 0.0)
+FALSE ===@pow(-2.0, 1.0)
+FALSE ===@pow(-2.0, 2.0)
+FALSE ===@pow(-1.0,-2.0)
+FALSE ===@pow(-1.0,-1.0)
+FALSE ===@pow(-1.0, 0.0)
+FALSE ===@pow(-1.0, 1.0)
+FALSE ===@pow(-1.0, 2.0)
+FALSE ===@pow( 0.0,-2.0)
+FALSE ===@pow( 0.0,-1.0)
+FALSE ===@pow( 0.0, 0.0)
+FALSE ===@pow( 0.0, 1.0)
+FALSE ===@pow( 0.0, 2.0)
1.0 === pow( 1.0,-2.0)
1.0 === pow( 1.0,-1.0)
1.0 === pow( 1.0, 0.0)
@@ -102,8 +102,8 @@ FALSE === pow( 0.0, 2.0)
1.0 === pow(-1.0, 0)
-1.0 === pow(-1.0, 1)
1.0 === pow(-1.0, 2)
-FALSE === pow( 0.0,-2)
-FALSE === pow( 0.0,-1)
+FALSE ===@pow( 0.0,-2)
+FALSE ===@pow( 0.0,-1)
1.0 === pow( 0.0, 0)
0.0 === pow( 0.0, 1)
0.0 === pow( 0.0, 2)
@@ -122,21 +122,21 @@ LONG_MIN+1 === pow(LONG_MIN+1,1)
(LONG_MAX-1)*(LONG_MAX-1) === pow(LONG_MAX-1,2)
(LONG_MIN+1)*(LONG_MIN+1) === pow(LONG_MIN+1,2)
(float)(LONG_MAX-1) === pow(LONG_MAX-1,1.0)
-FALSE === pow(LONG_MIN+1,1.0)
+FALSE ===@pow(LONG_MIN+1,1.0)
(LONG_MAX-1)*(LONG_MAX-1) === pow(LONG_MAX-1,2.0)
-FALSE === pow(LONG_MIN+1,2.0)
+FALSE ===@pow(LONG_MIN+1,2.0)
LONG_MAX === pow(LONG_MAX,1)
LONG_MIN === pow(LONG_MIN,1)
LONG_MAX*LONG_MAX === pow(LONG_MAX,2)
LONG_MIN*LONG_MIN === pow(LONG_MIN,2)
(float)LONG_MAX === pow(LONG_MAX,1.0)
-FALSE === pow(LONG_MIN,1.0)
+FALSE ===@pow(LONG_MIN,1.0)
LONG_MAX*LONG_MAX === pow(LONG_MAX,2.0)
-FALSE === pow(LONG_MIN,2.0)
+FALSE ===@pow(LONG_MIN,2.0)
TESTS;
echo "On failure, please mail result to jeroen@php.net\n";
- include('test_eval.inc');
+ include('../../../../tests/quicktester.inc');
--EXPECT--
1,1,0,0
diff --git a/ext/standard/tests/strings/trim.phpt b/ext/standard/tests/strings/trim.phpt
new file mode 100644
index 0000000000..937217ee22
--- /dev/null
+++ b/ext/standard/tests/strings/trim.phpt
@@ -0,0 +1,29 @@
+--TEST--
+trim() function
+--POST--
+--GET--
+--FILE--
+<?php
+
+$tests = <<<TESTS
+'abc' === trim('abc')
+'abc' === ltrim('abc')
+'abc' === rtrim('abc')
+'abc' === trim(" \0\t\nabc \0\t\n")
+"abc \0\t\n" === ltrim(" \0\t\nabc \0\t\n")
+" \0\t\nabc" === rtrim(" \0\t\nabc \0\t\n")
+" \0\t\nabc \0\t\n" === trim(" \0\t\nabc \0\t\n",'')
+" \0\t\nabc \0\t\n" === ltrim(" \0\t\nabc \0\t\n",'')
+" \0\t\nabc \0\t\n" === rtrim(" \0\t\nabc \0\t\n",'')
+"abc\x50\xC1" === trim("abc\x50\xC1\x60\x90","\x51..\xC0")
+"abc\x50" === trim("abc\x50\xC1\x60\x90","\x51..\xC1")
+"abc" === trim("abc\x50\xC1\x60\x90","\x50..\xC1")
+"abc\x50\xC1" === trim("abc\x50\xC1\x60\x90","\x51..\xC0")
+"abc\x50" === trim("abc\x50\xC1\x60\x90","\x51..\xC1")
+"abc" === trim("abc\x50\xC1\x60\x90","\x50..\xC1")
+TESTS;
+
+include('../../../../tests/quicktester.inc');
+
+--EXPECT--
+OK
diff --git a/ext/standard/tests/math/test_eval.inc b/tests/quicktester.inc
index 81f8bf6406..08e3c0a40f 100644
--- a/ext/standard/tests/math/test_eval.inc
+++ b/tests/quicktester.inc
@@ -1,5 +1,21 @@
<?php
- error_reporting(0);
+ /*
+ 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)