In perl.git, the branch blead has been updated <https://perl5.git.perl.org/perl.git/commitdiff/09305603e04e74c6e7ae78285e97a929dfc336e7?hp=6beede9533e4bc8c9b4d67a42483123c6adafd78>
- Log ----------------------------------------------------------------- commit 09305603e04e74c6e7ae78285e97a929dfc336e7 Author: Nicolas R <[email protected]> Date: Fri May 31 09:42:32 2019 -0600 Add unit test for compiled once RegExp Make sure that when using a Regexp with /o the RegExp is frozen as expected. Using a BEGIN block to freeze the RegExp is also providing extra code coverage for the perl compiler. ----------------------------------------------------------------------- Summary of changes: MANIFEST | 1 + t/re/begin-once.t | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 t/re/begin-once.t diff --git a/MANIFEST b/MANIFEST index 6d49721f86..bb1e5a1bf7 100644 --- a/MANIFEST +++ b/MANIFEST @@ -5830,6 +5830,7 @@ t/porting/test_bootstrap.t Test that the instructions for test bootstrapping are t/porting/utils.t Check that utility scripts still compile t/re/alpha_assertions.t See if things like '(*postive_lookahed:...) work properly t/re/anyof.t See if bracketed char classes [...] compile properly +t/re/begin-once.t Checking that /o freeze a variable in a RegExp t/re/charset.t See if regex modifiers like /d, /u work properly t/re/fold_grind.pl Core file to see if regex case folding works properly t/re/fold_grind_8.t Wrapper for fold_grind.pl for /l testing with a UTF-8 locale diff --git a/t/re/begin-once.t b/t/re/begin-once.t new file mode 100644 index 0000000000..e41d431830 --- /dev/null +++ b/t/re/begin-once.t @@ -0,0 +1,28 @@ +#!./perl + +use strict; +use warnings; + +sub freeze_at_begin { + my ($var) = @_; + + return $var =~ m{$var}o; +} + +BEGIN { + chdir 't' if -d 't'; + require './test.pl'; + + freeze_at_begin('frozen'); +} + +plan tests => 2; + +ok( !freeze_at_begin('not'), "/o done at begin is preserved and a new string does not match" ); +ok( freeze_at_begin('frozen'), "/o done at begin is preserved and the original string matches" ); + +1; + +# +# ex: set ts=8 sts=4 sw=4 et: +# -- Perl5 Master Repository
