diff options
author | Stevan Little <stevan.little@iinteractive.com> | 2012-09-12 22:54:08 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-09-20 11:34:37 -0500 |
commit | d014c200afc692c5aebacd8afa78150e3246afa7 (patch) | |
tree | d69aaede4bcd2280cdf3634bca10418d4d968b36 | |
parent | df3d31bc2fa148fe910fe091cfa9f12140849a80 (diff) | |
download | fun-d014c200afc692c5aebacd8afa78150e3246afa7.tar.gz fun-d014c200afc692c5aebacd8afa78150e3246afa7.zip |
slurpy tests
-rw-r--r-- | t/slurpy-syntax-errors.t | 18 | ||||
-rw-r--r-- | t/slurpy.t | 19 |
2 files changed, 37 insertions, 0 deletions
diff --git a/t/slurpy-syntax-errors.t b/t/slurpy-syntax-errors.t new file mode 100644 index 0000000..9f8ce3f --- /dev/null +++ b/t/slurpy-syntax-errors.t @@ -0,0 +1,18 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Fun; + +{ + eval 'fun ( $foo, @bar, $baz ) { return [] }'; + ok $@, '... got an error'; +} + +{ + eval 'fun ( $foo, %bar, $baz ) { return {} }'; + ok $@, '... got an error'; +} + +done_testing; diff --git a/t/slurpy.t b/t/slurpy.t new file mode 100644 index 0000000..da872ff --- /dev/null +++ b/t/slurpy.t @@ -0,0 +1,19 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Fun; + +fun test_array ( $foo, @bar ) { + return [ $foo, @bar ]; +} + +fun test_hash ( $foo, %bar ) { + return { foo => $foo, %bar }; +} + +is_deeply( test_array( 1, 2 .. 10 ), [ 1, 2 .. 10 ], '... slurpy array worked' ); +is_deeply( test_hash( 1, ( two => 2, three => 3 ) ), { foo => 1, two => 2, three => 3 }, '... slurpy hash worked' ); + +done_testing; |