]> granicus.if.org Git - php/commitdiff
more tests (and fix 2 from yesterday)
authorNuno Lopes <nlopess@php.net>
Wed, 14 Jun 2006 17:37:53 +0000 (17:37 +0000)
committerNuno Lopes <nlopess@php.net>
Wed, 14 Jun 2006 17:37:53 +0000 (17:37 +0000)
ext/pcre/tests/delimiters.phpt
ext/pcre/tests/dollar_endonly.phpt [new file with mode: 0644]
ext/pcre/tests/locales.phpt
ext/pcre/tests/match_flags.phpt [new file with mode: 0644]
ext/pcre/tests/match_flags2.phpt [new file with mode: 0644]
ext/pcre/tests/pcre_anchored.phpt [new file with mode: 0644]
ext/pcre/tests/pcre_extended.phpt [new file with mode: 0644]
ext/pcre/tests/pcre_extra.phpt [new file with mode: 0644]
ext/pcre/tests/ungreedy.phpt [new file with mode: 0644]

index 0cc235ecaa6b1e1e5a1b3100a1197708b6ff483c..1826f8730a337ea1e100b1f45f3f41b6d219e583 100644 (file)
@@ -11,6 +11,7 @@ var_dump(preg_match('<>', ''));
 var_dump(preg_match('~a', ''));
 var_dump(preg_match('@\@\@@', '@@'));
 var_dump(preg_match('//z', '@@'));
+var_dump(preg_match('{', ''));
 
 ?>
 --EXPECTF--
@@ -31,3 +32,6 @@ int(1)
 
 Warning: preg_match(): Unknown modifier 'z' in %sdelimiters.php on line 10
 bool(false)
+
+Warning: preg_match(): No ending matching delimiter '}' found in %sdelimiters.php on line 11
+bool(false)
diff --git a/ext/pcre/tests/dollar_endonly.phpt b/ext/pcre/tests/dollar_endonly.phpt
new file mode 100644 (file)
index 0000000..96a5244
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+D (PCRE_DOLLAR_ENDONLY) modififer
+--FILE--
+<?php
+
+var_dump(preg_match_all('/^\S+.+$/', "aeiou\n", $m));
+var_dump($m);
+
+var_dump(preg_match_all('/^\S+.+$/D', "aeiou\n", $m));
+var_dump($m);
+
+var_dump(preg_match_all('/^\S+\s$/D', "aeiou\n", $m));
+var_dump($m);
+
+?>
+--EXPECT--
+int(1)
+array(1) {
+  [0]=>
+  array(1) {
+    [0]=>
+    string(5) "aeiou"
+  }
+}
+int(0)
+array(1) {
+  [0]=>
+  array(0) {
+  }
+}
+int(1)
+array(1) {
+  [0]=>
+  array(1) {
+    [0]=>
+    string(6) "aeiou
+"
+  }
+}
index 0f55df0aad9453dff51d39ccb3bcaeb616105c4e..2e90c3d32a9245ff7d00c235ceaa07f3f32cd465 100644 (file)
@@ -1,7 +1,7 @@
 --TEST--
 Localized match
 --SKIPIF--
-<?php if (!function_exists('setlocale')) die('setlocale() not available'); ?>
+<?php if (!function_exists('setlocale')) die('skip: setlocale() not available'); ?>
 --FILE--
 <?php
 
diff --git a/ext/pcre/tests/match_flags.phpt b/ext/pcre/tests/match_flags.phpt
new file mode 100644 (file)
index 0000000..ddd36bf
--- /dev/null
@@ -0,0 +1,127 @@
+--TEST--
+preg_match_all() flags
+--FILE--
+<?php
+
+var_dump(preg_match_all('/(.)x/', 'zxax', $match, PREG_PATTERN_ORDER));
+var_dump($match);
+
+var_dump(preg_match_all('/(.)x/', 'zxyx', $match, PREG_SET_ORDER));
+var_dump($match);
+
+var_dump(preg_match_all('/(.)x/', 'zxyx', $match, PREG_OFFSET_CAPTURE));
+var_dump($match);
+
+var_dump(preg_match_all('/(.)x/', 'zxyx', $match, PREG_SET_ORDER | PREG_OFFSET_CAPTURE));
+var_dump($match);
+
+?>
+--EXPECT--
+int(2)
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    string(2) "zx"
+    [1]=>
+    string(2) "ax"
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    string(1) "z"
+    [1]=>
+    string(1) "a"
+  }
+}
+int(2)
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    string(2) "zx"
+    [1]=>
+    string(1) "z"
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    string(2) "yx"
+    [1]=>
+    string(1) "y"
+  }
+}
+int(2)
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(2) "zx"
+      [1]=>
+      int(0)
+    }
+    [1]=>
+    array(2) {
+      [0]=>
+      string(2) "yx"
+      [1]=>
+      int(2)
+    }
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(1) "z"
+      [1]=>
+      int(0)
+    }
+    [1]=>
+    array(2) {
+      [0]=>
+      string(1) "y"
+      [1]=>
+      int(2)
+    }
+  }
+}
+int(2)
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(2) "zx"
+      [1]=>
+      int(0)
+    }
+    [1]=>
+    array(2) {
+      [0]=>
+      string(1) "z"
+      [1]=>
+      int(0)
+    }
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(2) "yx"
+      [1]=>
+      int(2)
+    }
+    [1]=>
+    array(2) {
+      [0]=>
+      string(1) "y"
+      [1]=>
+      int(2)
+    }
+  }
+}
diff --git a/ext/pcre/tests/match_flags2.phpt b/ext/pcre/tests/match_flags2.phpt
new file mode 100644 (file)
index 0000000..f703091
--- /dev/null
@@ -0,0 +1,95 @@
+--TEST--
+preg_match() flags
+--FILE--
+<?php
+
+var_dump(preg_match('/x(.)/', 'fjszxax', $match, PREG_OFFSET_CAPTURE));
+var_dump($match);
+
+var_dump(preg_match('/(.)x/', 'fjszxax', $match, PREG_OFFSET_CAPTURE, 4));
+var_dump($match);
+
+var_dump(preg_match('/(?P<capt1>.)(x)(?P<letsmix>\S+)/', 'fjszxax', $match, PREG_OFFSET_CAPTURE));
+var_dump($match);
+
+?>
+--EXPECT--
+int(1)
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    string(2) "xa"
+    [1]=>
+    int(4)
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    string(1) "a"
+    [1]=>
+    int(5)
+  }
+}
+int(1)
+array(2) {
+  [0]=>
+  array(2) {
+    [0]=>
+    string(2) "ax"
+    [1]=>
+    int(5)
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    string(1) "a"
+    [1]=>
+    int(5)
+  }
+}
+int(1)
+array(6) {
+  [0]=>
+  array(2) {
+    [0]=>
+    string(4) "zxax"
+    [1]=>
+    int(3)
+  }
+  ["capt1"]=>
+  array(2) {
+    [0]=>
+    string(1) "z"
+    [1]=>
+    int(3)
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    string(1) "z"
+    [1]=>
+    int(3)
+  }
+  [2]=>
+  array(2) {
+    [0]=>
+    string(1) "x"
+    [1]=>
+    int(4)
+  }
+  ["letsmix"]=>
+  array(2) {
+    [0]=>
+    string(2) "ax"
+    [1]=>
+    int(5)
+  }
+  [3]=>
+  array(2) {
+    [0]=>
+    string(2) "ax"
+    [1]=>
+    int(5)
+  }
+}
diff --git a/ext/pcre/tests/pcre_anchored.phpt b/ext/pcre/tests/pcre_anchored.phpt
new file mode 100644 (file)
index 0000000..caa9643
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+A (PCRE_ANCHORED) modififer
+--FILE--
+<?php
+
+var_dump(preg_match('/\PN+/', '123abc', $m));
+var_dump($m);
+
+var_dump(preg_match('/\P{N}+/A', '123abc'));
+var_dump(preg_match('/^\P{N}+/', '123abc'));
+var_dump(preg_match('/^\P{N}+/A', '123abc'));
+
+?>
+--EXPECT--
+int(1)
+array(1) {
+  [0]=>
+  string(3) "abc"
+}
+int(0)
+int(0)
+int(0)
diff --git a/ext/pcre/tests/pcre_extended.phpt b/ext/pcre/tests/pcre_extended.phpt
new file mode 100644 (file)
index 0000000..6c4b20e
--- /dev/null
@@ -0,0 +1,29 @@
+--TEST--
+x (PCRE_EXTENDED) modififer
+--FILE--
+<?php
+
+var_dump(preg_match('/a e i o u/', 'aeiou', $m));
+var_dump($m);
+
+var_dump(preg_match('/a e i o u/x', 'aeiou', $m));
+var_dump($m);
+
+var_dump(preg_match("/a e\ni\to\ru/x", 'aeiou', $m));
+var_dump($m);
+
+?>
+--EXPECT--
+int(0)
+array(0) {
+}
+int(1)
+array(1) {
+  [0]=>
+  string(5) "aeiou"
+}
+int(1)
+array(1) {
+  [0]=>
+  string(5) "aeiou"
+}
diff --git a/ext/pcre/tests/pcre_extra.phpt b/ext/pcre/tests/pcre_extra.phpt
new file mode 100644 (file)
index 0000000..2bee408
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+X (PCRE_EXTRA) modififer
+--FILE--
+<?php
+
+var_dump(preg_match('/\y/', '\y'));
+var_dump(preg_match('/\y/X', '\y'));
+
+?>
+--EXPECTF--
+int(1)
+
+Warning: preg_match(): Compilation failed: unrecognized character follows \ at offset 1 in %spcre_extra.php on line 4
+bool(false)
diff --git a/ext/pcre/tests/ungreedy.phpt b/ext/pcre/tests/ungreedy.phpt
new file mode 100644 (file)
index 0000000..cf5e8ad
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+U (PCRE_UNGREEDY) modififer
+--FILE--
+<?php
+
+var_dump(preg_match('/<.*>/', '<aa> <bb> <cc>', $m));
+var_dump($m);
+
+var_dump(preg_match('/<.*>/U', '<aa> <bb> <cc>', $m));
+var_dump($m);
+
+var_dump(preg_match('/(?U)<.*>/', '<aa> <bb> <cc>', $m));
+var_dump($m);
+
+?>
+--EXPECT--
+int(1)
+array(1) {
+  [0]=>
+  string(14) "<aa> <bb> <cc>"
+}
+int(1)
+array(1) {
+  [0]=>
+  string(4) "<aa>"
+}
+int(1)
+array(1) {
+  [0]=>
+  string(4) "<aa>"
+}