2 # Copyright (C) 2008, The Perl Foundation.
7 t/php/var.t - Test for constants
11 % perl -I../lib pipp/t/php/constants.t
15 Tests support for constants.
17 See L<http://www.php.net/manual/en/language.constants.php>.
25 use lib "$FindBin::Bin/../../lib";
27 use Test::More tests => 12;
30 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), string' );
33 define( "THIS_IS", "it" );
34 echo constant("THIS_IS"), "\n";
39 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), integer' );
42 define( "TEN_TIMES_TEN", 100 );
43 echo constant("TEN_TIMES_TEN"), "\n";
48 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), FALSE' );
51 define( "FAUX", FALSE );
52 echo constant("FAUX"), "\n";
57 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), NULL' );
60 define( "NUL", NULL );
61 echo constant("NUL"), "\n";
66 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), Float' );
69 define( "PI", 3.14159 );
70 echo constant("PI"), "\n";
75 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), TRUE' );
78 define( "VRAI", TRUE );
79 echo constant("VRAI"), "\n";
84 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and echo, String' );
87 define( "THIS_IS", "it" );
94 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and echo, Float' );
97 define( "PI", 3.14159 );
103 language_output_like( 'Pipp', <<'END_CODE', <<'END_OUT', 'define(), Array' );
105 $hello['world'] = 'hi';
106 define( "HELLO", $hello );
108 /Constants may only evaluate to scalar values/
111 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() write once' );
114 echo define( 'MY_VAR', 'Ok' ), "\n";
115 echo define( 'MY_VAR', 'redefine' ), "\n";
123 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and defined()' );
126 define( "PI", 3.14159 );
127 echo defined("PI"), "\n";
128 echo defined("UNDEF_PI"), "\n";
134 language_output_like( 'Pipp', <<'END_CODE', <<'END_OUT', 'constant() undefined' );
137 echo constant("UNDEF_CST");
139 /Couldn't find constant UNDEF_CST/
144 # cperl-indent-level: 4
147 # vim: expandtab shiftwidth=4: