Permalink
Browse files

add more test

  • Loading branch information...
1 parent e1042e5 commit 1350fdd18bc7ad3524ea860f5885e44bea59fbdb @szabgab committed Apr 25, 2009
Showing with 21 additions and 1 deletion.
  1. +9 −0 t/01-test.t
  2. +12 −1 t/03-warn.t
View
@@ -62,6 +62,15 @@ my %tests = (
"-1,~" => 0,
"16384,~,~" => 16384,
+
+ "6,1,MIN" => 1,
+ "1,-2,MIN" => -2,
+ "-1,-2,MIN" => -2,
+ "6,1,MAX" => 6,
+ "1,-2,MAX" => 1,
+ "-1,-2,MAX" => -1,
+
+
);
my %rand = (
View
@@ -7,7 +7,7 @@ use Test::Warn;
use Math::RPN;
-plan tests => 1 + 4;
+plan tests => 1 + 10;
# Should produce a stack underflow
my $result;
@@ -21,6 +21,17 @@ is $result, 5;
my @result = rpn("9,3,2,+");
is_deeply \@result, [9, 5], 'stack overflow in array context';
+warning_like {@result = rpn("5,3,{,{,2,1")} qr/err: Cannot nest braces expr 5,3,<<<\{>>>,2,1 at/, 'cannot nest braces';
+is_deeply \@result, [5, 3]; # is this just accident?
+
+
+warning_like {@result = rpn("5,3,}")} qr/err: Unexpected Right Brace 5,3,<<<\}>>>,/, 'expected brace';
+is_deeply \@result, [5, 3]; # is this just accident?
+
+
+warning_like {$result = rpn("5,3,+,+")} qr/err: Stack Underflow in 5,3,\+,<<<\+>>>, at /;
+is $result, undef;
+
#warning_like {$result = rpn("5,3,{,{,2,1,=")} qr/xxx/;
#is $result, undef;

0 comments on commit 1350fdd

Please sign in to comment.