xref: /openbsd-src/gnu/usr.bin/perl/t/comp/bproto.t (revision 5759b3d249badf144a6240f7eec4dcf9df003e6b)
1#!./perl
2#
3# check if builtins behave as prototyped
4#
5
6# Ideally tests in t/comp wouldn't use require, as require isn't tested yet
7print "1..16\n";
8
9my $i = 1;
10
11sub foo {}
12my $bar = "bar";
13
14sub test_too_many {
15    eval $_[0];
16    print "not " unless $@ =~ /^Too many arguments/;
17    printf "ok %d\n",$i++;
18}
19
20sub test_too_few {
21    eval $_[0];
22    print "not " unless $@ =~ /^Not enough arguments/;
23    printf "ok %d\n",$i++;
24}
25
26sub test_no_error {
27    eval $_[0];
28    print "not " if $@;
29    printf "ok %d\n",$i++;
30}
31
32test_too_many($_) for split /\n/,
33q[	defined(&foo, $bar);
34	pos(1,$b);
35	undef(&foo, $bar);
36	uc($bar,$bar);
37];
38
39test_too_few($_) for split /\n/,
40q[	unpack;
41	pack;
42];
43
44test_no_error($_) for split /\n/,
45q[	scalar(&foo,$bar);
46	defined &foo, &foo, &foo;
47	undef &foo, $bar;
48	uc $bar,$bar;
49	grep(not($bar), $bar);
50	grep(not($bar, $bar), $bar);
51	grep((not $bar, $bar, $bar), $bar);
52        __FILE__();
53        __LINE__();
54        __PACKAGE__();
55];
56