]> granicus.if.org Git - php/commitdiff
New tests
authorFelipe Pena <felipe@php.net>
Wed, 12 Mar 2008 13:01:59 +0000 (13:01 +0000)
committerFelipe Pena <felipe@php.net>
Wed, 12 Mar 2008 13:01:59 +0000 (13:01 +0000)
Zend/tests/access_modifiers_010.phpt [new file with mode: 0644]
Zend/tests/errmsg_044.phpt [new file with mode: 0644]
Zend/tests/foreach_002.phpt [new file with mode: 0644]
Zend/tests/inter_03.phpt [new file with mode: 0644]
Zend/tests/list_001.phpt [new file with mode: 0644]
Zend/tests/list_002.phpt [new file with mode: 0644]
Zend/tests/objects_019.phpt [new file with mode: 0644]

diff --git a/Zend/tests/access_modifiers_010.phpt b/Zend/tests/access_modifiers_010.phpt
new file mode 100644 (file)
index 0000000..637ea36
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+Testing visibility of methods
+--FILE--
+<?php
+
+class d {
+       private function test2() {
+               print "Bar\n";
+       }
+}
+
+abstract class a extends d {
+       public function test() {
+               $this->test2();
+       }
+}
+
+abstract class b extends a {
+}
+
+class c extends b {
+       public function __construct() {
+               $this->test();
+       }       
+}
+
+new c;
+
+?>
+--EXPECTF--
+Fatal error: Call to private method d::test2() from context 'a' in %s on line %d
diff --git a/Zend/tests/errmsg_044.phpt b/Zend/tests/errmsg_044.phpt
new file mode 100644 (file)
index 0000000..78a85f8
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Trying use object of type stdClass as array
+--FILE--
+<?php
+
+$a[0] = new stdclass;
+$a[0][0] = new stdclass;
+
+?>
+--EXPECT--
+Fatal error: Cannot use object of type stdClass as array in %s on line %d
diff --git a/Zend/tests/foreach_002.phpt b/Zend/tests/foreach_002.phpt
new file mode 100644 (file)
index 0000000..a451b41
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+Creating recursive array on foreach using same variable
+--FILE--
+<?php
+
+error_reporting(E_ALL);
+
+foreach (($a = array('a' => array('a' => &$a))) as $a) {
+       var_dump($a);
+}
+
+?>
+--EXPECT--
+array(1) {
+  ["a"]=>
+  &array(1) {
+    ["a"]=>
+    &array(1) {
+      ["a"]=>
+      *RECURSION*
+    }
+  }
+}
+--UEXPECT--
+array(1) {
+  [u"a"]=>
+  &array(1) {
+    [u"a"]=>
+    &array(1) {
+      [u"a"]=>
+      *RECURSION*
+    }
+  }
+}
diff --git a/Zend/tests/inter_03.phpt b/Zend/tests/inter_03.phpt
new file mode 100644 (file)
index 0000000..c91f4aa
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+Testing interface constants with inheritance
+--FILE--
+<?php
+
+interface a {
+       const b = 2;    
+}
+
+interface b extends a {
+       const c = self::b;      
+}
+
+var_dump(b::c, a::b);
+
+?>
+--EXPECT--
+int(2)
+int(2)
diff --git a/Zend/tests/list_001.phpt b/Zend/tests/list_001.phpt
new file mode 100644 (file)
index 0000000..a9fff55
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+"Nested" list()
+--FILE--
+<?php
+
+list($a, list($b)) = array(new stdclass, array(new stdclass));
+var_dump($a, $b);
+
+?>
+--EXPECT--
+object(stdClass)#1 (0) {
+}
+object(stdClass)#2 (0) {
+}
diff --git a/Zend/tests/list_002.phpt b/Zend/tests/list_002.phpt
new file mode 100644 (file)
index 0000000..ac0d897
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+Testing full-reference on list()
+--FILE--
+<?php
+
+error_reporting(E_ALL);
+
+$a = new stdclass;
+$b =& $a;
+
+list($a, list($b)) = array($a, array($b));
+var_dump($a, $b, $a === $b);
+
+?>
+--EXPECT--
+object(stdClass)#1 (0) {
+}
+object(stdClass)#1 (0) {
+}
+bool(true)
diff --git a/Zend/tests/objects_019.phpt b/Zend/tests/objects_019.phpt
new file mode 100644 (file)
index 0000000..27d101d
--- /dev/null
@@ -0,0 +1,46 @@
+--TEST--
+Testing references of dynamic properties
+--FILE--
+<?php
+
+error_reporting(E_ALL);
+
+$foo = array(new stdclass, new stdclass);
+
+$foo[1]->a = &$foo[0]->a;
+$foo[0]->a = 2;
+
+$x = $foo[1]->a;
+$x = 'foo';
+
+var_dump($foo, $x);
+
+?>
+--EXPECT--
+array(2) {
+  [0]=>
+  object(stdClass)#1 (1) {
+    ["a"]=>
+    &int(2)
+  }
+  [1]=>
+  object(stdClass)#2 (1) {
+    ["a"]=>
+    &int(2)
+  }
+}
+string(3) "foo"
+--UEXPECT--
+array(2) {
+  [0]=>
+  object(stdClass)#1 (1) {
+    [u"a"]=>
+    &int(2)
+  }
+  [1]=>
+  object(stdClass)#2 (1) {
+    [u"a"]=>
+    &int(2)
+  }
+}
+unicode(3) "foo"