File: listquote.t

package info (click to toggle)
libdevel-callparser-perl 0.002-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 292 kB
  • sloc: perl: 73; sh: 4; makefile: 3
file content (123 lines) | stat: -rw-r--r-- 2,497 bytes parent folder | download | duplicates (4)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
use warnings;
use strict;

use Test::More tests => 47;
use t::LoadXS ();
use t::WriteHeader ();

t::WriteHeader::write_header("callparser0", "t", "listquote");
ok 1;
require_ok "Devel::CallParser";
t::LoadXS::load_xs("listquote", "t",
	[Devel::CallParser::callparser_linkable()]);
ok 1;

my($foo_got, $foo_ret);
sub foo { $foo_got = [ @_ ]; return "z"; }

$foo_got = undef;
eval q{$foo_ret = foo 1231;};
is $@, "";
is_deeply $foo_got, [ 1231 ];
is $foo_ret, "z";

$foo_got = undef;
eval q{$foo_ret = &foo(1231);};
is $@, "";
is_deeply $foo_got, [ 1231 ];
is $foo_ret, "z";

t::listquote::cv_set_call_parser_listquote(\&foo, "xyz");

$foo_got = undef;
eval q{$foo_ret = foo 1231;};
is $@, "";
is_deeply $foo_got, [ "xyz", "2", "3" ];
is $foo_ret, "z";

$foo_got = undef;
eval q{$foo_ret = &foo(1231);};
is $@, "";
is_deeply $foo_got, [ 1231 ];
is $foo_ret, "z";

$foo_got = undef;
eval q{$foo_ret = foo:ab cd:;};
is $@, "";
is_deeply $foo_got, [ "xyz", "a", "b", " ", "c", "d" ];
is $foo_ret, "z";

$foo_got = undef;
eval q{$foo_ret = foo!ab cd!;};
isnt $@, "";
is $foo_got, undef;

$foo_got = undef;
eval q{foo!ab cd!;};
is $@, "";
is_deeply $foo_got, [ "xyz", "a", "b", " ", "c", "d" ];

$foo_got = undef; $foo_ret = undef;
eval q{foo!ab cd! package main; $foo_ret = "z";};
is $@, "";
is_deeply $foo_got, [ "xyz", "a", "b", " ", "c", "d" ];
is $foo_ret, "z";

$foo_got = undef; $foo_ret = undef;
eval q{foo:ab cd: package main; $foo_ret = "z";};
isnt $@, "";
is $foo_got, undef;

*bar = \&foo; *bar = \&foo;

$foo_got = undef;
eval q{$foo_ret = bar:ab cd:;};
is $@, "";
is_deeply $foo_got, [ "xyz", "a", "b", " ", "c", "d" ];
is $foo_ret, "z";

*wibble::baz = \&foo; *wibble::baz = \&foo;

$foo_got = undef;
eval q{package wibble; $foo_ret = baz:ab cd:;};
is $@, "";
is_deeply $foo_got, [ "xyz", "a", "b", " ", "c", "d" ];
is $foo_ret, "z";

sub bin($$) { $foo_got = [ @_ ]; return "z"; }

$foo_got = undef;
eval q{$foo_ret = bin 1, 2;};
is $@, "";
is_deeply $foo_got, [ 1, 2 ];
is $foo_ret, "z";

$foo_got = undef;
eval q{$foo_ret = bin 1;};
isnt $@, "";
is $foo_got, undef;

$foo_got = undef;
eval q{$foo_ret = bin 1, 2, 3;};
isnt $@, "";
is $foo_got, undef;

t::listquote::cv_set_call_parser_listquote(\&bin, "aaa");

$foo_got = undef;
eval q{$foo_ret = bin|b|;};
is $@, "";
is_deeply $foo_got, [ "aaa", "b" ];
is $foo_ret, "z";

$foo_got = undef;
eval q{$foo_ret = bin||;};
isnt $@, "";
is $foo_got, undef;

$foo_got = undef;
eval q{$foo_ret = bin|bc|;};
isnt $@, "";
is $foo_got, undef;

1;