summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2019-08-28 16:26:05 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2019-08-28 16:26:05 (GMT)
commiteb498b5c1a53dcfe8fe9ba8bde08b671cbf329ed (patch) (side-by-side diff)
tree0370b3189098f28c6faf40c73f87f23817fd75a3
parent2be036c82a4d212152af6318eb1bcc749c565db7 (diff)
downloadconfig-ast-eb498b5c1a53dcfe8fe9ba8bde08b671cbf329ed.tar.gz
config-ast-eb498b5c1a53dcfe8fe9ba8bde08b671cbf329ed.tar.bz2
Add new testcase
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--t/04descr.t50
1 files changed, 50 insertions, 0 deletions
diff --git a/t/04descr.t b/t/04descr.t
new file mode 100644
index 0000000..501a760
--- a/dev/null
+++ b/t/04descr.t
@@ -0,0 +1,50 @@
+# -*- perl -*-
+use lib qw(t lib);
+use strict;
+use Test;
+use Config::AST;
+use Data::Dumper;
+
+plan tests => 7;
+
+my $ast = new Config::AST(lexicon => {
+ a => 1,
+ b => { mandatory => 1 },
+ c => {
+ section => {
+ d => { array => 1 },
+ e => 1,
+ f => {
+ section => {
+ g => 1,
+ h => {
+ section => {
+ i => 1,
+ j => 1,
+ k => 1
+ }
+ }
+ }
+ }
+ }
+ },
+ l => {
+ section => {
+ x => { mandatory => 1 },
+ '*' => '*'
+ }
+ }
+});
+
+sub dump_lexicon {
+ my $arg = shift;
+ Data::Dumper->new([$arg])->Terse(1)->Sortkeys(1)->Useqq(1)->Indent(0)->Dump
+}
+
+ok($ast->describe_keyword('a'),1);
+ok(dump_lexicon($ast->describe_keyword('b')),q({"mandatory" => 1}));
+ok($ast->describe_keyword(qw(c f g)),1);
+ok(!$ast->describe_keyword(qw(c f g i)));
+ok($ast->describe_keyword(qw(c f h i)));
+ok(!$ast->describe_keyword(qw(c f h i x)));
+ok($ast->describe_keyword(qw(l y z)),'*');

Return to:

Send suggestions and report system problems to the System administrator.