Initial commit
[data-dump-sexp.git] / t / Data-Dump-Sexp.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Test::More tests => 10;
6 BEGIN { use_ok('Data::Dump::Sexp') };
7
8 use Data::SExpression;
9
10 is dump_sexp(5), 5;
11 is dump_sexp('yes'), '"yes"';
12 is dump_sexp('"ha\\ha\\ha"'), '"\\"ha\\\\ha\\\\ha\\""';
13 is dump_sexp([1, "yes", 2]), '(1 "yes" 2)';
14 is dump_sexp({b => 5, a => "yes"}), '(("a" . "yes") ("b" . 5))';
15
16 sub roundtrip_test {
17 my ($sexp) = @_;
18 my $ds = Data::SExpression->new({use_symbol_class => 1, fold_lists => 0});
19 my $parsed = $ds->read($sexp);
20 is dump_sexp($parsed), $sexp
21 }
22
23 roundtrip_test 'symbol';
24 roundtrip_test '(HA-HA 111 "text")';
25 roundtrip_test '(cons . cell)';
26 roundtrip_test '(1 2 3 . 4)';
This page took 0.025118 seconds and 4 git commands to generate.