From d014c200afc692c5aebacd8afa78150e3246afa7 Mon Sep 17 00:00:00 2001 From: Stevan Little Date: Wed, 12 Sep 2012 22:54:08 -0400 Subject: slurpy tests --- t/slurpy-syntax-errors.t | 18 ++++++++++++++++++ t/slurpy.t | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 t/slurpy-syntax-errors.t create mode 100644 t/slurpy.t 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; -- cgit v1.2.3-54-g00ecf