import some (modified) signatures tests
[p5sagit/Function-Parameters.git] / t / foreign / signatures / proto.t
diff --git a/t/foreign/signatures/proto.t b/t/foreign/signatures/proto.t
new file mode 100644 (file)
index 0000000..ded1cc4
--- /dev/null
@@ -0,0 +1,43 @@
+#!perl
+use strict;
+use warnings;
+use Test::More tests => 7;
+
+use vars qw/@warnings/;
+BEGIN { $SIG{__WARN__} = sub { push @warnings, @_ } }
+
+BEGIN { is(@warnings, 0, 'no warnings yet') }
+
+use Function::Parameters;
+
+fun with_proto ($x, $y, $z) : ($$$) {
+    return $x + $y + $z;
+}
+
+{
+    my $foo;
+    fun with_lvalue () : () lvalue { $foo }
+}
+
+is(prototype('with_proto'), '$$$', ':proto attribute');
+
+is(prototype('with_lvalue'), '', ':proto with other attributes');
+with_lvalue = 1;
+is(with_lvalue, 1, 'other attributes still there');
+
+BEGIN { is(@warnings, 0, 'no warnings with correct :proto declarations') }
+
+fun invalid_proto ($x) : (invalid) { $x }
+
+BEGIN {
+    TODO: {
+        local $TODO = ':proto checks not yet implemented';
+        is(@warnings, 1, 'warning with illegal :proto');
+        like(
+            $warnings[0],
+            qr/Illegal character in prototype for fun invalid_proto : invalid at /,
+            'warning looks sane',
+        );
+    }
+}
+