File: 22_readonly.t

package info (click to toggle)
libppi-perl 1.283-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,216 kB
  • sloc: perl: 15,295; makefile: 8
file content (36 lines) | stat: -rwxr-xr-x 843 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

# Testing of readonly functionality

use lib 't/lib';
use PPI::Test::pragmas;
use Test::More tests => 12 + ($ENV{AUTHOR_TESTING} ? 1 : 0);

use PPI::Document ();
use Helper 'safe_new';





#####################################################################
# Creating Documents

SCOPE: {
	# Blank document	
	my $empty = safe_new;
	is( $empty->readonly, '', '->readonly is false for blank' );

	# From source
	my $source = 'print "Hello World!\n"';
	my $doc1 = safe_new \$source;
	is( $doc1->readonly, '', '->readonly is false by default' );

	# With explicit false
	my $doc2 = safe_new \$source, readonly => undef;
	is( $doc2->readonly, '', '->readonly is false for explicit false' );

	# With explicit true
	my $doc3 = safe_new \$source, readonly => 2;
	is( $doc3->readonly, 1, '->readonly is true for explicit true' );
}