mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
add new tests
This commit is contained in:
parent
29be5946f9
commit
ff59351416
47
Zend/tests/offset_array.phpt
Normal file
47
Zend/tests/offset_array.phpt
Normal file
@ -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
|
37
Zend/tests/offset_bool.phpt
Normal file
37
Zend/tests/offset_bool.phpt
Normal file
@ -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
|
37
Zend/tests/offset_long.phpt
Normal file
37
Zend/tests/offset_long.phpt
Normal file
@ -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
|
37
Zend/tests/offset_null.phpt
Normal file
37
Zend/tests/offset_null.phpt
Normal file
@ -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
|
11
Zend/tests/offset_object.phpt
Normal file
11
Zend/tests/offset_object.phpt
Normal file
@ -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
|
45
Zend/tests/offset_string.phpt
Normal file
45
Zend/tests/offset_string.phpt
Normal file
@ -0,0 +1,45 @@
|
||||
--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
|
Loading…
Reference in New Issue
Block a user