summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2000-08-27 19:46:06 +0000
committerStig Bakken <ssb@php.net>2000-08-27 19:46:06 +0000
commit315f4f5658cf22a17ba06fa2ca2f3d890355873f (patch)
tree3dd1134c1d1c3821b48fab806884123f09b2d21f /ext/standard
parent7eeda99a055df5a510d3d20526e9adcb42fecdb0 (diff)
downloadphp-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 'ext/standard')
-rw-r--r--ext/standard/tests/file/001.phpt141
-rw-r--r--ext/standard/tests/general_functions/001.phpt55
-rw-r--r--ext/standard/tests/math/001.phpt25
-rw-r--r--ext/standard/tests/reg/001.phpt9
-rw-r--r--ext/standard/tests/reg/002.phpt9
-rw-r--r--ext/standard/tests/reg/003.phpt11
-rw-r--r--ext/standard/tests/reg/004.phpt16
-rw-r--r--ext/standard/tests/reg/005.phpt20
-rw-r--r--ext/standard/tests/reg/006.phpt10
-rw-r--r--ext/standard/tests/reg/007.phpt12
-rw-r--r--ext/standard/tests/reg/008.phpt10
-rw-r--r--ext/standard/tests/reg/009.phpt19
-rw-r--r--ext/standard/tests/reg/010.phpt9
-rw-r--r--ext/standard/tests/reg/011.phpt9
-rw-r--r--ext/standard/tests/reg/012.phpt9
-rw-r--r--ext/standard/tests/reg/013.phpt9
-rw-r--r--ext/standard/tests/reg/014.phpt9
-rw-r--r--ext/standard/tests/reg/015.phpt8
-rw-r--r--ext/standard/tests/reg/016.phpt8
19 files changed, 398 insertions, 0 deletions
diff --git a/ext/standard/tests/file/001.phpt b/ext/standard/tests/file/001.phpt
new file mode 100644
index 0000000000..b95a1e6d65
--- /dev/null
+++ b/ext/standard/tests/file/001.phpt
@@ -0,0 +1,141 @@
+--TEST--
+File type functions
+--POST--
+--GET--
+--FILE--
+<?php
+@unlink('test.file');
+@unlink('test.link');
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+fclose (fopen('test.file', 'w'));
+chmod ('test.file', 0654);
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+sleep (2);
+symlink('test.file','test.link');
+if (file_exists('test.link')) {
+ echo "test.link exists\n";
+} else {
+ echo "test.link does not exist\n";
+}
+if (is_link('test.file')) {
+ echo "test.file is a symlink\n";
+} else {
+ echo "test.file is not a symlink\n";
+}
+if (is_link('test.link')) {
+ echo "test.link is a symlink\n";
+} else {
+ echo "test.link is not a symlink\n";
+}
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+$s = stat ('test.file');
+$ls = lstat ('test.file');
+for ($i = 0; $i <= 12; $i++) {
+ if ($ls[$i] != $s[$i]) {
+ echo "test.file lstat and stat differ at element $i\n";
+ }
+}
+$s = stat ('test.link');
+$ls = lstat ('test.link');
+for ($i = 0; $i <= 11; $i++) {
+ if ($ls[$i] != $s[$i]) {
+ if($i!=6) echo "test.link lstat and stat differ at element $i\n";
+ }
+}
+echo "test.file is " . filetype('test.file') . "\n";
+echo "test.link is " . filetype('test.link') . "\n";
+printf ("test.file permissions are 0%o\n", 0777 & fileperms('test.file'));
+echo "test.file size is " . filesize('test.file') . "\n";
+if (is_writeable('test.file')) {
+ echo "test.file is writeable\n";
+} else {
+ echo "test.file is not writeable\n";
+}
+if (is_readable('test.file')) {
+ echo "test.file is readable\n";
+} else {
+ echo "test.file is not readable\n";
+}
+if (is_executable('test.file')) {
+ echo "test.file is executable\n";
+} else {
+ echo "test.file is not executable\n";
+}
+if (is_file('test.file')) {
+ echo "test.file is a regular file\n";
+} else {
+ echo "test.file is not a regular file\n";
+}
+if (is_file('test.link')) {
+ echo "test.link is a regular file\n";
+} else {
+ echo "test.link is not a regular file\n";
+}
+if (is_dir('test.link')) {
+ echo "test.link is a directory\n";
+} else {
+ echo "test.link is not a directory\n";
+}
+if (is_dir('file')) {
+ echo "file is a directory\n";
+} else {
+ echo "file is not a directory\n";
+}
+if (is_dir('test.file')) {
+ echo "test.file is a directory\n";
+} else {
+ echo "test.file is not a directory\n";
+}
+unlink('test.file');
+unlink('test.link');
+if (file_exists('test.file')) {
+ echo "test.file exists (cached)\n";
+} else {
+ echo "test.file does not exist\n";
+}
+clearstatcache();
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+?>
+--EXPECT--
+test.file does not exist
+test.file exists
+test.link exists
+test.file is not a symlink
+test.link is a symlink
+test.file exists
+test.link lstat and stat differ at element 1
+test.link lstat and stat differ at element 2
+test.link lstat and stat differ at element 7
+test.link lstat and stat differ at element 8
+test.link lstat and stat differ at element 9
+test.link lstat and stat differ at element 10
+test.file is file
+test.link is link
+test.file permissions are 0654
+test.file size is 0
+test.file is writeable
+test.file is readable
+test.file is not executable
+test.file is a regular file
+test.link is a regular file
+test.link is not a directory
+file is a directory
+test.file is not a directory
+test.file does not exist
+test.file does not exist
diff --git a/ext/standard/tests/general_functions/001.phpt b/ext/standard/tests/general_functions/001.phpt
new file mode 100644
index 0000000000..ee6d32f7f8
--- /dev/null
+++ b/ext/standard/tests/general_functions/001.phpt
@@ -0,0 +1,55 @@
+--TEST--
+sprintf() function
+--POST--
+--GET--
+--FILE--
+<?php
+
+$agent = sprintf("%.5s", "James Bond, 007");
+
+echo("sprintf string truncate test: ");
+if ($agent == "James") {
+ echo("passed\n");
+} else {
+ echo("failed!\n");
+}
+
+echo("sprintf padding and align test: ");
+$test = sprintf("abc%04d %-20s%c", 20, "fisketur", 33);
+if ($test == "abc0020 fisketur !") {
+ echo("passed\n");
+} else {
+ echo("failed!\n");
+}
+
+echo("sprintf octal and hex test: ");
+$test = sprintf("%4o %4x %4X %0"."8x", 128, 1024, 49151, 3457925);
+if ($test == " 200 400 BFFF 0034c385") {
+ echo("passed\n");
+} else {
+ echo("failed!\n");
+}
+
+echo("sprintf octal binary test: ");
+$test = sprintf("%b", 3457925);
+if ($test == "1101001100001110000101") {
+ echo("passed\n");
+} else {
+ echo("failed!\n");
+}
+
+echo("sprintf float test: ");
+$test = sprintf("%0"."06.2f", 10000/3.0);
+if ($test == "003333.33") {
+ echo("passed\n");
+} else {
+ echo("failed!\n");
+}
+
+?>
+--EXPECT--
+sprintf string truncate test: passed
+sprintf padding and align test: passed
+sprintf octal and hex test: passed
+sprintf octal binary test: passed
+sprintf float test: passed
diff --git a/ext/standard/tests/math/001.phpt b/ext/standard/tests/math/001.phpt
new file mode 100644
index 0000000000..dee4217342
--- /dev/null
+++ b/ext/standard/tests/math/001.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Simple math tests
+--POST--
+--GET--
+--FILE--
+<?php
+ echo abs(-1) . "\n";
+ echo abs(-1.5) . "\n";
+ echo abs("-1") . "\n";
+ echo abs("-1.5") . "\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
+-1
+2
+-2
+1
diff --git a/ext/standard/tests/reg/001.phpt b/ext/standard/tests/reg/001.phpt
new file mode 100644
index 0000000000..f63c252518
--- /dev/null
+++ b/ext/standard/tests/reg/001.phpt
@@ -0,0 +1,9 @@
+--TEST--
+RegReplace test 1
+--POST--
+--GET--
+--FILE--
+<?php $a="abc123";
+ echo ereg_replace("123","def",$a)?>
+--EXPECT--
+abcdef
diff --git a/ext/standard/tests/reg/002.phpt b/ext/standard/tests/reg/002.phpt
new file mode 100644
index 0000000000..a9b7aaa00a
--- /dev/null
+++ b/ext/standard/tests/reg/002.phpt
@@ -0,0 +1,9 @@
+--TEST--
+RegReplace test 2
+--POST--
+--GET--
+--FILE--
+<?php $a="abc123";
+ echo ereg_replace("123","",$a)?>
+--EXPECT--
+abc
diff --git a/ext/standard/tests/reg/003.phpt b/ext/standard/tests/reg/003.phpt
new file mode 100644
index 0000000000..bb42729ca2
--- /dev/null
+++ b/ext/standard/tests/reg/003.phpt
@@ -0,0 +1,11 @@
+--TEST--
+ereg_replace single-quote test
+--POST--
+--GET--
+--FILE--
+<?php $a="\\'test";
+ echo ereg_replace("\\\\'","'",$a)
+?>
+--EXPECT--
+
+'test
diff --git a/ext/standard/tests/reg/004.phpt b/ext/standard/tests/reg/004.phpt
new file mode 100644
index 0000000000..1f60ff4900
--- /dev/null
+++ b/ext/standard/tests/reg/004.phpt
@@ -0,0 +1,16 @@
+--TEST--
+simple ereg test
+--POST--
+--GET--
+--FILE--
+<?php $a="This is a nice and simple string";
+ if (ereg(".*nice and simple.*",$a)) {
+ echo "ok\n";
+ }
+ if (!ereg(".*doesn't exist.*",$a)) {
+ echo "ok\n";
+ }
+?>
+--EXPECT--
+ok
+ok
diff --git a/ext/standard/tests/reg/005.phpt b/ext/standard/tests/reg/005.phpt
new file mode 100644
index 0000000000..78c0a0912a
--- /dev/null
+++ b/ext/standard/tests/reg/005.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Test Regular expression register support in ereg
+--POST--
+--GET--
+--FILE--
+<?php $a="This is a nice and simple string";
+ echo ereg(".*(is).*(is).*",$a,$registers);
+ echo "\n";
+ echo $registers[0];
+ echo "\n";
+ echo $registers[1];
+ echo "\n";
+ echo $registers[2];
+ echo "\n";
+?>
+--EXPECT--
+32
+This is a nice and simple string
+is
+is
diff --git a/ext/standard/tests/reg/006.phpt b/ext/standard/tests/reg/006.phpt
new file mode 100644
index 0000000000..50b6dbfd3a
--- /dev/null
+++ b/ext/standard/tests/reg/006.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test ereg_replace of start-of-line
+--POST--
+--GET--
+--FILE--
+<?php $a="This is a nice and simple string";
+ echo ereg_replace("^This","That",$a);
+?>
+--EXPECT--
+That is a nice and simple string
diff --git a/ext/standard/tests/reg/007.phpt b/ext/standard/tests/reg/007.phpt
new file mode 100644
index 0000000000..2223d48e22
--- /dev/null
+++ b/ext/standard/tests/reg/007.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Test empty result buffer in reg_replace
+--POST--
+--GET--
+--FILE--
+<?php
+ $a="abcd";
+ $b=ereg_replace("abcd","",$a);
+ echo strlen($b);
+?>
+--EXPECT--
+0
diff --git a/ext/standard/tests/reg/008.phpt b/ext/standard/tests/reg/008.phpt
new file mode 100644
index 0000000000..db61d1ca07
--- /dev/null
+++ b/ext/standard/tests/reg/008.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test back-references in regular expressions
+--POST--
+--GET--
+--FILE--
+<?php
+ echo ereg_replace("([a-z]*)([-=+|]*)([0-9]+)","\\3 \\1 \\2\n","abc+-|=123");
+?>
+--EXPECT--
+123 abc +-|=
diff --git a/ext/standard/tests/reg/009.phpt b/ext/standard/tests/reg/009.phpt
new file mode 100644
index 0000000000..4996ef4c97
--- /dev/null
+++ b/ext/standard/tests/reg/009.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Test split()
+--POST--
+--GET--
+--FILE--
+<?php
+ $a=split("[[:space:]]","this is a
+test");
+ echo count($a) . "\n";
+ for ($i = 0; $i < count($a); $i++) {
+ echo $a[$i] . "\n";
+ }
+?>
+--EXPECT--
+4
+this
+is
+a
+test
diff --git a/ext/standard/tests/reg/010.phpt b/ext/standard/tests/reg/010.phpt
new file mode 100644
index 0000000000..30d28fd02f
--- /dev/null
+++ b/ext/standard/tests/reg/010.phpt
@@ -0,0 +1,9 @@
+--TEST--
+Long back references
+--POST--
+--GET--
+--FILE--
+<?php $a="abc122222222223";
+ echo ereg_replace("1(2*)3","\\1def\\1",$a)?>
+--EXPECT--
+abc2222222222def2222222222
diff --git a/ext/standard/tests/reg/011.phpt b/ext/standard/tests/reg/011.phpt
new file mode 100644
index 0000000000..4eda774f58
--- /dev/null
+++ b/ext/standard/tests/reg/011.phpt
@@ -0,0 +1,9 @@
+--TEST--
+\0 back reference
+--POST--
+--GET--
+--FILE--
+<?php $a="abc123";
+ echo ereg_replace("123","def\\0ghi",$a)?>
+--EXPECT--
+abcdef123ghi
diff --git a/ext/standard/tests/reg/012.phpt b/ext/standard/tests/reg/012.phpt
new file mode 100644
index 0000000000..d5342c7436
--- /dev/null
+++ b/ext/standard/tests/reg/012.phpt
@@ -0,0 +1,9 @@
+--TEST--
+nonexisting back reference
+--POST--
+--GET--
+--FILE--
+<?php $a="abc123";
+ echo ereg_replace("123",'def\1ghi',$a)?>
+--EXPECT--
+abcdef\1ghi
diff --git a/ext/standard/tests/reg/013.phpt b/ext/standard/tests/reg/013.phpt
new file mode 100644
index 0000000000..ec3329fa7c
--- /dev/null
+++ b/ext/standard/tests/reg/013.phpt
@@ -0,0 +1,9 @@
+--TEST--
+escapes in replace string
+--POST--
+--GET--
+--FILE--
+<?php $a="abc123";
+ echo ereg_replace("123","def\\g\\\\hi\\",$a)?>
+--EXPECT--
+abcdef\g\\hi\
diff --git a/ext/standard/tests/reg/014.phpt b/ext/standard/tests/reg/014.phpt
new file mode 100644
index 0000000000..ec4d19ed0e
--- /dev/null
+++ b/ext/standard/tests/reg/014.phpt
@@ -0,0 +1,9 @@
+--TEST--
+backreferences not replaced recursively
+--POST--
+--GET--
+--FILE--
+<?php $a="a\\2bxc";
+ echo ereg_replace("a(.*)b(.*)c","\\1",$a)?>
+--EXPECT--
+\2
diff --git a/ext/standard/tests/reg/015.phpt b/ext/standard/tests/reg/015.phpt
new file mode 100644
index 0000000000..961a60fa76
--- /dev/null
+++ b/ext/standard/tests/reg/015.phpt
@@ -0,0 +1,8 @@
+--TEST--
+replace empty matches
+--POST--
+--GET--
+--FILE--
+<?php echo ereg_replace("^","z","abc123")?>
+--EXPECT--
+zabc123
diff --git a/ext/standard/tests/reg/016.phpt b/ext/standard/tests/reg/016.phpt
new file mode 100644
index 0000000000..a24816f182
--- /dev/null
+++ b/ext/standard/tests/reg/016.phpt
@@ -0,0 +1,8 @@
+--TEST--
+test backslash handling in regular expressions
+--POST--
+--GET--
+--FILE--
+<?php echo ereg_replace('\?',"abc","?123?")?>
+--EXPECT--
+abc123abc