Annotation of embedaddon/php/ext/standard/tests/array/bug21918.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #21918 (different handling of positive vs. negative array indexes)
! 3: --FILE--
! 4: <?php
! 5:
! 6: echo "==Mixed==\n";
! 7: $a = array(-1=>'a', '-2'=>'b', 3=>'c', '4'=>'d', 5=>'e', '6001'=>'f', '07'=>'g');
! 8:
! 9: foreach($a as $k => $v) {
! 10: var_dump($k);
! 11: var_dump($v);
! 12: }
! 13:
! 14: echo "==Normal==\n";
! 15: $b = array();
! 16: $b[] = 'a';
! 17:
! 18: foreach($b as $k => $v) {
! 19: var_dump($k);
! 20: var_dump($v);
! 21: }
! 22:
! 23: echo "==Negative==\n";
! 24: $c = array('-2' => 'a');
! 25:
! 26: foreach($c as $k => $v) {
! 27: var_dump($k);
! 28: var_dump($v);
! 29: }
! 30:
! 31: echo "==Done==\n";
! 32: ?>
! 33: --EXPECT--
! 34: ==Mixed==
! 35: int(-1)
! 36: string(1) "a"
! 37: int(-2)
! 38: string(1) "b"
! 39: int(3)
! 40: string(1) "c"
! 41: int(4)
! 42: string(1) "d"
! 43: int(5)
! 44: string(1) "e"
! 45: int(6001)
! 46: string(1) "f"
! 47: string(2) "07"
! 48: string(1) "g"
! 49: ==Normal==
! 50: int(0)
! 51: string(1) "a"
! 52: ==Negative==
! 53: int(-2)
! 54: string(1) "a"
! 55: ==Done==
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>