File: test_perl_parser.pl

package info (click to toggle)
vnlog 1.40-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 952 kB
  • sloc: perl: 4,496; ansic: 727; python: 462; sh: 116; makefile: 7
file content (79 lines) | stat: -rwxr-xr-x 1,025 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env perl
use strict;
use warnings;

use feature ':5.10';

use FindBin '$RealBin';
use lib "$RealBin/../lib";


use Vnlog::Parser;

my $parser = Vnlog::Parser->new();
my $resultstring = '';
while (<DATA>)
{
    if( !$parser->parse($_) )
    {
        die "Error parsing vnlog line '$_': " . $parser->error();
    }

    my $d = $parser->getValuesHash();
    next unless %$d;

    use Data::Dumper;
    $resultstring .= Dumper [$d->{time},$d->{height}];
}

my $ref = <<'EOF';
$VAR1 = [
          '1',
          '2'
        ];
$VAR1 = [
          '3',
          '4'
        ];
$VAR1 = [
          undef,
          '5'
        ];
$VAR1 = [
          '6',
          undef
        ];
$VAR1 = [
          undef,
          undef
        ];
$VAR1 = [
          '7',
          '8'
        ];
EOF

if( $resultstring eq $ref)
{
    say "Test passed";
    exit 0;
}

say "Expected '$ref' but got '$resultstring'";
say "Test failed!";
exit 1;


__DATA__
#! zxcv
 # 
#time height
  ## qewr
	# asdf
1 2
3 4
# - 10
- 5
6 -
- -
7 8