This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
new perldelta
[perl5.git] / t / op / cond.t
CommitLineData
8d063cd8
LW
1#!./perl
2
63811f13
CK
3BEGIN {
4 chdir 't' if -d 't';
63811f13 5 require './test.pl';
624c42e2 6 set_up_inc('../lib');
63811f13 7}
8d063cd8 8
63811f13
CK
9is( 1 ? 1 : 0, 1, 'compile time, true' );
10is( 0 ? 0 : 1, 1, 'compile time, false' );
8d063cd8
LW
11
12$x = 1;
63811f13
CK
13is( $x ? 1 : 0, 1, 'run time, true');
14is( !$x ? 0 : 1, 1, 'run time, false');
15
86e988be
DM
16# This used to SEGV due to deep recursion in Perl_scalar().
17# (Actually it only SEGVed with the depth being about 100_000; but
18# compiling the nested condition goes quadratic in some way, so I've
19# reduced to the count to a manageable size. So this is not so much a
20# proper test, as it is a comment on the sort of thing that used to break)
21
22{
23 my $e = "1";
24 $e = "(\$x ? 1 : $e)" for 1..20_000;
25 $e = "\$x = $e";
26 eval $e;
27 is $@, "", "SEGV in Perl_scalar";
28}
29
30
63811f13 31done_testing();