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