File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / lang / operators / operator_identical_variation_64bit.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:06 2012 UTC (12 years, 4 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    1: --TEST--
    2: Test === operator : max int 64bit range
    3: --SKIPIF--
    4: <?php
    5: if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
    6: ?>
    7: --FILE--
    8: <?php
    9:  
   10: define("MAX_64Bit", 9223372036854775807);
   11: define("MAX_32Bit", 2147483647);
   12: define("MIN_64Bit", -9223372036854775807 - 1);
   13: define("MIN_32Bit", -2147483647 - 1);
   14: 
   15: $validIdentical = array (
   16: MAX_32Bit, array(MAX_32Bit),
   17: MIN_32Bit, array(MIN_32Bit),
   18: MAX_64Bit, array(MAX_64Bit),
   19: MIN_64Bit, array(MIN_64Bit),
   20: );
   21: 
   22: $invalidIdentical = array (
   23: MAX_32Bit, array("2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, "2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1),
   24: MIN_32Bit, array("-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, "-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1),
   25: MAX_64Bit, array(MAX_64Bit - 1, MAX_64Bit + 1),
   26: MIN_64Bit, array(MIN_64Bit + 1, MIN_64Bit - 1),
   27: );
   28: 
   29: 
   30: $failed = false;
   31: // test for valid values
   32: for ($i = 0; $i < count($validIdentical); $i +=2) {
   33:    $typeToTestVal = $validIdentical[$i];
   34:    $compares = $validIdentical[$i + 1];
   35:    foreach($compares as $compareVal) {
   36:       if ($typeToTestVal === $compareVal) {
   37:          // do nothing
   38:       }
   39:       else {
   40:          echo "FAILED: '$typeToTestVal' !== '$compareVal'\n";
   41:          $failed = true;
   42:       }
   43:    }
   44: }
   45: // test for invalid values
   46: for ($i = 0; $i < count($invalidIdentical); $i +=2) {
   47:    $typeToTestVal = $invalidIdentical[$i];
   48:    $compares = $invalidIdentical[$i + 1];
   49:    foreach($compares as $compareVal) {
   50:       if ($typeToTestVal === $compareVal) {
   51:          echo "FAILED: '$typeToTestVal' === '$compareVal'\n";
   52:          $failed = true;
   53:       }
   54:    }
   55: }
   56: 
   57: if ($failed == false) {
   58:    echo "Test Passed\n";
   59: }
   60:    
   61: ?>
   62: ===DONE===
   63: --EXPECT--
   64: Test Passed
   65: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>