Annotation of embedaddon/php/tests/classes/constants_basic_001.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Class constant declarations
                      3: --FILE--
                      4: <?php
                      5:   define('DEFINED', 1234);
                      6:   $def = 456;
                      7:   define('DEFINED_TO_VAR', $def);
                      8:   define('DEFINED_TO_UNDEF_VAR', $undef);
                      9:   
                     10:   class C
                     11:   {
                     12:       const c0 = UNDEFINED;
                     13:       
                     14:       const c1 = 1, c2 = 1.5;
                     15:       const c3 =  + 1, c4 =  + 1.5;
                     16:       const c5 = -1, c6 = -1.5;
                     17:       
                     18:       const c7 = __LINE__;
                     19:       const c8 = __FILE__;
                     20:       const c9 = __CLASS__;
                     21:       const c10 = __METHOD__;
                     22:       const c11 = __FUNCTION__;
                     23:       
                     24:       const c12 = DEFINED;
                     25:       const c13 = DEFINED_TO_VAR;
                     26:       const c14 = DEFINED_TO_UNDEF_VAR;
                     27:       
                     28:       const c15 = "hello1";
                     29:       const c16 = 'hello2';
                     30:       const c17 = C::c16;
                     31:       const c18 = self::c17;
                     32:   }
                     33:   
                     34:   echo "\nAttempt to access various kinds of class constants:\n";
                     35:   var_dump(C::c0);
                     36:   var_dump(C::c1);
                     37:   var_dump(C::c2);
                     38:   var_dump(C::c3);
                     39:   var_dump(C::c4);
                     40:   var_dump(C::c5);
                     41:   var_dump(C::c6);
                     42:   var_dump(C::c7);
                     43:   var_dump(C::c8);
                     44:   var_dump(C::c9);
                     45:   var_dump(C::c10);
                     46:   var_dump(C::c11);
                     47:   var_dump(C::c12);
                     48:   var_dump(C::c13);
                     49:   var_dump(C::c14);
                     50:   var_dump(C::c15);
                     51:   var_dump(C::c16);
                     52:   var_dump(C::c17);
                     53:   var_dump(C::c18);
                     54:   
                     55:   echo "\nExpecting fatal error:\n";
                     56:   var_dump(C::c19);
                     57:   
                     58:   echo "\nYou should not see this.";
                     59: ?>
                     60: --EXPECTF--
                     61: 
                     62: Notice: Undefined variable: undef in %s on line 5
                     63: 
                     64: Attempt to access various kinds of class constants:
                     65: 
                     66: Notice: Use of undefined constant UNDEFINED - assumed 'UNDEFINED' in %s on line %d
                     67: string(9) "UNDEFINED"
                     68: int(1)
                     69: float(1.5)
                     70: int(1)
                     71: float(1.5)
                     72: int(-1)
                     73: float(-1.5)
                     74: int(15)
                     75: string(%d) "%s"
                     76: string(1) "C"
                     77: string(1) "C"
                     78: string(0) ""
                     79: int(1234)
                     80: int(456)
                     81: NULL
                     82: string(6) "hello1"
                     83: string(6) "hello2"
                     84: string(6) "hello2"
                     85: string(6) "hello2"
                     86: 
                     87: Expecting fatal error:
                     88: 
                     89: Fatal error: Undefined class constant 'c19' in %s on line 53

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