add new tests

This commit is contained in:
Antony Dovgal 2006-06-01 11:57:49 +00:00
parent 29be5946f9
commit ff59351416
6 changed files with 214 additions and 0 deletions

View 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

View 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

View 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

View 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

View 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

View 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