File: reparse.t

package info (click to toggle)
libtoml-perl 0.97-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 112 kB
  • sloc: perl: 132; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 2,042 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

# This duplicates the first test, using the original, example TOML,
# the turns that parsed structure into toml and reparses it, thus
# ensuring a round-trip.

use strict;
use Test::More tests => 2;

use_ok("TOML");

# Structure from mojombo/toml
my $data = {
          'database' => {
                        'ports' => [
                                   '8001',
                                   '8001',
                                   '8002'
                                 ],
                        'connection_max' => '5000',
                        'server' => '192.168.1.1',
                        'enabled' => 'true'
                      },
          'owner' => {
                     'dob' => '1979-05-27T07:32:00Z',
                     'name' => 'Tom Preston-Werner',
                     'bio' => 'GitHub Cofounder & CEO
Likes tater tots and beer.',
                     'organization' => 'GitHub'
                   },
          'clients' => {
                       'data' => [
                                 [
                                   'gamma',
                                   'delta'
                                 ],
                                 [
                                   '1',
                                   '2'
                                 ]
                               ]
                     },
          'servers' => {
                       'alpha' => {
                                  'dc' => 'eqdc10',
                                  'ip' => '10.0.0.1'
                                },
                       'beta' => {
                                 'dc' => 'eqdc10',
                                 'ip' => '10.0.0.2'
                               }
                     },
          'title' => 'TOML Example'
        };



# Check that parsing the newly generated toml produces the same data structure
my $new_data = from_toml(to_toml($data));
is_deeply($data, $new_data, "Parsing newly generated structure results in same structure");