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