summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--t/slurpy-syntax-errors.t18
-rw-r--r--t/slurpy.t19
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;