X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/01050d49181679ee39712302d1af475c0d7549a4..1898a2f14d8075cd689403a1f731596867191835:/t/comp/fold.t diff --git a/t/comp/fold.t b/t/comp/fold.t index 69d1903..f6a9470 100644 --- a/t/comp/fold.t +++ b/t/comp/fold.t @@ -4,7 +4,7 @@ # we've not yet verified that use works. # use strict; -print "1..23\n"; +print "1..27\n"; my $test = 0; # Historically constant folding was performed by evaluating the ops, and if @@ -132,3 +132,29 @@ package other { # hide the "ok" sub print " ", ++$test, " - print followed by const || URSINE\n"; BEGIN { $^W = 1 } } + +# or stat +print "not " unless stat(1 ? INSTALL : 0) eq stat("INSTALL"); +print "ok ", ++$test, " - stat(const ? word : ....)\n"; +# in case we are in t/ +print "not " unless stat(1 ? TEST : 0) eq stat("TEST"); +print "ok ", ++$test, " - stat(const ? word : ....)\n"; + +# or truncate +my $n = "for_fold_dot_t$$"; +open F, ">$n" or die "open: $!"; +print F "bralh blah blah \n"; +close F or die "close $!"; +eval "truncate 1 ? $n : 0, 0;"; +print "not " unless -z $n; +print "ok ", ++$test, " - truncate(const ? word : ...)\n"; +unlink $n; + +# Constant folding should not change the mutability of returned values. +for(1+2) { + eval { $_++ }; + print "not " unless $_ eq 4; + print "ok ", ++$test, + " - 1+2 returns mutable value, just like \$a+\$b", + " # TODO\n"; +}