X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fdor.t;h=079631a31d600ca5dacbea6f8a28b0baea4a7a81;hb=1c509eb921569425706e6fe39ea7cb2f11e99d1b;hp=67f2b77d7f84e232a31241b1c89603dd25ecff9c;hpb=75cc09e40ef43ffdb7866f862ed8a8f1528a2d9e;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/dor.t b/t/op/dor.t index 67f2b77..079631a 100644 --- a/t/op/dor.t +++ b/t/op/dor.t @@ -10,7 +10,7 @@ BEGIN { package main; require './test.pl'; -plan( tests => 33 ); +plan( tests => 41 ); my($x); @@ -23,6 +23,8 @@ is($x // 1, 1, ' // : left-hand operand undef'); $x=''; is($x // 0, '', ' // : left-hand operand defined but empty'); +like([] // 0, qr/^ARRAY/, ' // : left-hand operand a referece'); + $x=1; is(($x err 0), 1, ' err: left-hand operand defined'); @@ -32,16 +34,18 @@ is(($x err 1), 1, ' err: left-hand operand undef'); $x=''; is(($x err 0), '', ' err: left-hand operand defined but empty'); +like(([] err 0), qr/^ARRAY/, ' err: left-hand operand a referece'); + $x=undef; $x //= 1; is($x, 1, ' //=: left-hand operand undefined'); $x //= 0; -is($x, 1, ' //=: left-hand operand defined'); +is($x, 1, '//=: left-hand operand defined'); $x = ''; $x //= 0; -is($x, '', ' //=: left-hand operand defined but empty'); +is($x, '', '//=: left-hand operand defined but empty'); @ARGV = (undef, 0, 3); is(shift // 7, 7, 'shift // ... works'); @@ -78,3 +82,15 @@ like( $@, qr/^Search pattern not terminated/ ); is(0 // 2, 0, ' // : left-hand operand not optimized away'); is('' // 2, '', ' // : left-hand operand not optimized away'); is(undef // 2, 2, ' // : left-hand operand optimized away'); + +# [perl #32347] err should be a weak keyword + +package weakerr; + +sub err { "<@_>" } +::is( (shift() err 42), 42, 'err as an operator' ); +::is( (shift err 42), 42, 'err as an operator, with ambiguity' ); +::is( (err 2), "<2>", 'err as a function without parens' ); +::is( err(2, 3), "<2 3>", 'err as a function with parens' ); +::is( err(), "<>", 'err as a function without arguments' ); +::is( err, "<>", 'err as a function without parens' );