tagged release 0.7.1
[parrot.git] / languages / pipp / t / php / constant.t
blob700cbd9642a7cbee5c643409788ae0bd5de9d0b0
1 #! perl
2 # Copyright (C) 2008, The Perl Foundation.
3 # $Id$
5 =head1 NAME
7 t/php/var.t - Test for constants
9 =head1 SYNOPSIS
11     % perl -I../lib pipp/t/php/constants.t
13 =head1 DESCRIPTION
15 Tests support for constants.
17 See L<http://www.php.net/manual/en/language.constants.php>.
19 =cut
21 use strict;
22 use warnings;
24 use FindBin;
25 use lib "$FindBin::Bin/../../lib";
27 use Test::More     tests => 12;
28 use Parrot::Test;
30 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), string' );
31 <?php
33 define( "THIS_IS", "it" );
34 echo constant("THIS_IS"), "\n";
35 END_CODE
37 END_OUT
39 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), integer' );
40 <?php
42 define( "TEN_TIMES_TEN", 100 );
43 echo constant("TEN_TIMES_TEN"), "\n";
44 END_CODE
45 100
46 END_OUT
48 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), FALSE' );
49 <?php
51 define( "FAUX", FALSE );
52 echo constant("FAUX"), "\n";
53 END_CODE
55 END_OUT
57 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), NULL' );
58 <?php
60 define( "NUL", NULL );
61 echo constant("NUL"), "\n";
62 END_CODE
64 END_OUT
66 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), Float' );
67 <?php
69 define( "PI", 3.14159 );
70 echo constant("PI"), "\n";
71 END_CODE
72 3.14159
73 END_OUT
75 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and constant(), TRUE' );
76 <?php
78 define( "VRAI", TRUE );
79 echo constant("VRAI"), "\n";
80 END_CODE
82 END_OUT
84 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and echo, String' );
85 <?php
87 define( "THIS_IS", "it" );
88 echo THIS_IS;
89 echo "\n";
90 END_CODE
92 END_OUT
94 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and echo, Float' );
95 <?php
97 define( "PI", 3.14159 );
98 echo PI, "\n";
99 END_CODE
100 3.14159
101 END_OUT
103 language_output_like( 'Pipp', <<'END_CODE', <<'END_OUT', 'define(), Array' );
104 <?php
105   $hello['world'] = 'hi';
106   define( "HELLO", $hello );
107 END_CODE
108 /Constants may only evaluate to scalar values/
109 END_OUT
111 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() write once' );
112 <?php
114   echo define( 'MY_VAR', 'Ok' ), "\n";
115   echo define( 'MY_VAR', 'redefine' ), "\n";
116   echo MY_VAR, "\n";
117 END_CODE
121 END_OUT
123 language_output_is( 'Pipp', <<'END_CODE', <<'END_OUT', 'define() and defined()' );
124 <?php
126 define( "PI", 3.14159 );
127 echo defined("PI"), "\n";
128 echo defined("UNDEF_PI"), "\n";
129 END_CODE
132 END_OUT
134 language_output_like( 'Pipp', <<'END_CODE', <<'END_OUT', 'constant() undefined' );
135 <?php
137   echo constant("UNDEF_CST");
138 END_CODE
139 /Couldn't find constant UNDEF_CST/
140 END_OUT
142 # Local Variables:
143 #   mode: cperl
144 #   cperl-indent-level: 4
145 #   fill-column: 100
146 # End:
147 # vim: expandtab shiftwidth=4: