1--TEST-- 2Test >= operator : different types 3--FILE-- 4<?php 5$valid_true = array(1, "1", "true", 1.0, array(1)); 6$valid_false = array(0, "", 0.0, array(), NULL); 7 8$int1 = 679; 9$int2 = -67835; 10$valid_int1 = array("679", " 679", 679.0, 6.79E2, "678", "678abc", " 678", 678.0, 6.78E2, 6.789E2, "+678", +678); 11$valid_int2 = array("-67835", " -67835", -67835.000, -6.7835E4, "-67836", -67835.0001, -6.78351E4, "-67836", -67835.0001, -6.78351E4); 12$invalid_int1 = array(680, "680", "679abc"); 13$invalid_int2 = array(-67834, "-67834", "-67835abc", "-67836abc". " -67836"); 14 15$float1 = 57385.45835; 16$float2 = -67345.76567; 17$valid_float1 = array("57385.45835", " 57385.45835", 5.738545835e4, "57385.45834", "57385.45834aaa", " 57385.45834", 5.738545834e4); 18$valid_float2 = array("-67345.76567", " -67345.76567", -6.734576567E4, "-67345.76568", " -67345.76568", -6.734576568E4); 19$invalid_float1 = array(57385.45836, 5.738545836e4, "57385.45835aaa"); 20$invalid_float2 = array(-67345.76564, -6.734576564E4, "-67345.76567aaa", "-67345.76568aaa"); 21 22$toCompare = array( 23 24 true, array_merge($valid_false, $valid_true), NULL, 25 false, $valid_false, $valid_true, 26 $int1, $valid_int1, $invalid_int1, 27 $int2, $valid_int2, $invalid_int2, 28 $float1, $valid_float1, $invalid_float1, 29 $float2, $valid_float2, $invalid_float2 30); 31 32$failed = false; 33for ($i = 0; $i < count($toCompare); $i +=3) { 34 $typeToTest = $toCompare[$i]; 35 $valid_compares = $toCompare[$i + 1]; 36 $invalid_compares = $toCompare[$i + 2]; 37 38 foreach($valid_compares as $compareVal) { 39 if ($typeToTest >= $compareVal) { 40 // do nothing 41 } 42 else { 43 echo "FAILED: '$typeToTest' < '$compareVal'\n"; 44 $failed = true; 45 } 46 } 47 48 if ($invalid_compares != NULL) { 49 foreach($invalid_compares as $compareVal) { 50 if ($typeToTest >= $compareVal) { 51 echo "FAILED: '$typeToTest' >= '$compareVal'\n"; 52 $failed = true; 53 } 54 } 55 } 56 57} 58if ($failed == false) { 59 echo "Test Passed\n"; 60} 61?> 62--EXPECT-- 63Test Passed 64