File: 01_memory.t

package info (click to toggle)
libcommonmark-perl 0.310100-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 220 kB
  • sloc: perl: 291; makefile: 3
file content (38 lines) | stat: -rw-r--r-- 808 bytes parent folder | download
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
use strict;
use warnings;

use Test::More tests => 5;

BEGIN {
    use_ok('CommonMark');
}

diag sprintf "cmark compile time version: %s\ncmark runtime version: %s",
    CommonMark->compile_time_version_string,
    CommonMark->version_string;

my $md = <<EOF;
# Header

Paragraph *emph*, **strong**

* Item 1
* Item 2
EOF

my $doc = CommonMark->parse_document($md);
isa_ok($doc, 'CommonMark::Node', 'parse_document');

my $header = $doc->first_child;
isa_ok($header, 'CommonMark::Node', 'first_child');
is($doc->first_child, $header, 'first_child returns same node');

my $text = $header->first_child;
$doc    = undef;
$header = undef;
# Cause some allocations.
CommonMark->parse_document($md)
    for 1..5;
my $literal = $text->get_literal;
is($literal, 'Header', 'doc still exists with no refs to root');