summaryrefslogtreecommitdiff
path: root/ext/ereg/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ereg/tests')
-rw-r--r--ext/ereg/tests/001.phpt7
-rw-r--r--ext/ereg/tests/002.phpt7
-rw-r--r--ext/ereg/tests/003.phpt8
-rw-r--r--ext/ereg/tests/004.phpt14
-rw-r--r--ext/ereg/tests/005.phpt18
-rw-r--r--ext/ereg/tests/006.phpt8
-rw-r--r--ext/ereg/tests/007.phpt10
-rw-r--r--ext/ereg/tests/008.phpt8
-rw-r--r--ext/ereg/tests/009.phpt17
-rw-r--r--ext/ereg/tests/010.phpt7
-rw-r--r--ext/ereg/tests/011.phpt7
-rw-r--r--ext/ereg/tests/012.phpt7
-rw-r--r--ext/ereg/tests/013.phpt7
-rw-r--r--ext/ereg/tests/014.phpt7
-rw-r--r--ext/ereg/tests/015.phpt6
-rw-r--r--ext/ereg/tests/016.phpt6
16 files changed, 144 insertions, 0 deletions
diff --git a/ext/ereg/tests/001.phpt b/ext/ereg/tests/001.phpt
new file mode 100644
index 0000000000..13c50d0d1e
--- /dev/null
+++ b/ext/ereg/tests/001.phpt
@@ -0,0 +1,7 @@
+--TEST--
+RegReplace test 1
+--FILE--
+<?php $a="abc123";
+ echo ereg_replace("123","def",$a)?>
+--EXPECT--
+abcdef
diff --git a/ext/ereg/tests/002.phpt b/ext/ereg/tests/002.phpt
new file mode 100644
index 0000000000..abe9e063d8
--- /dev/null
+++ b/ext/ereg/tests/002.phpt
@@ -0,0 +1,7 @@
+--TEST--
+RegReplace test 2
+--FILE--
+<?php $a="abc123";
+ echo ereg_replace("123","",$a)?>
+--EXPECT--
+abc
diff --git a/ext/ereg/tests/003.phpt b/ext/ereg/tests/003.phpt
new file mode 100644
index 0000000000..4257f0d27e
--- /dev/null
+++ b/ext/ereg/tests/003.phpt
@@ -0,0 +1,8 @@
+--TEST--
+ereg_replace single-quote test
+--FILE--
+<?php $a="\\'test";
+ echo ereg_replace("\\\\'","'",$a)
+?>
+--EXPECT--
+'test
diff --git a/ext/ereg/tests/004.phpt b/ext/ereg/tests/004.phpt
new file mode 100644
index 0000000000..3e535c6a9d
--- /dev/null
+++ b/ext/ereg/tests/004.phpt
@@ -0,0 +1,14 @@
+--TEST--
+simple ereg test
+--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/ereg/tests/005.phpt b/ext/ereg/tests/005.phpt
new file mode 100644
index 0000000000..ee9ccc6da4
--- /dev/null
+++ b/ext/ereg/tests/005.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test Regular expression register support in ereg
+--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/ereg/tests/006.phpt b/ext/ereg/tests/006.phpt
new file mode 100644
index 0000000000..cae349672e
--- /dev/null
+++ b/ext/ereg/tests/006.phpt
@@ -0,0 +1,8 @@
+--TEST--
+Test ereg_replace of start-of-line
+--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/ereg/tests/007.phpt b/ext/ereg/tests/007.phpt
new file mode 100644
index 0000000000..beb3cdc159
--- /dev/null
+++ b/ext/ereg/tests/007.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test empty result buffer in reg_replace
+--FILE--
+<?php
+ $a="abcd";
+ $b=ereg_replace("abcd","",$a);
+ echo "strlen(\$b)=".strlen($b);
+?>
+--EXPECT--
+strlen($b)=0
diff --git a/ext/ereg/tests/008.phpt b/ext/ereg/tests/008.phpt
new file mode 100644
index 0000000000..9a0cedabc5
--- /dev/null
+++ b/ext/ereg/tests/008.phpt
@@ -0,0 +1,8 @@
+--TEST--
+Test back-references in regular expressions
+--FILE--
+<?php
+ echo ereg_replace("([a-z]*)([-=+|]*)([0-9]+)","\\3 \\1 \\2\n","abc+-|=123");
+?>
+--EXPECT--
+123 abc +-|=
diff --git a/ext/ereg/tests/009.phpt b/ext/ereg/tests/009.phpt
new file mode 100644
index 0000000000..528606f3c8
--- /dev/null
+++ b/ext/ereg/tests/009.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Test split()
+--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/ereg/tests/010.phpt b/ext/ereg/tests/010.phpt
new file mode 100644
index 0000000000..f6f8909f73
--- /dev/null
+++ b/ext/ereg/tests/010.phpt
@@ -0,0 +1,7 @@
+--TEST--
+Long back references
+--FILE--
+<?php $a="abc122222222223";
+ echo ereg_replace("1(2*)3","\\1def\\1",$a)?>
+--EXPECT--
+abc2222222222def2222222222
diff --git a/ext/ereg/tests/011.phpt b/ext/ereg/tests/011.phpt
new file mode 100644
index 0000000000..65554b302f
--- /dev/null
+++ b/ext/ereg/tests/011.phpt
@@ -0,0 +1,7 @@
+--TEST--
+\0 back reference
+--FILE--
+<?php $a="abc123";
+ echo ereg_replace("123","def\\0ghi",$a)?>
+--EXPECT--
+abcdef123ghi
diff --git a/ext/ereg/tests/012.phpt b/ext/ereg/tests/012.phpt
new file mode 100644
index 0000000000..88ad5992ad
--- /dev/null
+++ b/ext/ereg/tests/012.phpt
@@ -0,0 +1,7 @@
+--TEST--
+nonexisting back reference
+--FILE--
+<?php $a="abc123";
+ echo ereg_replace("123",'def\1ghi',$a)?>
+--EXPECT--
+abcdef\1ghi
diff --git a/ext/ereg/tests/013.phpt b/ext/ereg/tests/013.phpt
new file mode 100644
index 0000000000..a2d9ee0099
--- /dev/null
+++ b/ext/ereg/tests/013.phpt
@@ -0,0 +1,7 @@
+--TEST--
+escapes in replace string
+--FILE--
+<?php $a="abc123";
+ echo ereg_replace("123","def\\g\\\\hi\\",$a)?>
+--EXPECT--
+abcdef\g\\hi\
diff --git a/ext/ereg/tests/014.phpt b/ext/ereg/tests/014.phpt
new file mode 100644
index 0000000000..d2a32451a9
--- /dev/null
+++ b/ext/ereg/tests/014.phpt
@@ -0,0 +1,7 @@
+--TEST--
+backreferences not replaced recursively
+--FILE--
+<?php $a="a\\2bxc";
+ echo ereg_replace("a(.*)b(.*)c","\\1",$a)?>
+--EXPECT--
+\2
diff --git a/ext/ereg/tests/015.phpt b/ext/ereg/tests/015.phpt
new file mode 100644
index 0000000000..c255ddf05b
--- /dev/null
+++ b/ext/ereg/tests/015.phpt
@@ -0,0 +1,6 @@
+--TEST--
+replace empty matches
+--FILE--
+<?php echo ereg_replace("^","z","abc123")?>
+--EXPECT--
+zabc123
diff --git a/ext/ereg/tests/016.phpt b/ext/ereg/tests/016.phpt
new file mode 100644
index 0000000000..c354ab26fc
--- /dev/null
+++ b/ext/ereg/tests/016.phpt
@@ -0,0 +1,6 @@
+--TEST--
+test backslash handling in regular expressions
+--FILE--
+<?php echo ereg_replace('\?',"abc","?123?")?>
+--EXPECT--
+abc123abc