summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSalvador FandiƱo <sfandino@yahoo.com>2005-06-13 17:48:01 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-06-14 08:52:46 +0000
commitaefc56c5a86a8918fc9d52065e8cf4df301d4ee4 (patch)
tree540d157b633c8c7ef6ef0a17ae1e84be71803028 /t
parent5eb567df529229d30d1a4d7c913a67cbd444dacb (diff)
downloadperl-aefc56c5a86a8918fc9d52065e8cf4df301d4ee4.tar.gz
better assertion support
Message-ID: <20050613154719.29295.qmail@lists.develooper.com> p4raw-id: //depot/perl@24832
Diffstat (limited to 't')
-rw-r--r--t/comp/assertions.t6
-rw-r--r--t/comp/asstcompat.t40
-rwxr-xr-xt/run/switch_A.t9
3 files changed, 48 insertions, 7 deletions
diff --git a/t/comp/assertions.t b/t/comp/assertions.t
index da9f5680ff..9edc13a1da 100644
--- a/t/comp/assertions.t
+++ b/t/comp/assertions.t
@@ -45,17 +45,17 @@ require assertions;
while (@expr) {
my $expr=shift @expr;
my $expected=shift @expr;
- my $result=eval {assertions::calc_expr($expr)};
+ my $result=eval {assertions::_calc_expr($expr)};
if (defined $expected) {
unless (defined $result and $result == $expected) {
- print STDERR "assertions::calc_expr($expr) failed,".
+ print STDERR "assertions::_calc_expr($expr) failed,".
" expected '$expected' but '$result' obtained (\$@=$@)\n";
print "not ";
}
}
else {
if (defined $result) {
- print STDERR "assertions::calc_expr($expr) failed,".
+ print STDERR "assertions::_calc_expr($expr) failed,".
" expected undef but '$result' obtained\n";
print "not ";
}
diff --git a/t/comp/asstcompat.t b/t/comp/asstcompat.t
new file mode 100644
index 0000000000..fa0a357837
--- /dev/null
+++ b/t/comp/asstcompat.t
@@ -0,0 +1,40 @@
+#!./perl
+
+my $i = 1;
+sub ok {
+ my $ok = shift;
+ print( ($ok ? '' : 'not '), "ok $i", (@_ ? " - @_" : ''), "\n");
+ $i++;
+}
+
+print "1..7\n";
+
+# 1
+use base 'assertions::compat';
+ok(eval "sub assert_foo : assertion { 0 } ; 1", "handle assertion attribute");
+
+use assertions::activate 'Foo';
+
+# 2
+use assertions::compat asserting_2 => 'Foo';
+ok(asserting_2, 'on');
+
+# 3
+use assertions::compat asserting_3 => 'Bar';
+ok(!asserting_3, 'off');
+
+# 4
+use assertions::compat asserting_4 => '_ || Bar';
+ok(!asserting_4, 'current off or off');
+
+# 5
+use assertions::compat asserting_5 => '_ || Foo';
+ok(asserting_5, 'current off or on');
+
+# 6
+use assertions::compat asserting_6 => '_ || Bar';
+ok(asserting_6, 'current on or off');
+
+# 7
+use assertions::compat asserting_7 => '_ && Foo';
+ok(asserting_7, 'current on and on');
diff --git a/t/run/switch_A.t b/t/run/switch_A.t
index d79f430df0..5111b9d6ef 100755
--- a/t/run/switch_A.t
+++ b/t/run/switch_A.t
@@ -13,24 +13,25 @@ BEGIN {
#1
fresh_perl_is('sub cm : assertion { "ok" }; use assertions Hello; print cm()',
'ok',
- { switches => ['-AHello'] }, '-AHello');
+ { switches => ['-A=Hello'] }, '-A=Hello');
#2
fresh_perl_is('sub cm : assertion { "ok" }; use assertions SDFJKS; print cm()',
'ok',
- { switches => ['-A.*'] }, '-A.*');
+ { switches => ['-A=.*'] }, '-A=.*');
#3
fresh_perl_is('sub cm : assertion { "ok" }; use assertions Bye; print cm()',
'ok',
- { switches => ['-AB.e'] }, '-AB.e');
+ { switches => ['-A=B.e'] }, '-A=B.e');
#4
fresh_perl_is('sub cm : assertion { "ok" }; use assertions Hello; print cm()',
'0',
- { switches => ['-ANoH..o'] }, '-ANoH..o');
+ { switches => ['-A=NoH..o'] }, '-A=NoH..o');
#5
fresh_perl_is('sub cm : assertion { "ok" }; use assertions Hello; print cm()',
'ok',
{ switches => ['-A'] }, '-A');
+