File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / lang / operators / operator_gt_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, 5 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: $validGreaterThan = array (
   16: MAX_32Bit, array(MAX_32Bit - 1, "2147483646", "2147483646.999", 2.147483646e9, 2147483646.9, MIN_32Bit),
   17: -2147483647, array(MIN_32Bit, "-2147483648", "-2147483647.001", -2.1474836471e9, -2147483647.9),
   18: );
   19: 
   20: $invalidGreaterThan = array (
   21: MAX_32Bit, array(2e33, MAX_32Bit + 1),
   22: MIN_32Bit, array(MIN_32Bit + 1, MAX_32Bit)
   23: );
   24: 
   25: 
   26: 
   27: $failed = false;
   28: // test valid values
   29: for ($i = 0; $i < count($validGreaterThan); $i +=2) {
   30:    $typeToTestVal = $validGreaterThan[$i];
   31:    $compares = $validGreaterThan[$i + 1];
   32:    foreach($compares as $compareVal) {
   33:       if ($typeToTestVal > $compareVal) {
   34:          // do nothing
   35:       }
   36:       else {
   37:          echo "FAILED: '$typeToTestVal' <= '$compareVal'\n";
   38:          $failed = true;
   39:       }
   40:    }
   41: }
   42: // test for invalid values
   43: for ($i = 0; $i < count($invalidGreaterThan); $i +=2) {
   44:    $typeToTestVal = $invalidGreaterThan[$i];
   45:    $compares = $invalidGreaterThan[$i + 1];
   46:    foreach($compares as $compareVal) {
   47:       if ($typeToTestVal > $compareVal) {
   48:          echo "FAILED: '$typeToTestVal' > '$compareVal'\n";
   49:          $failed = true;
   50:       }
   51:    }
   52: }
   53: 
   54: if ($failed == false) {
   55:    echo "Test Passed\n";
   56: }
   57:    
   58: ?>
   59: ===DONE===
   60: --EXPECT--
   61: Test Passed
   62: ===DONE===

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