summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRobin Houston <robin@cpan.org>2005-12-21 11:00:08 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-12-21 16:16:19 +0000
commitbc9b29dbf2ff006e91ae1d732887485497f58896 (patch)
tree4147ad5078d3b0f0201672a8a8876a5ace346c4e /t
parent565a3db3dc85d0f63074b38e7019290e4f8f3766 (diff)
downloadperl-bc9b29dbf2ff006e91ae1d732887485497f58896.tar.gz
Feature bundle is now :5.10, and add -E switch
Message-ID: <20051221110008.GB25877@rpc142.cs.man.ac.uk> p4raw-id: //depot/perl@26432
Diffstat (limited to 't')
-rw-r--r--t/lib/feature/err66
-rw-r--r--t/lib/feature/nonesuch10
-rw-r--r--t/lib/warnings/op1
-rw-r--r--t/op/dor.t15
-rw-r--r--t/run/switches.t27
5 files changed, 104 insertions, 15 deletions
diff --git a/t/lib/feature/err b/t/lib/feature/err
new file mode 100644
index 0000000000..638b5a68ea
--- /dev/null
+++ b/t/lib/feature/err
@@ -0,0 +1,66 @@
+Check the lexical scoping of the err keyword.
+(The actual behaviour is tested in t/op/dor.t)
+
+__END__
+# No err; should be a syntax error.
+use warnings;
+my $undef err print "Hello!\n";
+EXPECT
+Bareword found where operator expected at - line 3, near "$undef err"
+ (Missing operator before err?)
+Unquoted string "err" may clash with future reserved word at - line 3.
+syntax error at - line 3, near "$undef err "
+Execution of - aborted due to compilation errors.
+########
+# With err, should work
+use warnings;
+use feature "err";
+my $undef err print "Hello", "world";
+EXPECT
+Helloworld
+########
+# With err, should work in eval too
+use warnings;
+use feature "err";
+eval q(my $undef err print "Hello", "world");
+EXPECT
+Helloworld
+########
+# feature out of scope; should be a syntax error.
+use warnings;
+{ use feature 'err'; }
+my $undef err print "Hello", "world";
+EXPECT
+Bareword found where operator expected at - line 4, near "$undef err"
+ (Missing operator before err?)
+Unquoted string "err" may clash with future reserved word at - line 4.
+syntax error at - line 4, near "$undef err "
+Execution of - aborted due to compilation errors.
+########
+# 'no feature' should work
+use warnings;
+use feature 'err';
+my $undef err print "Hello", "world";
+no feature;
+my $undef2 err "Hello", "world";
+EXPECT
+Bareword found where operator expected at - line 6, near "$undef2 err"
+ (Missing operator before err?)
+Unquoted string "err" may clash with future reserved word at - line 6.
+String found where operator expected at - line 6, near "err "Hello""
+ (Do you need to predeclare err?)
+syntax error at - line 6, near "$undef2 err "
+Execution of - aborted due to compilation errors.
+########
+# 'no feature "err"' should work too
+use warnings;
+use feature 'err';
+my $undef err print "Hello", "world";
+no feature 'err';
+$undef err print "Hello", "world";
+EXPECT
+Bareword found where operator expected at - line 6, near "$undef err"
+ (Missing operator before err?)
+Unquoted string "err" may clash with future reserved word at - line 6.
+syntax error at - line 6, near "$undef err "
+Execution of - aborted due to compilation errors.
diff --git a/t/lib/feature/nonesuch b/t/lib/feature/nonesuch
index 1de44f621b..0de975ad54 100644
--- a/t/lib/feature/nonesuch
+++ b/t/lib/feature/nonesuch
@@ -10,3 +10,13 @@ no feature "nonesuch";
EXPECT
OPTIONS regex
^Feature "nonesuch" is not supported by Perl [v0-9.]+ at - line 1
+########
+use feature ":nonesuch";
+EXPECT
+OPTIONS regex
+^Feature bundle "nonesuch" is not supported by Perl [v0-9.]+ at - line 1
+########
+no feature ":nonesuch";
+EXPECT
+OPTIONS regex
+^Feature bundle "nonesuch" is not supported by Perl [v0-9.]+ at - line 1
diff --git a/t/lib/warnings/op b/t/lib/warnings/op
index c39a7b2fd9..ca92412d62 100644
--- a/t/lib/warnings/op
+++ b/t/lib/warnings/op
@@ -679,6 +679,7 @@ Value of readdir() operator can be "0"; test with defined() at - line 4.
########
# op.c
use warnings 'misc';
+use feature 'err';
open FH, "<abc";
$_ = <FH> err $_ = 1;
($_ = <FH>) // ($_ = 1);
diff --git a/t/op/dor.t b/t/op/dor.t
index 079631a31d..04e0f7d8e7 100644
--- a/t/op/dor.t
+++ b/t/op/dor.t
@@ -8,9 +8,10 @@ BEGIN {
}
package main;
+use feature "err";
require './test.pl';
-plan( tests => 41 );
+plan( tests => 35 );
my($x);
@@ -82,15 +83,3 @@ 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' );
diff --git a/t/run/switches.t b/t/run/switches.t
index a63c54b9f5..f654486467 100644
--- a/t/run/switches.t
+++ b/t/run/switches.t
@@ -1,7 +1,7 @@
#!./perl -w
# Tests for the command-line switches:
-# -0, -c, -l, -s, -m, -M, -V, -v, -h, -z, -i
+# -0, -c, -l, -s, -m, -M, -V, -v, -h, -z, -i, -E
# Some switches have their own tests, see MANIFEST.
BEGIN {
@@ -11,7 +11,7 @@ BEGIN {
require "./test.pl";
-plan(tests => 26);
+plan(tests => 30);
use Config;
@@ -282,3 +282,26 @@ __EOF__
"foo yada dada:bada foo bing:king kong foo",
"-i backup file");
}
+
+# Tests for -E
+
+$r = runperl(
+ switches => [ '-E', '"say q(Hello, world!)"']
+);
+is( $r, "Hello, world!\n", "-E say" );
+
+
+$r = runperl(
+ switches => [ '-E', '"undef err say q(Hello, world!)"']
+);
+is( $r, "Hello, world!\n", "-E err" );
+
+$r = runperl(
+ switches => [ '-E', '"undef ~~ undef and say q(Hello, world!)"']
+);
+is( $r, "Hello, world!\n", "-E ~~" );
+
+$r = runperl(
+ switches => [ '-E', '"given(undef) {when(undef) { say q(Hello, world!)"}}']
+);
+is( $r, "Hello, world!\n", "-E given" );