File: v2_06_scalar.t

package info (click to toggle)
libparse-plainconfig-perl 3.07-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 1,916; makefile: 2
file content (98 lines) | stat: -rw-r--r-- 2,642 bytes parent folder | download | duplicates (5)
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
# 06_scalar.t
#
# Tests for proper extraction of scalar values

use Parse::PlainConfig::Legacy;

$|++;
print "1..13\n";

my $test   = 1;
my $rcfile = './t/v2_testrc';
my $conf   = Parse::PlainConfig::Legacy->new(FILE => $rcfile);

# First series with smart parser off
#
# 1 scalar 1
$conf->read($rcfile);
$conf->parameter("SCALAR 1") eq "value1" ? print "ok $test\n" : 
	print "not ok $test\n";
$test++;

# 2 scalar 2
$conf->parameter("SCALAR 2") eq "these, are, all one => value" ? 
  print "ok $test\n" : print "not ok $test\n";
$test++;

# 3 scalar 3
$conf->parameter("SCALAR 3") eq "this is a continued line." ?
  print "ok $test\n" : print "not ok $test\n";
$test++;

# 4 scalar 4
$conf->parameter("SCALAR 4") eq 
  "ASDFKAS234123098ASDFA9082341ASDFIO23489078907SFASDF8A972" ?
  print "ok $test\n" : print "not ok $test\n";
$test++;

# Second series with smart parser on
#
# 5 scalar 1
$conf->property(SMART_PARSER => 1);
$conf->property(AUTOPURGE => 1);
$conf->read("${rcfile}_smart");
$conf->parameter("SCALAR 1") eq "value1" ? print "ok $test\n" : 
	print "not ok $test\n";
$test++;

# 6 scalar 2
$conf->parameter("SCALAR 2") eq "these, are, all one => value" ? 
  print "ok $test\n" : print "not ok $test\n";
$test++;

# 7 scalar 3
$conf->parameter("SCALAR 3") eq "this is a continued line." ?
  print "ok $test\n" : print "not ok $test\n";
$test++;

# 8 scalar 4
$conf->parameter("SCALAR 4") eq 
  "ASDFKAS234123098ASDFA9082341ASDFIO23489078907SFASDF8A972" ?
  print "ok $test\n" : print "not ok $test\n";
$test++;

# 9 scalar 2 with scalar coercion set and smart parsing
$conf->coerce("string", "SCALAR 2");
$conf->read;
$conf->parameter("SCALAR 2") eq '"these, are, all one => value"' ? 
  print "ok $test\n" : print "not ok $test\n";
$test++;

# Set tests
#
# 10 new scalar 1
$conf->parameter("NEW SCALAR 1", "this is new");
$conf->parameter("NEW SCALAR 1") eq "this is new" ?
  print "ok $test\n" : print "not ok $test\n";
$test++;

# 11 new scalar 2 with coercion set
$conf->coerce("string", "NEW SCALAR 2");
$conf->parameter("NEW SCALAR 2", "this is also new");
$conf->parameter("NEW SCALAR 2") eq "this is also new" ?
  print "ok $test\n" : print "not ok $test\n";
$test++;

# 12 new scalar 2 with list value
$conf->parameter("NEW SCALAR 2", [qw(this is new again)]);
$conf->parameter("NEW SCALAR 2") eq "this , is , new , again" ?
  print "ok $test\n" : print "not ok $test\n";
$test++;

# 13 new scalar 2 with hash value
$conf->parameter("NEW SCALAR 2", {qw(this is new indeed)});
$conf->parameter("NEW SCALAR 2") eq "new => indeed , this => is" ?
  print "ok $test\n" : print "not ok $test\n";
$test++;

# end 06_scalar.t