File: split_proto.t

package info (click to toggle)
libmethod-signatures-perl 20120523-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 468 kB
  • sloc: perl: 2,060; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,174 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl -w

use strict;
use warnings;

use Test::More 'no_plan';

use Method::Signatures::Parser;

my %tests = (
    '$foo'              => ['$foo'],
    '$foo, $bar'        => ['$foo', '$bar'],
    ':$foo, $bar?'      => [':$foo', '$bar?'],
    ''                  => [],
    '$sum = 2+2, $div = 2/2'    => ['$sum = 2+2', '$div = 2/2'],
    '$foo = "Hello, world!"'    => ['$foo = "Hello, world!"'],
    '@args = (1,2,3)'   => ['@args = (1,2,3)'],
    '$foo = [1,2,3], $bar = { this => 23, that => 42 }' => [
        '$foo = [1,2,3]', '$bar = { this => 23, that => 42 }'
    ],
    '$code = sub { my $bar = 2+2; }, :$this'    =>  ['$code = sub { my $bar = 2+2; }', ':$this'],

    q[
        $num    = 42,
        $string = q[Hello, world!],
        $hash   = { this => 42, that => 23 },
        $code   = sub { $num + 4 },
        @nums   = (1,2,3)
    ]   =>
    [
        '$num    = 42',
        '$string = q[Hello, world!]',
        '$hash   = { this => 42, that => 23 }',
        '$code   = sub { $num + 4 }',
        '@nums   = (1,2,3)'
    ],
);

while(my($args, $expect) = each %tests) {
    is_deeply [split_proto($args)], $expect, "split_proto($args)";
}