diff options
author | Nicholas Clark <nick@ccl4.org> | 2022-08-03 22:08:44 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2022-08-04 08:38:03 +0200 |
commit | dfbf5f46d1d33033c44ae80f74f875abf73e5e02 (patch) | |
tree | 792039e218a9e7c79a300bad294c8b93b1af2fcb /t/cmd | |
parent | a2b22270f3af59c82af647bc8a155a62b9dea494 (diff) | |
download | perl-dfbf5f46d1d33033c44ae80f74f875abf73e5e02.tar.gz |
Add tests for `do { ... } while 0;` and `do { ... } until 1;`
Astoundingly, even though we had the perl code as a comment in the C code
which handles this special case in Perl_newLOOPOP(), we didn't actually have
a regression test for it. Father C added a test case for a variant in commit
fc39925ca702f4c8 in Dec 2013, where the value for until is a constant, but
constant folding fails, but the "simple" version never actually had a test
case.
This commit adds the missing test cases.
Diffstat (limited to 't/cmd')
-rw-r--r-- | t/cmd/mod.t | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/t/cmd/mod.t b/t/cmd/mod.t index d3048e7920..36a3a00a32 100644 --- a/t/cmd/mod.t +++ b/t/cmd/mod.t @@ -1,6 +1,6 @@ #!./perl -print "1..13\n"; +print "1..15\n"; print "ok 1\n" if 1; print "not ok 1\n" unless 1; @@ -54,3 +54,19 @@ print "not ok 12\n" if $x > 0; # This used to cause a segfault $x = "".("".do{"foo" for (1)}); print "ok 13\n"; + +$x = 0; +do { ++$x } while 0; +if ($x == 1) { + print "ok 14\n"; +} else { + print "not ok 14 # $x\n"; +} + +$x = 0; +do { ++$x } until 1; +if ($x == 1) { + print "ok 15\n"; +} else { + print "not ok 15 # $x\n"; +} |