]> granicus.if.org Git - php/commitdiff
add new tests
authorAntony Dovgal <tony2001@php.net>
Thu, 1 Jun 2006 11:57:39 +0000 (11:57 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 1 Jun 2006 11:57:39 +0000 (11:57 +0000)
Zend/tests/offset_array.phpt [new file with mode: 0644]
Zend/tests/offset_bool.phpt [new file with mode: 0644]
Zend/tests/offset_long.phpt [new file with mode: 0644]
Zend/tests/offset_null.phpt [new file with mode: 0644]
Zend/tests/offset_object.phpt [new file with mode: 0644]
Zend/tests/offset_string.phpt [new file with mode: 0644]

diff --git a/Zend/tests/offset_array.phpt b/Zend/tests/offset_array.phpt
new file mode 100644 (file)
index 0000000..a7e2f21
--- /dev/null
@@ -0,0 +1,47 @@
+--TEST--
+using different variables to access array offsets
+--FILE--
+<?php
+
+$arr = array(1,2,3,4,5,6,7,8);
+
+var_dump($arr[1]);
+var_dump($arr[0.0836]);
+var_dump($arr[NULL]);
+var_dump($arr["run away"]);
+
+var_dump($arr[TRUE]);
+var_dump($arr[FALSE]);
+
+$fp = fopen(__FILE__, "r");
+var_dump($arr[$fp]);
+
+$obj = new stdClass;
+var_dump($arr[$obj]);
+
+$arr1 = Array(1,2,3);
+var_dump($arr[$arr1]);
+
+echo "Done\n";
+?>
+--EXPECTF--    
+int(2)
+int(1)
+
+Notice: Undefined index:   in %s on line %d
+NULL
+
+Notice: Undefined index:  run away in %s on line %d
+NULL
+int(2)
+int(1)
+
+Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
+int(%d)
+
+Warning: Illegal offset type in %s on line %d
+NULL
+
+Warning: Illegal offset type in %s on line %d
+NULL
+Done
diff --git a/Zend/tests/offset_bool.phpt b/Zend/tests/offset_bool.phpt
new file mode 100644 (file)
index 0000000..9bf8a89
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+using different variables to access boolean offsets
+--FILE--
+<?php
+
+$bool = TRUE;
+
+var_dump($bool[1]);
+var_dump($bool[0.0836]);
+var_dump($bool[NULL]);
+var_dump($bool["run away"]);
+
+var_dump($bool[TRUE]);
+var_dump($bool[FALSE]);
+
+$fp = fopen(__FILE__, "r");
+var_dump($bool[$fp]);
+
+$obj = new stdClass;
+var_dump($bool[$obj]);
+
+$arr = Array(1,2,3);
+var_dump($bool[$arr]);
+
+echo "Done\n";
+?>
+--EXPECTF--    
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+Done
diff --git a/Zend/tests/offset_long.phpt b/Zend/tests/offset_long.phpt
new file mode 100644 (file)
index 0000000..c65a5ba
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+using different variables to access long offsets
+--FILE--
+<?php
+
+$long = 1;
+
+var_dump($long[1]);
+var_dump($long[0.0836]);
+var_dump($long[NULL]);
+var_dump($long["run away"]);
+
+var_dump($long[TRUE]);
+var_dump($long[FALSE]);
+
+$fp = fopen(__FILE__, "r");
+var_dump($long[$fp]);
+
+$obj = new stdClass;
+var_dump($long[$obj]);
+
+$arr = Array(1,2,3);
+var_dump($long[$arr]);
+
+echo "Done\n";
+?>
+--EXPECTF--    
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+Done
diff --git a/Zend/tests/offset_null.phpt b/Zend/tests/offset_null.phpt
new file mode 100644 (file)
index 0000000..9364f0a
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+using different variables to access null offsets
+--FILE--
+<?php
+
+$null = NULL;
+
+var_dump($null[1]);
+var_dump($null[0.0836]);
+var_dump($null[NULL]);
+var_dump($null["run away"]);
+
+var_dump($null[TRUE]);
+var_dump($null[FALSE]);
+
+$fp = fopen(__FILE__, "r");
+var_dump($null[$fp]);
+
+$obj = new stdClass;
+var_dump($null[$obj]);
+
+$arr = Array(1,2,3);
+var_dump($null[$arr]);
+
+echo "Done\n";
+?>
+--EXPECTF--    
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+Done
diff --git a/Zend/tests/offset_object.phpt b/Zend/tests/offset_object.phpt
new file mode 100644 (file)
index 0000000..b570fd2
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+accessing object dimension
+--FILE--
+<?php
+
+$object = new stdClass;
+var_dump($object[1]);
+
+?>
+--EXPECTF--    
+Fatal error: Cannot use object of type stdClass as array in %s on line %d
diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt
new file mode 100644 (file)
index 0000000..63f92c5
--- /dev/null
@@ -0,0 +1,64 @@
+--TEST--
+using different variables to access string offsets
+--FILE--
+<?php
+
+$str = "Sitting on a corner all alone, staring from the bottom of his soul";
+
+var_dump($str[1]);
+var_dump($str[0.0836]);
+var_dump($str[NULL]);
+var_dump($str["run away"]);
+
+var_dump($str[TRUE]);
+var_dump($str[FALSE]);
+
+$fp = fopen(__FILE__, "r");
+var_dump($str[$fp]);
+
+$obj = new stdClass;
+var_dump($str[$obj]);
+
+$arr = Array(1,2,3);
+var_dump($str[$arr]);
+
+echo "Done\n";
+?>
+--EXPECTF--    
+string(1) "i"
+string(1) "S"
+string(1) "S"
+string(1) "S"
+string(1) "i"
+string(1) "S"
+
+Warning: Illegal offset type in %s on line %d
+string(1) "%s"
+
+Warning: Illegal offset type in %s on line %d
+
+Notice: Object of class stdClass could not be converted to int in %s on line %d
+string(1) "%s"
+
+Warning: Illegal offset type in %s on line %d
+string(1) "i"
+Done
+--UEXPECTF--
+unicode(1) "i"
+unicode(1) "S"
+unicode(1) "S"
+unicode(1) "S"
+unicode(1) "i"
+unicode(1) "S"
+
+Warning: Illegal offset type in %s on line %d
+unicode(1) "%s"
+
+Warning: Illegal offset type in %s on line %d
+
+Notice: Object of class stdClass could not be converted to int in %s on line %d
+unicode(1) "%s"
+
+Warning: Illegal offset type in %s on line %d
+unicode(1) "i"
+Done