From 95c52ddd8dcdd6cd0de626eb8e4b117efc54e9e1 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 15 Jun 2013 19:42:35 -0700 Subject: [PATCH] Test !0 and !1 immutability and singletonness The latter (for bug #114838) is a to-do test under ithreads. --- t/op/not.t | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/t/op/not.t b/t/op/not.t index 8df5774..e82f627 100644 --- a/t/op/not.t +++ b/t/op/not.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 19; +plan tests => 23; # not() tests pass("logical negation of empty list") if not(); @@ -76,3 +76,18 @@ SKIP: my $c = Scalar::Util::dualvar(0,"1"); is not($c), "", 'not(dualvar) ignores false int when string is true'; } + +# not’s return value should be read-only, as it is the same global scalar +# each time (and test that it is, too). +*yes = \not 0; +*no = \not 1; +for (!0) { eval { $_ = 43 } } +like $@, qr/^Modification of a read-only value attempted at /, + 'not 0 is read-only'; +for (!1) { eval { $_ = 43 } } +like $@, qr/^Modification of a read-only value attempted at /, + 'not 1 is read-only'; +require Config; +$::TODO = 'not fixed yet' if $Config::Config{useithreads};; +is \!0, \$yes, '!0 returns the same value each time [perl #114838]'; +is \!1, \$no, '!1 returns the same value each time [perl #114838]'; -- 2.7.4