1#!./perl
2
3BEGIN {
4    unless (-d 'blib') {
5	chdir 't' if -d 't';
6	@INC = '../lib';
7	require Config; import Config;
8	keys %Config; # Silence warning
9	if ($Config{extensions} !~ /\bList\/Util\b/) {
10	    print "1..0 # Skip: List::Util was not built\n";
11	    exit 0;
12	}
13    }
14}
15
16use Scalar::Util qw(readonly);
17
18
19print "1..9\n";
20
21print "not " unless readonly(1);
22print "ok 1\n";
23
24my $var = 2;
25
26print "not " if readonly($var);
27print "ok 2\n";
28
29print "not " unless $var == 2;
30print "ok 3\n";
31
32print "not " unless readonly("fred");
33print "ok 4\n";
34
35$var = "fred";
36
37print "not " if readonly($var);
38print "ok 5\n";
39
40print "not " unless $var eq "fred";
41print "ok 6\n";
42
43$var = \2;
44
45print "not " if readonly($var);
46print "ok 7\n";
47
48print "not " unless readonly($$var);
49print "ok 8\n";
50
51print "not " if readonly(*STDOUT);
52print "ok 9\n";
53