]> git.donarmstrong.com Git - liborg-parser-perl.git/blob - t/base_element-get_property.t
Import original source of Org-Parser 0.23
[liborg-parser-perl.git] / t / base_element-get_property.t
1 #!perl
2
3 use 5.010;
4 use strict;
5 use warnings;
6
7 use FindBin '$Bin';
8 use lib $Bin, "$Bin/t";
9
10 use Org::Parser;
11 use Test::More 0.96;
12 require "testlib.pl";
13
14 test_parse(
15     name => 'get_property()',
16     doc  => <<'_',
17 #+PROPERTY: x 1
18 #+PROPERTY: y 1
19 * head1
20   some text
21   :PROPERTIES:
22     :x: 2
23   :END:
24 _
25     test_after_parse => sub {
26         my (%args) = @_;
27         my $doc = $args{result};
28
29         my $text = $doc->children->[2]->children->[0];
30         is(ref($text), "Org::Element::Text", "got text");
31         is($text->as_string, "  some text\n", "got correct text");
32         is($text->get_property('x'), 2,
33            "text->get_property(x)");
34         is($text->get_property('y'), 1,
35            "text->get_property(y)");
36         ok(!$text->get_property('z'),
37            "text->get_property(z)");
38
39         # TODO: search_parent=1
40     },
41 );
42
43 done_testing();