Return to 031.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / lang |
1.1 ! misho 1: --TEST-- ! 2: Bug #16227 (Internal hash position bug on assignment) ! 3: --FILE-- ! 4: <?php ! 5: // reported by php.net@alienbill.com ! 6: $arrayOuter = array("key1","key2"); ! 7: $arrayInner = array("0","1"); ! 8: ! 9: print "Correct - with inner loop reset.\n"; ! 10: ! 11: while(list(,$o) = each($arrayOuter)){ ! 12: reset($arrayInner); ! 13: while(list(,$i) = each($arrayInner)){ ! 14: print "inloop $i for $o\n"; ! 15: } ! 16: } ! 17: reset($arrayOuter); ! 18: reset($arrayInner); ! 19: ! 20: print "What happens without inner loop reset.\n"; ! 21: ! 22: while(list(,$o) = each($arrayOuter)){ ! 23: while(list(,$i) = each($arrayInner)){ ! 24: print "inloop $i for $o\n"; ! 25: } ! 26: } ! 27: reset($arrayOuter); ! 28: reset($arrayInner); ! 29: ! 30: print "What happens without inner loop reset but copy.\n"; ! 31: ! 32: while(list(,$o) = each($arrayOuter)){ ! 33: $placeholder = $arrayInner; ! 34: while(list(,$i) = each($arrayInner)){ ! 35: print "inloop $i for $o\n"; ! 36: } ! 37: } ! 38: reset($arrayOuter); ! 39: reset($arrayInner); ! 40: ! 41: print "What happens with inner loop reset over copy.\n"; ! 42: ! 43: while(list(,$o) = each($arrayOuter)){ ! 44: $placeholder = $arrayInner; ! 45: while(list(,$i) = each($placeholder)){ ! 46: print "inloop $i for $o\n"; ! 47: } ! 48: } ! 49: reset($arrayOuter); ! 50: reset($arrayInner); ! 51: ?> ! 52: --EXPECT-- ! 53: Correct - with inner loop reset. ! 54: inloop 0 for key1 ! 55: inloop 1 for key1 ! 56: inloop 0 for key2 ! 57: inloop 1 for key2 ! 58: What happens without inner loop reset. ! 59: inloop 0 for key1 ! 60: inloop 1 for key1 ! 61: What happens without inner loop reset but copy. ! 62: inloop 0 for key1 ! 63: inloop 1 for key1 ! 64: inloop 0 for key2 ! 65: inloop 1 for key2 ! 66: What happens with inner loop reset over copy. ! 67: inloop 0 for key1 ! 68: inloop 1 for key1 ! 69: inloop 0 for key2 ! 70: inloop 1 for key2