File: v2_07_list.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 (81 lines) | stat: -rw-r--r-- 2,062 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
# 07_list.t
#
# Tests for proper extraction of scalar values

use Parse::PlainConfig::Legacy;

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

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

# First series with smart parser off
#
# 1 list 1
$conf->read($rcfile);
($conf->parameter("LIST 1"))[2] eq "value3" ? print "ok $test\n" : 
	print "not ok $test\n";
$test++;

# 2 list 2
($conf->parameter("LIST 2"))[1] eq "two, parts" ? print "ok $test\n" : 
  print "not ok $test\n";
$test++;

# 3 list 3
($conf->parameter("LIST 3"))[2] eq "two => parts" ? print "ok $test\n" : 
  print "not ok $test\n";
$test++;

# Second series with smart parser on
#
# 4 list 1
$conf->property(SMART_PARSER => 1);
$conf->property(AUTOPURGE => 1);
$conf->read("${rcfile}_smart");
($conf->parameter("LIST 1"))[2] eq "value3" ? print "ok $test\n" : 
	print "not ok $test\n";
$test++;

# 5 list 2
($conf->parameter("LIST 2"))[1] eq "two, parts" ? print "ok $test\n" : 
  print "not ok $test\n";
$test++;

# 6 list 3 with list coercion set and smart parsing
$conf->coerce("list", "LIST 3");
$conf->read;
($conf->parameter("LIST 3"))[2] eq "two => parts" ? print "ok $test\n" : 
  print "not ok $test\n";
$test++;

# Set tests
#
# 7 new list 1
$conf->parameter("NEW LIST 1", [qw(this is a new list)]);
($conf->parameter("NEW LIST 1"))[2] eq "a" ? print "ok $test\n" : 
  print "not ok $test\n";
$test++;

# 8 new list 2 with coercion set
$conf->coerce("list", "NEW LIST 2");
$conf->parameter("NEW LIST 2", [qw(this is a new list)]);
($conf->parameter("NEW LIST 2"))[2] eq "a" ? print "ok $test\n" : 
  print "not ok $test\n";
$test++;

# 9 new list 2 with string value
$conf->parameter("NEW LIST 2", "this is new");
($conf->parameter("NEW LIST 2"))[0] eq "this is new" ? print "ok $test\n" : 
  print "not ok $test\n";
$test++;

# 10 new list 2 with hash value
$conf->parameter("NEW LIST 2", { 'this' => 'is', 'also' => 'new' });
($conf->parameter("NEW LIST 2"))[2] eq "this" ? print "ok $test\n" : 
  print "not ok $test\n";
$test++;

# end 07_list.t