From: Jeff Ober Date: Fri, 17 Jan 2020 14:36:44 +0000 (-0500) Subject: Add script to build perl tests from BurntSush/toml-test, fix bug found by said tests... X-Git-Tag: nailing-cargo/1.0.0~234^2~34 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=45c29e603aa95a88adc34d6af8e48cba807aab44;p=nailing-cargo.git Add script to build perl tests from BurntSush/toml-test, fix bug found by said tests in writer when encountering empty nested inline table --- diff --git a/build-tests.pl b/build-tests.pl new file mode 100644 index 0000000..897ff59 --- /dev/null +++ b/build-tests.pl @@ -0,0 +1,263 @@ +#------------------------------------------------------------------------------- +# Generates perl unit tests from the toml/json files in BurntSush/toml-test +# without having to add special casing to TOML::Tiny to conform to their +# annotated JSON format. +#------------------------------------------------------------------------------- +use strict; +use warnings; +no warnings 'experimental'; +use v5.18; + +use Data::Dumper; +use JSON::PP; + +# We want to read unicde as characters from toml-test source files. That makes +# things simpler for us when we parse them and generate perl source in the +# generated test file. +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +sub slurp{ + open my $fh, '<', $_[0] or die $!; + local $/; + <$fh>; +} + +# Removes type annotations from BurntSushi/toml-test JSON files and returns the +# cleaned up data structure to which the associated TOML file should be parsed. +sub deturd_json{ + state $json = JSON::PP->new->utf8(1); + my $annotated = $json->decode(slurp(shift)); + my $cleanish = deannotate($annotated); + + local $Data::Dumper::Varname = 'expected'; + local $Data::Dumper::Deparse = 1; + return Dumper($cleanish); +} + +# Recursively deannotates and inflates values from toml-test JSON data +# structures into a format more in line with TOML::Tiny's parser outout. For +# integer and float values, a Test2::Tools::Compare validator is generated to +# compare using Math::Big(Int|Float)->beq, since TOML's float and int types are +# 64 bits. Datetimes are converted to a common, normalized string format. +sub deannotate{ + my $data = shift; + + for (ref $data) { + when ('HASH') { + if (exists $data->{type} && exists $data->{value} && keys(%$data) == 2) { + for ($data->{type}) { + return $data->{value} eq 'true' ? 1 : 0 when /bool/; + return [ map{ deannotate($_) } @{$data->{value}} ] when /array/; + + when (/datetime/) { + my $src = qq{ + use Test2::Tools::Compare qw(validator); + validator(sub{ + use DateTime; + use DateTime::Format::RFC3339; + my \$exp = DateTime::Format::RFC3339->parse_datetime("$data->{value}"); + my \$got = DateTime::Format::RFC3339->parse_datetime(\$_); + \$exp->set_time_zone('UTC'); + \$got->set_time_zone('UTC'); + return DateTime->compare(\$got, \$exp) == 0; + }); + }; + + my $result = eval $src; + $@ && die $@; + + return $result; + } + + when (/integer/) { + my $src = qq{ + use Test2::Tools::Compare qw(validator); + validator(sub{ + require Math::BigInt; + Math::BigInt->new("$data->{value}")->beq(\$_); + }); + }; + + my $result = eval $src; + $@ && die $@; + + return $result; + } + + when (/float/) { + my $src = qq{ + use Test2::Tools::Compare qw(validator); + validator(sub{ + require Math::BigFloat; + Math::BigFloat->new("$data->{value}")->beq(\$_); + }); + }; + + my $result = eval $src; + $@ && die $@; + + return $result; + } + + default{ return $data->{value} } + } + } + + my %object; + $object{$_} = deannotate($data->{$_}) for keys %$data; + return \%object; + } + + when ('ARRAY') { + return [ map{ deannotate($_) } @$data ]; + } + + default{ + return $data; + } + } +} + +sub build_pospath_test_files{ + my $src = shift; + my $dest = shift; + + $src = "$src/tests/valid"; + $dest = "$dest/t/toml-test/valid"; + + print "Generating positive path tests from $src\n"; + + unless (-d $dest) { + system('mkdir', '-p', $dest) == 0 || die $?; + } + + my %TOML; + my %JSON; + + opendir my $dh, $src or die $!; + + while (my $file = readdir $dh) { + my $path = "$src/$file"; + my ($test, $ext) = $file =~ /^(.*)\.([^\.]+)$/; + + for ($ext) { + next unless defined; + $TOML{$test} = $path when /toml/; + $JSON{$test} = $path when /json/; + } + } + + closedir $dh; + + for (sort keys %TOML) { + my $data = deturd_json($JSON{$_}); + + my $toml = slurp($TOML{$_}); + $toml =~ s/\\/\\\\/g; + + open my $fh, '>', "$dest/$_.t" or die $!; + + print $fh qq{# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $data + +my \$actual = from_toml(q{$toml}); + +is(\$actual, \$expected1, '$_ - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper(\$expected1); + + diag 'ACTUAL:'; + diag Dumper(\$actual); +}; + +is(eval{ from_toml(to_toml(\$actual)) }, \$actual, '$_ - to_toml') or do{ + diag 'INPUT:'; + diag Dumper(\$actual); + + diag 'TOML OUTPUT:'; + diag to_toml(\$actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml(\$actual))); +}; + +done_testing;}; + + close $fh; + } +} + +sub build_negpath_test_files{ + my $src = shift; + my $dest = shift; + + $src = "$src/tests/invalid"; + $dest = "$dest/t/toml-test/invalid"; + + print "Generating negative path tests from $src\n"; + + unless (-d $dest) { + system('mkdir', '-p', $dest) == 0 || die $?; + } + + my %TOML; + + opendir my $dh, $src or die $!; + + while (my $file = readdir $dh) { + my $path = "$src/$file"; + my ($test, $ext) = $file =~ /^(.*)\.([^\.]+)$/; + + if ($ext && $ext eq 'toml') { + $TOML{$test} = $path; + } + } + + closedir $dh; + + for (sort keys %TOML) { + my $toml = slurp($TOML{$_}); + $toml =~ s/\\/\\\\/g; + + open my $fh, '>', "$dest/$_.t" or die $!; + + print $fh qq{# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +$toml + }, strict_arrays => 1); +}), 'strict_mode dies on $_'; + +done_testing;}; + + close $fh; + } +} + +my $usage = "usage: build-tests \$toml-test-repo-path \$toml-tiny-repo-path\n"; +my $toml_test_path = shift @ARGV || die $usage; +my $toml_tiny_path = shift @ARGV || die $usage; + +-d $toml_test_path || die "invalid path to BurntSush/toml-test: $toml_test_path\n"; +-d "$toml_test_path/tests" || die "invalid path to BurntSush/toml-test: $toml_test_path\n"; +-d $toml_tiny_path || die "invalid path to TOML::Tiny repo: $toml_tiny_path\n"; +-d "$toml_tiny_path/t" || die "invalid path to TOML::Tiny repo: $toml_tiny_path\n"; + +build_pospath_test_files($toml_test_path, $toml_tiny_path); +build_negpath_test_files($toml_test_path, $toml_tiny_path); diff --git a/lib/TOML/Tiny/Writer.pm b/lib/TOML/Tiny/Writer.pm index e127a0e..f5a206c 100644 --- a/lib/TOML/Tiny/Writer.pm +++ b/lib/TOML/Tiny/Writer.pm @@ -26,53 +26,57 @@ sub to_toml { for (ref $data) { when ('HASH') { - for my $k (grep{ ref($data->{$_}) !~ /HASH|ARRAY/ } sort keys %$data) { - my $key = to_toml_key($k); - my $val = to_toml($data->{$k}, %param); - push @buff, "$key=$val"; - } + if (!keys(%$data)) { + push @buff, '{}'; + } else { + for my $k (grep{ ref($data->{$_}) !~ /HASH|ARRAY/ } sort keys %$data) { + my $key = to_toml_key($k); + my $val = to_toml($data->{$k}, %param); + push @buff, "$key=$val"; + } - for my $k (grep{ ref $data->{$_} eq 'ARRAY' } sort keys %$data) { - my @inline; - my @table_array; + for my $k (grep{ ref $data->{$_} eq 'ARRAY' } sort keys %$data) { + my @inline; + my @table_array; - for my $v (@{$data->{$k}}) { - if (ref $v eq 'HASH') { - push @table_array, $v; - } else { - push @inline, $v; + for my $v (@{$data->{$k}}) { + if (ref $v eq 'HASH') { + push @table_array, $v; + } else { + push @inline, $v; + } } - } - if (@inline) { - my $key = to_toml_key($k); - my $val = to_toml(\@inline, %param); - push @buff, "$key=$val"; - } + if (@inline) { + my $key = to_toml_key($k); + my $val = to_toml(\@inline, %param); + push @buff, "$key=$val"; + } - if (@table_array) { - push @KEYS, $k; + if (@table_array) { + push @KEYS, $k; - for (@table_array) { - push @buff, '', '[[' . join('.', map{ to_toml_key($_) } @KEYS) . ']]'; + for (@table_array) { + push @buff, '', '[[' . join('.', map{ to_toml_key($_) } @KEYS) . ']]'; - for my $k (sort keys %$_) { - my $key = to_toml_key($k); - my $val = to_toml($_->{$k}, %param); - push @buff, "$key=$val"; + for my $k (sort keys %$_) { + my $key = to_toml_key($k); + my $val = to_toml($_->{$k}, %param); + push @buff, "$key=$val"; + } } + + pop @KEYS; } + } + for my $k (grep{ ref $data->{$_} eq 'HASH' } sort keys %$data) { + push @KEYS, $k; + push @buff, '', '[' . join('.', map{ to_toml_key($_) } @KEYS) . ']'; + push @buff, to_toml($data->{$k}, %param); pop @KEYS; } } - - for my $k (grep{ ref $data->{$_} eq 'HASH' } sort keys %$data) { - push @KEYS, $k; - push @buff, '', '[' . join('.', map{ to_toml_key($_) } @KEYS) . ']'; - push @buff, to_toml($data->{$k}, %param); - pop @KEYS; - } } when ('ARRAY') { diff --git a/t/parsing/array.t b/t/parsing/array.t deleted file mode 100644 index 7b3664d..0000000 --- a/t/parsing/array.t +++ /dev/null @@ -1,34 +0,0 @@ -use Test2::V0; -use TOML::Tiny; - -is from_toml('thevoid=[[[]]]'), {thevoid => [[[]]]}, 'empty'; - -is from_toml('ints=[1,2,3]'), {ints => [1, 2, 3]}, 'no spaces'; - -is from_toml('ints=[1, 2, 3] # comment'), {ints => [1, 2, 3]}, 'comments after array'; - -is from_toml(q{ - -ints=[ - 1, # comments - 2, 3 -] - -}), {ints => [1, 2, 3]}, 'multi-line, w/ comments'; - -is from_toml('ints=[1, 2, 3, ]'), {ints => [1, 2, 3]}, 'trailing comma'; - -is from_toml('nested=[["a"], ["b", ["c"]]]'), {nested => [['a'], ['b', ['c']]]}, 'nested'; - -is from_toml(q{ -title = [ - "Client: \"XXXX\", Job: XXXX", - "Code: XXXX" -] -}), {title => ['Client: "XXXX", Job: XXXX', 'Code: XXXX']}, 'with string containing comma';; - -is from_toml(q{title = [ " \", ",]}), {title => [' ", ']}, 'with string containing escaped quote, then comma'; - -is from_toml(q|foo = [ { bar="\"{{baz}}\""} ]|), {foo => [{bar => '"{{baz}}"'}]}, 'escaped quotes in string in table array table'; - -done_testing; diff --git a/t/parsing/bool.t b/t/parsing/bool.t deleted file mode 100644 index ddf0687..0000000 --- a/t/parsing/bool.t +++ /dev/null @@ -1,9 +0,0 @@ -use Test2::V0; -use TOML::Tiny; - -is from_toml('x=true'), {x => $TOML::Tiny::Parser::TRUE}, 'true'; -is from_toml('x=false'), {x => $TOML::Tiny::Parser::FALSE}, 'false'; -is from_toml('x=true', inflate_boolean => sub{ $_[0] eq 'true' ? 'T' : 'F' }), {x => 'T'}, 'inflate_boolean(true)'; -is from_toml('x=false', inflate_boolean => sub{ $_[0] eq 'true' ? 'T' : 'F' }), {x => 'F'}, 'inflate_boolean(false)'; - -done_testing; diff --git a/t/parsing/comments.t b/t/parsing/comments.t deleted file mode 100644 index c58fe54..0000000 --- a/t/parsing/comments.t +++ /dev/null @@ -1,47 +0,0 @@ -use Test2::V0; -use TOML::Tiny; - -is from_toml(q{ -# Top comment. - # Top comment. -# Top comment. - -# [no-extraneous-groups-please] - -[group] # Comment -answer = 42 # Comment -# no-extraneous-keys-please = 999 -# Inbetween comment. -more = [ # Comment - # What about multiple # comments? - # Can you handle it? - # - # Evil. -# Evil. - 42, 42, # Comments within arrays are fun. - # What about multiple # comments? - # Can you handle it? - # - # Evil. -# Evil. -# ] Did I fool you? -] # Hopefully not. -}), { - group => { - answer => 42, - more => [42, 42], - } -}, 'comments everywhere'; - -is from_toml(q{ -# full line comment -foo='bar' #comment -}), - {foo => 'bar'}, 'comment with eol at eof'; - -is from_toml(q{ -# full line comment -foo='bar' #comment}), - {foo => 'bar'}, 'comment at eof'; - -done_testing; diff --git a/t/parsing/datetime.t b/t/parsing/datetime.t deleted file mode 100644 index 8975d26..0000000 --- a/t/parsing/datetime.t +++ /dev/null @@ -1,18 +0,0 @@ -use Test2::V0; -use TOML::Tiny; -use DateTime::Format::RFC3339; - -my %args = ( - inflate_datetime => sub{ - my $str = shift; - my $dt = DateTime::Format::RFC3339->parse_datetime($str); - $dt->set_time_zone('UTC'); - ''.$dt; - }, -); - -is from_toml(q{x=1987-07-05T17:45:00Z}, %args), {x => '1987-07-05T17:45:00Z'}, 'utc'; -is from_toml(q{x=1977-06-28T07:32:00-05:00}, %args), {x => '1977-06-28T12:32:00Z'}, 'offset'; -is from_toml(q{x=1977-12-21T10:32:00.555+07:00}, %args), {x => '1977-12-21T03:32:00.555000000Z'}, 'milliseconds'; - -done_testing; diff --git a/t/parsing/misc.t b/t/parsing/misc.t deleted file mode 100644 index f70ad6d..0000000 --- a/t/parsing/misc.t +++ /dev/null @@ -1,6 +0,0 @@ -use Test2::V0; -use TOML::Tiny; - -is from_toml(''), {}, 'empty string'; - -done_testing; diff --git a/t/parsing/strings.t b/t/parsing/strings.t deleted file mode 100644 index 58d2e51..0000000 --- a/t/parsing/strings.t +++ /dev/null @@ -1,31 +0,0 @@ -use Test2::V0; -use TOML::Tiny; - -is from_toml(q{x="how now brown bureaucrat"}), {x => "how now brown bureaucrat"}, 'basic string'; -is from_toml(q{x=""}), {x => ''}, 'empty string'; -is from_toml(q{x="\\\\n"}), {x => q{\n}}, 'escaped escape'; - -is from_toml(q{backspace = "This string has a \b backspace character."}), {backspace => "This string has a \b backspace character."}, 'backspace'; -is from_toml(q{tab = "This string has a \t tab character."}), {tab => "This string has a \t tab character."}, 'tab'; -is from_toml(q{newline = "This string has a \n new line character."}), {newline => "This string has a \n new line character."}, 'newline'; -is from_toml(q{formfeed = "This string has a \f form feed character."}), {formfeed => "This string has a \f form feed character."}, 'formfeed'; -is from_toml(q{carriage = "This string has a \r carriage return character."}), {carriage => "This string has a \r carriage return character."}, 'carriage'; -is from_toml(q{quote = "This string has a \" quote character."}), {quote => "This string has a \" quote character."}, 'quote'; -is from_toml(q{backslash = "This string has a \\\\ backslash character."}), {backslash => "This string has a \\ backslash character."}, 'backslash'; - -is from_toml(q{notunicode1 = "This string does not have a unicode \\\\u escape."}), {notunicode1 => "This string does not have a unicode \\u escape."}, 'not unicode 1'; -is from_toml(q{notunicode2 = "This string does not have a unicode \u005Cu escape."}), {notunicode2 => "This string does not have a unicode \\u escape."}, 'not unicode 2'; -is from_toml(q{notunicode3 = "This string does not have a unicode \\\\u0075 escape."}), {notunicode3 => "This string does not have a unicode \\u0075 escape."}, 'not unicode 3'; -is from_toml(q{notunicode4 = "This string does not have a unicode \\\u0075 escape."}), {notunicode4 => "This string does not have a unicode \\u0075 escape."}, 'not unicode 4'; - -is from_toml(q{nl_mid = "val\nue"}), {nl_mid => "val\nue"}, 'newline in middle of string'; -is from_toml(q{nl_end = """value\n"""}), {nl_end => "value\n"}, 'newline at end of string'; - -is from_toml(q{lit_nl_end = '''value\n'''}), {lit_nl_end => 'value\n'}, 'literal with \n at end'; -is from_toml(q{lit_nl_mid = 'val\nue'}), {lit_nl_mid => 'val\nue'}, 'literal with \n in middle'; -is from_toml(q{lit_nl_uni = 'val\ue'}), {lit_nl_uni => 'val\ue'}, 'literal with \u in middle'; - -is from_toml(q{x="hash in # string"}), {x => 'hash in # string'}, 'hash inside string is not recognized as comment'; -is from_toml(q{x="hash in # string" # comment after}), {x => 'hash in # string'}, 'hash in string with comment after string parsed correctly'; - -done_testing; diff --git a/t/toml-test/invalid/array-mixed-types-arrays-and-ints.t b/t/toml-test/invalid/array-mixed-types-arrays-and-ints.t new file mode 100644 index 0000000..fd08858 --- /dev/null +++ b/t/toml-test/invalid/array-mixed-types-arrays-and-ints.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +arrays-and-ints = [1, ["Arrays are not integers."]] + + }, strict_arrays => 1); +}), 'strict_mode dies on array-mixed-types-arrays-and-ints'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/array-mixed-types-ints-and-floats.t b/t/toml-test/invalid/array-mixed-types-ints-and-floats.t new file mode 100644 index 0000000..2e50347 --- /dev/null +++ b/t/toml-test/invalid/array-mixed-types-ints-and-floats.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +ints-and-floats = [1, 1.1] + + }, strict_arrays => 1); +}), 'strict_mode dies on array-mixed-types-ints-and-floats'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/array-mixed-types-strings-and-ints.t b/t/toml-test/invalid/array-mixed-types-strings-and-ints.t new file mode 100644 index 0000000..2dff8a6 --- /dev/null +++ b/t/toml-test/invalid/array-mixed-types-strings-and-ints.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +strings-and-ints = ["hi", 42] + + }, strict_arrays => 1); +}), 'strict_mode dies on array-mixed-types-strings-and-ints'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/datetime-malformed-no-leads.t b/t/toml-test/invalid/datetime-malformed-no-leads.t new file mode 100644 index 0000000..7304b65 --- /dev/null +++ b/t/toml-test/invalid/datetime-malformed-no-leads.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +no-leads = 1987-7-05T17:45:00Z + + }, strict_arrays => 1); +}), 'strict_mode dies on datetime-malformed-no-leads'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/datetime-malformed-no-secs.t b/t/toml-test/invalid/datetime-malformed-no-secs.t new file mode 100644 index 0000000..ce8e400 --- /dev/null +++ b/t/toml-test/invalid/datetime-malformed-no-secs.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +no-secs = 1987-07-05T17:45Z + + }, strict_arrays => 1); +}), 'strict_mode dies on datetime-malformed-no-secs'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/datetime-malformed-no-t.t b/t/toml-test/invalid/datetime-malformed-no-t.t new file mode 100644 index 0000000..20785ca --- /dev/null +++ b/t/toml-test/invalid/datetime-malformed-no-t.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +no-t = 1987-07-0517:45:00Z + + }, strict_arrays => 1); +}), 'strict_mode dies on datetime-malformed-no-t'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/datetime-malformed-with-milli.t b/t/toml-test/invalid/datetime-malformed-with-milli.t new file mode 100644 index 0000000..37059e8 --- /dev/null +++ b/t/toml-test/invalid/datetime-malformed-with-milli.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +with-milli = 1987-07-5T17:45:00.12Z + + }, strict_arrays => 1); +}), 'strict_mode dies on datetime-malformed-with-milli'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/duplicate-key-table.t b/t/toml-test/invalid/duplicate-key-table.t new file mode 100644 index 0000000..03058a0 --- /dev/null +++ b/t/toml-test/invalid/duplicate-key-table.t @@ -0,0 +1,20 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[fruit] +type = "apple" + +[fruit.type] +apple = "yes" + + }, strict_arrays => 1); +}), 'strict_mode dies on duplicate-key-table'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/duplicate-keys.t b/t/toml-test/invalid/duplicate-keys.t new file mode 100644 index 0000000..16b554c --- /dev/null +++ b/t/toml-test/invalid/duplicate-keys.t @@ -0,0 +1,17 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +dupe = false +dupe = true + + }, strict_arrays => 1); +}), 'strict_mode dies on duplicate-keys'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/duplicate-tables.t b/t/toml-test/invalid/duplicate-tables.t new file mode 100644 index 0000000..0a163a3 --- /dev/null +++ b/t/toml-test/invalid/duplicate-tables.t @@ -0,0 +1,17 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[a] +[a] + + }, strict_arrays => 1); +}), 'strict_mode dies on duplicate-tables'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/empty-implicit-table.t b/t/toml-test/invalid/empty-implicit-table.t new file mode 100644 index 0000000..9cb730b --- /dev/null +++ b/t/toml-test/invalid/empty-implicit-table.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[naughty..naughty] + + }, strict_arrays => 1); +}), 'strict_mode dies on empty-implicit-table'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/empty-table.t b/t/toml-test/invalid/empty-table.t new file mode 100644 index 0000000..c1066ae --- /dev/null +++ b/t/toml-test/invalid/empty-table.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[] + + }, strict_arrays => 1); +}), 'strict_mode dies on empty-table'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/float-leading-zero-neg.t b/t/toml-test/invalid/float-leading-zero-neg.t new file mode 100644 index 0000000..53711e4 --- /dev/null +++ b/t/toml-test/invalid/float-leading-zero-neg.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +leading-zero = -03.14 + + }, strict_arrays => 1); +}), 'strict_mode dies on float-leading-zero-neg'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/float-leading-zero-pos.t b/t/toml-test/invalid/float-leading-zero-pos.t new file mode 100644 index 0000000..2f0fa1e --- /dev/null +++ b/t/toml-test/invalid/float-leading-zero-pos.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +leading-zero = +03.14 + + }, strict_arrays => 1); +}), 'strict_mode dies on float-leading-zero-pos'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/float-leading-zero.t b/t/toml-test/invalid/float-leading-zero.t new file mode 100644 index 0000000..252054a --- /dev/null +++ b/t/toml-test/invalid/float-leading-zero.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +leading-zero = 03.14 + + }, strict_arrays => 1); +}), 'strict_mode dies on float-leading-zero'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/float-no-leading-zero.t b/t/toml-test/invalid/float-no-leading-zero.t new file mode 100644 index 0000000..de56e6f --- /dev/null +++ b/t/toml-test/invalid/float-no-leading-zero.t @@ -0,0 +1,17 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +answer = .12345 +neganswer = -.12345 + + }, strict_arrays => 1); +}), 'strict_mode dies on float-no-leading-zero'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/float-no-trailing-digits.t b/t/toml-test/invalid/float-no-trailing-digits.t new file mode 100644 index 0000000..1af0bba --- /dev/null +++ b/t/toml-test/invalid/float-no-trailing-digits.t @@ -0,0 +1,17 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +answer = 1. +neganswer = -1. + + }, strict_arrays => 1); +}), 'strict_mode dies on float-no-trailing-digits'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/float-underscore-after-point.t b/t/toml-test/invalid/float-underscore-after-point.t new file mode 100644 index 0000000..b760b6f --- /dev/null +++ b/t/toml-test/invalid/float-underscore-after-point.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +bad = 1._2 + + }, strict_arrays => 1); +}), 'strict_mode dies on float-underscore-after-point'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/float-underscore-after.t b/t/toml-test/invalid/float-underscore-after.t new file mode 100644 index 0000000..d90fc08 --- /dev/null +++ b/t/toml-test/invalid/float-underscore-after.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +bad = 1.2_ + + }, strict_arrays => 1); +}), 'strict_mode dies on float-underscore-after'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/float-underscore-before-point.t b/t/toml-test/invalid/float-underscore-before-point.t new file mode 100644 index 0000000..21f0313 --- /dev/null +++ b/t/toml-test/invalid/float-underscore-before-point.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +bad = 1_.2 + + }, strict_arrays => 1); +}), 'strict_mode dies on float-underscore-before-point'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/float-underscore-before.t b/t/toml-test/invalid/float-underscore-before.t new file mode 100644 index 0000000..ecc9339 --- /dev/null +++ b/t/toml-test/invalid/float-underscore-before.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +bad = _1.2 + + }, strict_arrays => 1); +}), 'strict_mode dies on float-underscore-before'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/inline-table-linebreak.t b/t/toml-test/invalid/inline-table-linebreak.t new file mode 100644 index 0000000..37b4018 --- /dev/null +++ b/t/toml-test/invalid/inline-table-linebreak.t @@ -0,0 +1,17 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +simple = { a = 1 +} + + }, strict_arrays => 1); +}), 'strict_mode dies on inline-table-linebreak'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/integer-leading-zero-neg.t b/t/toml-test/invalid/integer-leading-zero-neg.t new file mode 100644 index 0000000..5caeb8b --- /dev/null +++ b/t/toml-test/invalid/integer-leading-zero-neg.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +leading-zero = -012 + + }, strict_arrays => 1); +}), 'strict_mode dies on integer-leading-zero-neg'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/integer-leading-zero-pos.t b/t/toml-test/invalid/integer-leading-zero-pos.t new file mode 100644 index 0000000..f0823d9 --- /dev/null +++ b/t/toml-test/invalid/integer-leading-zero-pos.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +leading-zero = +012 + + }, strict_arrays => 1); +}), 'strict_mode dies on integer-leading-zero-pos'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/integer-leading-zero.t b/t/toml-test/invalid/integer-leading-zero.t new file mode 100644 index 0000000..77103b3 --- /dev/null +++ b/t/toml-test/invalid/integer-leading-zero.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +leading-zero = 012 + + }, strict_arrays => 1); +}), 'strict_mode dies on integer-leading-zero'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/integer-underscore-after.t b/t/toml-test/invalid/integer-underscore-after.t new file mode 100644 index 0000000..4a0e261 --- /dev/null +++ b/t/toml-test/invalid/integer-underscore-after.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +bad = 123_ + + }, strict_arrays => 1); +}), 'strict_mode dies on integer-underscore-after'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/integer-underscore-before.t b/t/toml-test/invalid/integer-underscore-before.t new file mode 100644 index 0000000..204b0e8 --- /dev/null +++ b/t/toml-test/invalid/integer-underscore-before.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +bad = _123 + + }, strict_arrays => 1); +}), 'strict_mode dies on integer-underscore-before'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/integer-underscore-double.t b/t/toml-test/invalid/integer-underscore-double.t new file mode 100644 index 0000000..acbb911 --- /dev/null +++ b/t/toml-test/invalid/integer-underscore-double.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +bad = 1__23 + + }, strict_arrays => 1); +}), 'strict_mode dies on integer-underscore-double'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-after-array.t b/t/toml-test/invalid/key-after-array.t new file mode 100644 index 0000000..8d6a75a --- /dev/null +++ b/t/toml-test/invalid/key-after-array.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[[agencies]] owner = "S Cjelli" + + }, strict_arrays => 1); +}), 'strict_mode dies on key-after-array'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-after-table.t b/t/toml-test/invalid/key-after-table.t new file mode 100644 index 0000000..1e5460b --- /dev/null +++ b/t/toml-test/invalid/key-after-table.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[error] this = "should not be here" + + }, strict_arrays => 1); +}), 'strict_mode dies on key-after-table'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-empty.t b/t/toml-test/invalid/key-empty.t new file mode 100644 index 0000000..1765ef6 --- /dev/null +++ b/t/toml-test/invalid/key-empty.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ + = 1 + + }, strict_arrays => 1); +}), 'strict_mode dies on key-empty'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-hash.t b/t/toml-test/invalid/key-hash.t new file mode 100644 index 0000000..058d535 --- /dev/null +++ b/t/toml-test/invalid/key-hash.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +a# = 1 + + }, strict_arrays => 1); +}), 'strict_mode dies on key-hash'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-newline.t b/t/toml-test/invalid/key-newline.t new file mode 100644 index 0000000..7c71c6b --- /dev/null +++ b/t/toml-test/invalid/key-newline.t @@ -0,0 +1,17 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +a += 1 + + }, strict_arrays => 1); +}), 'strict_mode dies on key-newline'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-no-eol.t b/t/toml-test/invalid/key-no-eol.t new file mode 100644 index 0000000..66b180b --- /dev/null +++ b/t/toml-test/invalid/key-no-eol.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +a = 1 b = 2 + + }, strict_arrays => 1); +}), 'strict_mode dies on key-no-eol'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-open-bracket.t b/t/toml-test/invalid/key-open-bracket.t new file mode 100644 index 0000000..b197e67 --- /dev/null +++ b/t/toml-test/invalid/key-open-bracket.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[abc = 1 + + }, strict_arrays => 1); +}), 'strict_mode dies on key-open-bracket'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-single-open-bracket.t b/t/toml-test/invalid/key-single-open-bracket.t new file mode 100644 index 0000000..d78f661 --- /dev/null +++ b/t/toml-test/invalid/key-single-open-bracket.t @@ -0,0 +1,15 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[ + }, strict_arrays => 1); +}), 'strict_mode dies on key-single-open-bracket'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-space.t b/t/toml-test/invalid/key-space.t new file mode 100644 index 0000000..25ee4a7 --- /dev/null +++ b/t/toml-test/invalid/key-space.t @@ -0,0 +1,15 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +a b = 1 + }, strict_arrays => 1); +}), 'strict_mode dies on key-space'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-start-bracket.t b/t/toml-test/invalid/key-start-bracket.t new file mode 100644 index 0000000..3e6733b --- /dev/null +++ b/t/toml-test/invalid/key-start-bracket.t @@ -0,0 +1,18 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[a] +[xyz = 5 +[b] + + }, strict_arrays => 1); +}), 'strict_mode dies on key-start-bracket'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/key-two-equals.t b/t/toml-test/invalid/key-two-equals.t new file mode 100644 index 0000000..baf4ccf --- /dev/null +++ b/t/toml-test/invalid/key-two-equals.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +key= = 1 + + }, strict_arrays => 1); +}), 'strict_mode dies on key-two-equals'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/llbrace.t b/t/toml-test/invalid/llbrace.t new file mode 100644 index 0000000..ff26ef5 --- /dev/null +++ b/t/toml-test/invalid/llbrace.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[ [table]] + + }, strict_arrays => 1); +}), 'strict_mode dies on llbrace'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/multi-line-inline-table.t b/t/toml-test/invalid/multi-line-inline-table.t new file mode 100644 index 0000000..84c9274 --- /dev/null +++ b/t/toml-test/invalid/multi-line-inline-table.t @@ -0,0 +1,18 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +json_like = { + first = "Tom", + last = "Preston-Werner" +} + }, strict_arrays => 1); +}), 'strict_mode dies on multi-line-inline-table'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/rrbrace.t b/t/toml-test/invalid/rrbrace.t new file mode 100644 index 0000000..ee190e9 --- /dev/null +++ b/t/toml-test/invalid/rrbrace.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[[table] ] + + }, strict_arrays => 1); +}), 'strict_mode dies on rrbrace'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/string-bad-byte-escape.t b/t/toml-test/invalid/string-bad-byte-escape.t new file mode 100644 index 0000000..7496e9d --- /dev/null +++ b/t/toml-test/invalid/string-bad-byte-escape.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +naughty = "\\xAg" + + }, strict_arrays => 1); +}), 'strict_mode dies on string-bad-byte-escape'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/string-bad-codepoint.t b/t/toml-test/invalid/string-bad-codepoint.t new file mode 100644 index 0000000..ae58bd6 --- /dev/null +++ b/t/toml-test/invalid/string-bad-codepoint.t @@ -0,0 +1,15 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +invalid-codepoint = "This string contains a non scalar unicode codepoint \\uD801" + }, strict_arrays => 1); +}), 'strict_mode dies on string-bad-codepoint'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/string-bad-escape.t b/t/toml-test/invalid/string-bad-escape.t new file mode 100644 index 0000000..116ba6d --- /dev/null +++ b/t/toml-test/invalid/string-bad-escape.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +invalid-escape = "This string has a bad \\a escape character." + + }, strict_arrays => 1); +}), 'strict_mode dies on string-bad-escape'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/string-bad-slash-escape.t b/t/toml-test/invalid/string-bad-slash-escape.t new file mode 100644 index 0000000..205c726 --- /dev/null +++ b/t/toml-test/invalid/string-bad-slash-escape.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +invalid-escape = "This string has a bad \\/ escape character." + + }, strict_arrays => 1); +}), 'strict_mode dies on string-bad-slash-escape'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/string-bad-uni-esc.t b/t/toml-test/invalid/string-bad-uni-esc.t new file mode 100644 index 0000000..f56d675 --- /dev/null +++ b/t/toml-test/invalid/string-bad-uni-esc.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +str = "val\\ue" + + }, strict_arrays => 1); +}), 'strict_mode dies on string-bad-uni-esc'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/string-byte-escapes.t b/t/toml-test/invalid/string-byte-escapes.t new file mode 100644 index 0000000..3b4521a --- /dev/null +++ b/t/toml-test/invalid/string-byte-escapes.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +answer = "\\x33" + + }, strict_arrays => 1); +}), 'strict_mode dies on string-byte-escapes'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/string-no-close.t b/t/toml-test/invalid/string-no-close.t new file mode 100644 index 0000000..e5971df --- /dev/null +++ b/t/toml-test/invalid/string-no-close.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +no-ending-quote = "One time, at band camp + + }, strict_arrays => 1); +}), 'strict_mode dies on string-no-close'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/table-array-implicit.t b/t/toml-test/invalid/table-array-implicit.t new file mode 100644 index 0000000..e5fdeae --- /dev/null +++ b/t/toml-test/invalid/table-array-implicit.t @@ -0,0 +1,29 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +# This test is a bit tricky. It should fail because the first use of +# `[[albums.songs]]` without first declaring `albums` implies that `albums` +# must be a table. The alternative would be quite weird. Namely, it wouldn't +# comply with the TOML spec: "Each double-bracketed sub-table will belong to +# the most *recently* defined table element *above* it." +# +# This is in contrast to the *valid* test, table-array-implicit where +# `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared +# later. (Although, `[albums]` could be.) +[[albums.songs]] +name = "Glory Days" + +[[albums]] +name = "Born in the USA" + + }, strict_arrays => 1); +}), 'strict_mode dies on table-array-implicit'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/table-array-malformed-bracket.t b/t/toml-test/invalid/table-array-malformed-bracket.t new file mode 100644 index 0000000..527c646 --- /dev/null +++ b/t/toml-test/invalid/table-array-malformed-bracket.t @@ -0,0 +1,17 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[[albums] +name = "Born to Run" + + }, strict_arrays => 1); +}), 'strict_mode dies on table-array-malformed-bracket'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/table-array-malformed-empty.t b/t/toml-test/invalid/table-array-malformed-empty.t new file mode 100644 index 0000000..96cbe2b --- /dev/null +++ b/t/toml-test/invalid/table-array-malformed-empty.t @@ -0,0 +1,17 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[[]] +name = "Born to Run" + + }, strict_arrays => 1); +}), 'strict_mode dies on table-array-malformed-empty'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/table-empty.t b/t/toml-test/invalid/table-empty.t new file mode 100644 index 0000000..3cdf8f9 --- /dev/null +++ b/t/toml-test/invalid/table-empty.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[] + + }, strict_arrays => 1); +}), 'strict_mode dies on table-empty'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/table-nested-brackets-close.t b/t/toml-test/invalid/table-nested-brackets-close.t new file mode 100644 index 0000000..8381e9f --- /dev/null +++ b/t/toml-test/invalid/table-nested-brackets-close.t @@ -0,0 +1,17 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[a]b] +zyx = 42 + + }, strict_arrays => 1); +}), 'strict_mode dies on table-nested-brackets-close'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/table-nested-brackets-open.t b/t/toml-test/invalid/table-nested-brackets-open.t new file mode 100644 index 0000000..3bdf469 --- /dev/null +++ b/t/toml-test/invalid/table-nested-brackets-open.t @@ -0,0 +1,17 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[a[b] +zyx = 42 + + }, strict_arrays => 1); +}), 'strict_mode dies on table-nested-brackets-open'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/table-whitespace.t b/t/toml-test/invalid/table-whitespace.t new file mode 100644 index 0000000..fd7a6ba --- /dev/null +++ b/t/toml-test/invalid/table-whitespace.t @@ -0,0 +1,15 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[invalid key] + }, strict_arrays => 1); +}), 'strict_mode dies on table-whitespace'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/table-with-pound.t b/t/toml-test/invalid/table-with-pound.t new file mode 100644 index 0000000..167de7e --- /dev/null +++ b/t/toml-test/invalid/table-with-pound.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[key#group] +answer = 42 + }, strict_arrays => 1); +}), 'strict_mode dies on table-with-pound'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/text-after-array-entries.t b/t/toml-test/invalid/text-after-array-entries.t new file mode 100644 index 0000000..271ec01 --- /dev/null +++ b/t/toml-test/invalid/text-after-array-entries.t @@ -0,0 +1,19 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +array = [ + "Is there life after an array separator?", No + "Entry" +] + + }, strict_arrays => 1); +}), 'strict_mode dies on text-after-array-entries'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/text-after-integer.t b/t/toml-test/invalid/text-after-integer.t new file mode 100644 index 0000000..f596899 --- /dev/null +++ b/t/toml-test/invalid/text-after-integer.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +answer = 42 the ultimate answer? + + }, strict_arrays => 1); +}), 'strict_mode dies on text-after-integer'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/text-after-string.t b/t/toml-test/invalid/text-after-string.t new file mode 100644 index 0000000..1cb747d --- /dev/null +++ b/t/toml-test/invalid/text-after-string.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +string = "Is there life after strings?" No. + + }, strict_arrays => 1); +}), 'strict_mode dies on text-after-string'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/text-after-table.t b/t/toml-test/invalid/text-after-table.t new file mode 100644 index 0000000..49f146f --- /dev/null +++ b/t/toml-test/invalid/text-after-table.t @@ -0,0 +1,16 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +[error] this shouldn't be here + + }, strict_arrays => 1); +}), 'strict_mode dies on text-after-table'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/text-before-array-separator.t b/t/toml-test/invalid/text-before-array-separator.t new file mode 100644 index 0000000..9fc4158 --- /dev/null +++ b/t/toml-test/invalid/text-before-array-separator.t @@ -0,0 +1,19 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +array = [ + "Is there life before an array separator?" No, + "Entry" +] + + }, strict_arrays => 1); +}), 'strict_mode dies on text-before-array-separator'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/invalid/text-in-array.t b/t/toml-test/invalid/text-in-array.t new file mode 100644 index 0000000..8cfd759 --- /dev/null +++ b/t/toml-test/invalid/text-in-array.t @@ -0,0 +1,20 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +ok dies(sub{ + from_toml(q{ +array = [ + "Entry 1", + I don't belong, + "Entry 2", +] + + }, strict_arrays => 1); +}), 'strict_mode dies on text-in-array'; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/array-empty.t b/t/toml-test/valid/array-empty.t new file mode 100644 index 0000000..b3b21be --- /dev/null +++ b/t/toml-test/valid/array-empty.t @@ -0,0 +1,45 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'thevoid' => [ + [ + [ + [ + [] + ] + ] + ] + ] + }; + + +my $actual = from_toml(q{thevoid = [[[[[]]]]] +}); + +is($actual, $expected1, 'array-empty - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'array-empty - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/array-nospaces.t b/t/toml-test/valid/array-nospaces.t new file mode 100644 index 0000000..9407043 --- /dev/null +++ b/t/toml-test/valid/array-nospaces.t @@ -0,0 +1,86 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'ints' => [ + bless( { + '_file' => '(eval 47)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ), + bless( { + '_file' => '(eval 112)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('2')->beq($_); + }, + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ), + bless( { + '_file' => '(eval 113)', + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('3')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ) + ] + }; + + +my $actual = from_toml(q{ints = [1,2,3] +}); + +is($actual, $expected1, 'array-nospaces - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'array-nospaces - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/array-string-quote-comma-2.t b/t/toml-test/valid/array-string-quote-comma-2.t new file mode 100644 index 0000000..ca9dc92 --- /dev/null +++ b/t/toml-test/valid/array-string-quote-comma-2.t @@ -0,0 +1,39 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'title' => [ + ' ", ' + ] + }; + + +my $actual = from_toml(q{title = [ " \\", ",] +}); + +is($actual, $expected1, 'array-string-quote-comma-2 - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'array-string-quote-comma-2 - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/array-string-quote-comma.t b/t/toml-test/valid/array-string-quote-comma.t new file mode 100644 index 0000000..b75ca62 --- /dev/null +++ b/t/toml-test/valid/array-string-quote-comma.t @@ -0,0 +1,43 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'title' => [ + 'Client: "XXXX", Job: XXXX', + 'Code: XXXX' + ] + }; + + +my $actual = from_toml(q{title = [ +"Client: \\"XXXX\\", Job: XXXX", +"Code: XXXX" +] +}); + +is($actual, $expected1, 'array-string-quote-comma - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'array-string-quote-comma - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/array-string-with-comma.t b/t/toml-test/valid/array-string-with-comma.t new file mode 100644 index 0000000..4f4111f --- /dev/null +++ b/t/toml-test/valid/array-string-with-comma.t @@ -0,0 +1,43 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'title' => [ + 'Client: XXXX, Job: XXXX', + 'Code: XXXX' + ] + }; + + +my $actual = from_toml(q{title = [ +"Client: XXXX, Job: XXXX", +"Code: XXXX" +] +}); + +is($actual, $expected1, 'array-string-with-comma - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'array-string-with-comma - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/array-table-array-string-backslash.t b/t/toml-test/valid/array-table-array-string-backslash.t new file mode 100644 index 0000000..f0a7851 --- /dev/null +++ b/t/toml-test/valid/array-table-array-string-backslash.t @@ -0,0 +1,41 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'foo' => [ + { + 'bar' => '"{{baz}}"' + } + ] + }; + + +my $actual = from_toml(q{foo = [ { bar="\\"{{baz}}\\""} ] +}); + +is($actual, $expected1, 'array-table-array-string-backslash - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'array-table-array-string-backslash - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/arrays-hetergeneous.t b/t/toml-test/valid/arrays-hetergeneous.t new file mode 100644 index 0000000..8d7cc4a --- /dev/null +++ b/t/toml-test/valid/arrays-hetergeneous.t @@ -0,0 +1,110 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'mixed' => [ + [ + bless( { + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + '_file' => '(eval 362)' + }, 'Test2::Compare::Custom' ), + bless( { + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('2')->beq($_); + }, + '_file' => '(eval 363)' + }, 'Test2::Compare::Custom' ) + ], + [ + 'a', + 'b' + ], + [ + bless( { + '_file' => '(eval 364)', + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('1.1')->beq($_); + } + }, 'Test2::Compare::Custom' ), + bless( { + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('2.1')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 365)' + }, 'Test2::Compare::Custom' ) + ] + ] + }; + + +my $actual = from_toml(q{mixed = [[1, 2], ["a", "b"], [1.1, 2.1]] +}); + +is($actual, $expected1, 'arrays-hetergeneous - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'arrays-hetergeneous - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/arrays-nested.t b/t/toml-test/valid/arrays-nested.t new file mode 100644 index 0000000..c7dbda4 --- /dev/null +++ b/t/toml-test/valid/arrays-nested.t @@ -0,0 +1,44 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'nest' => [ + [ + 'a' + ], + [ + 'b' + ] + ] + }; + + +my $actual = from_toml(q{nest = [["a"], ["b"]] +}); + +is($actual, $expected1, 'arrays-nested - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'arrays-nested - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/arrays.t b/t/toml-test/valid/arrays.t new file mode 100644 index 0000000..f2fbb4c --- /dev/null +++ b/t/toml-test/valid/arrays.t @@ -0,0 +1,245 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'dates' => [ + bless( { + '_file' => '(eval 139)', + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 11 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + my $exp = 'DateTime::Format::RFC3339'->parse_datetime('1987-07-05T17:45:00Z'); + my $got = 'DateTime::Format::RFC3339'->parse_datetime($_); + $exp->set_time_zone('UTC'); + $got->set_time_zone('UTC'); + return 'DateTime'->compare($got, $exp) == 0; + } + }, 'Test2::Compare::Custom' ), + bless( { + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + my $exp = 'DateTime::Format::RFC3339'->parse_datetime('1979-05-27T07:32:00Z'); + my $got = 'DateTime::Format::RFC3339'->parse_datetime($_); + $exp->set_time_zone('UTC'); + $got->set_time_zone('UTC'); + return 'DateTime'->compare($got, $exp) == 0; + }, + '_lines' => [ + 11 + ], + '_file' => '(eval 360)' + }, 'Test2::Compare::Custom' ), + bless( { + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + my $exp = 'DateTime::Format::RFC3339'->parse_datetime('2006-06-01T11:00:00Z'); + my $got = 'DateTime::Format::RFC3339'->parse_datetime($_); + $exp->set_time_zone('UTC'); + $got->set_time_zone('UTC'); + return 'DateTime'->compare($got, $exp) == 0; + }, + '_lines' => [ + 11 + ], + 'name' => '', + 'operator' => 'CODE(...)', + '_file' => '(eval 361)' + }, 'Test2::Compare::Custom' ) + ], + 'floats' => [ + bless( { + '_file' => '(eval 136)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('1.1')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ), + bless( { + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('2.1')->beq($_); + }, + '_lines' => [ + 6 + ], + 'name' => '', + 'operator' => 'CODE(...)', + '_file' => '(eval 137)' + }, 'Test2::Compare::Custom' ), + bless( { + '_file' => '(eval 138)', + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('3.1')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ) + ], + 'strings' => [ + 'a', + 'b', + 'c' + ], + 'comments' => [ + bless( { + '_file' => '(eval 134)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + '_lines' => [ + 6 + ], + 'name' => '', + 'operator' => 'CODE(...)' + }, 'Test2::Compare::Custom' ), + bless( { + '_file' => '(eval 135)', + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('2')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ) + ], + 'ints' => [ + bless( { + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + '_file' => '(eval 131)' + }, 'Test2::Compare::Custom' ), + bless( { + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('2')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 132)' + }, 'Test2::Compare::Custom' ), + bless( { + '_file' => '(eval 133)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('3')->beq($_); + }, + '_lines' => [ + 6 + ], + 'name' => '', + 'operator' => 'CODE(...)' + }, 'Test2::Compare::Custom' ) + ] + }; + + +my $actual = from_toml(q{ints = [1, 2, 3] +floats = [1.1, 2.1, 3.1] +strings = ["a", "b", "c"] +dates = [ + 1987-07-05T17:45:00Z, + 1979-05-27T07:32:00Z, + 2006-06-01T11:00:00Z, +] +comments = [ + 1, + 2, #this is ok +] +}); + +is($actual, $expected1, 'arrays - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'arrays - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/bool.t b/t/toml-test/valid/bool.t new file mode 100644 index 0000000..ddb2f04 --- /dev/null +++ b/t/toml-test/valid/bool.t @@ -0,0 +1,39 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'f' => 0, + 't' => 1 + }; + + +my $actual = from_toml(q{t = true +f = false +}); + +is($actual, $expected1, 'bool - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'bool - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/comments-at-eof.t b/t/toml-test/valid/comments-at-eof.t new file mode 100644 index 0000000..80d8006 --- /dev/null +++ b/t/toml-test/valid/comments-at-eof.t @@ -0,0 +1,38 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'key' => 'value' + }; + + +my $actual = from_toml(q{# This is a full-line comment +key = "value" # This is a comment at the end of a line +}); + +is($actual, $expected1, 'comments-at-eof - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'comments-at-eof - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/comments-at-eof2.t b/t/toml-test/valid/comments-at-eof2.t new file mode 100644 index 0000000..3370b10 --- /dev/null +++ b/t/toml-test/valid/comments-at-eof2.t @@ -0,0 +1,37 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'key' => 'value' + }; + + +my $actual = from_toml(q{# This is a full-line comment +key = "value" # This is a comment at the end of a line}); + +is($actual, $expected1, 'comments-at-eof2 - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'comments-at-eof2 - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/comments-everywhere.t b/t/toml-test/valid/comments-everywhere.t new file mode 100644 index 0000000..3ea025b --- /dev/null +++ b/t/toml-test/valid/comments-everywhere.t @@ -0,0 +1,111 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'group' => { + 'answer' => bless( { + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + }, + '_lines' => [ + 6 + ], + '_file' => '(eval 366)' + }, 'Test2::Compare::Custom' ), + 'more' => [ + bless( { + '_file' => '(eval 367)', + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + } + }, 'Test2::Compare::Custom' ), + bless( { + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + }, + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 368)' + }, 'Test2::Compare::Custom' ) + ] + } + }; + + +my $actual = from_toml(q{# Top comment. + # Top comment. +# Top comment. + +# [no-extraneous-groups-please] + +[group] # Comment +answer = 42 # Comment +# no-extraneous-keys-please = 999 +# Inbetween comment. +more = [ # Comment + # What about multiple # comments? + # Can you handle it? + # + # Evil. +# Evil. + 42, 42, # Comments within arrays are fun. + # What about multiple # comments? + # Can you handle it? + # + # Evil. +# Evil. +# ] Did I fool you? +] # Hopefully not. +}); + +is($actual, $expected1, 'comments-everywhere - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'comments-everywhere - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/datetime-timezone.t b/t/toml-test/valid/datetime-timezone.t new file mode 100644 index 0000000..f153e97 --- /dev/null +++ b/t/toml-test/valid/datetime-timezone.t @@ -0,0 +1,55 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'bestdayever' => bless( { + '_lines' => [ + 11 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + my $exp = 'DateTime::Format::RFC3339'->parse_datetime('2017-06-06T12:34:56-05:00'); + my $got = 'DateTime::Format::RFC3339'->parse_datetime($_); + $exp->set_time_zone('UTC'); + $got->set_time_zone('UTC'); + return 'DateTime'->compare($got, $exp) == 0; + }, + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 372)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{bestdayever = 2017-06-06T12:34:56-05:00 +}); + +is($actual, $expected1, 'datetime-timezone - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'datetime-timezone - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/datetime.t b/t/toml-test/valid/datetime.t new file mode 100644 index 0000000..c5a6e8b --- /dev/null +++ b/t/toml-test/valid/datetime.t @@ -0,0 +1,95 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'milliseconds' => bless( { + 'operator' => 'CODE(...)', + 'name' => '', + '_lines' => [ + 11 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + my $exp = 'DateTime::Format::RFC3339'->parse_datetime('1977-12-21T03:32:00.555+00:00'); + my $got = 'DateTime::Format::RFC3339'->parse_datetime($_); + $exp->set_time_zone('UTC'); + $got->set_time_zone('UTC'); + return 'DateTime'->compare($got, $exp) == 0; + }, + '_file' => '(eval 369)' + }, 'Test2::Compare::Custom' ), + 'numoffset' => bless( { + '_file' => '(eval 370)', + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 11 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + my $exp = 'DateTime::Format::RFC3339'->parse_datetime('1977-06-28T12:32:00Z'); + my $got = 'DateTime::Format::RFC3339'->parse_datetime($_); + $exp->set_time_zone('UTC'); + $got->set_time_zone('UTC'); + return 'DateTime'->compare($got, $exp) == 0; + } + }, 'Test2::Compare::Custom' ), + 'bestdayever' => bless( { + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 11 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + my $exp = 'DateTime::Format::RFC3339'->parse_datetime('1987-07-05T17:45:00Z'); + my $got = 'DateTime::Format::RFC3339'->parse_datetime($_); + $exp->set_time_zone('UTC'); + $got->set_time_zone('UTC'); + return 'DateTime'->compare($got, $exp) == 0; + }, + '_file' => '(eval 371)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{bestdayever = 1987-07-05T17:45:00Z +numoffset = 1977-06-28T07:32:00-05:00 +milliseconds = 1977-12-21T10:32:00.555+07:00 +}); + +is($actual, $expected1, 'datetime - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'datetime - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/double-quote-escape.t b/t/toml-test/valid/double-quote-escape.t new file mode 100644 index 0000000..7d00ce1 --- /dev/null +++ b/t/toml-test/valid/double-quote-escape.t @@ -0,0 +1,37 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'test' => '"one"' + }; + + +my $actual = from_toml(q{test = "\\"one\\"" +}); + +is($actual, $expected1, 'double-quote-escape - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'double-quote-escape - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/empty.t b/t/toml-test/valid/empty.t new file mode 100644 index 0000000..bdb9f45 --- /dev/null +++ b/t/toml-test/valid/empty.t @@ -0,0 +1,34 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = {}; + + +my $actual = from_toml(q{}); + +is($actual, $expected1, 'empty - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'empty - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/escaped-escape.t b/t/toml-test/valid/escaped-escape.t new file mode 100644 index 0000000..c6a5fd1 --- /dev/null +++ b/t/toml-test/valid/escaped-escape.t @@ -0,0 +1,37 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'answer' => '\\x64' + }; + + +my $actual = from_toml(q{answer = "\\\\x64" +}); + +is($actual, $expected1, 'escaped-escape - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'escaped-escape - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/example.t b/t/toml-test/valid/example.t new file mode 100644 index 0000000..318fafb --- /dev/null +++ b/t/toml-test/valid/example.t @@ -0,0 +1,112 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'numtheory' => { + 'boring' => 0, + 'perfection' => [ + bless( { + '_file' => '(eval 373)', + 'operator' => 'CODE(...)', + 'name' => '', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('6')->beq($_); + } + }, 'Test2::Compare::Custom' ), + bless( { + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('28')->beq($_); + }, + '_lines' => [ + 6 + ], + 'name' => '', + 'operator' => 'CODE(...)', + '_file' => '(eval 374)' + }, 'Test2::Compare::Custom' ), + bless( { + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('496')->beq($_); + }, + '_file' => '(eval 375)' + }, 'Test2::Compare::Custom' ) + ] + }, + 'best-day-ever' => bless( { + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + my $exp = 'DateTime::Format::RFC3339'->parse_datetime('1987-07-05T17:45:00Z'); + my $got = 'DateTime::Format::RFC3339'->parse_datetime($_); + $exp->set_time_zone('UTC'); + $got->set_time_zone('UTC'); + return 'DateTime'->compare($got, $exp) == 0; + }, + '_lines' => [ + 11 + ], + 'name' => '', + 'operator' => 'CODE(...)', + '_file' => '(eval 376)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{best-day-ever = 1987-07-05T17:45:00Z + +[numtheory] +boring = false +perfection = [6, 28, 496] +}); + +is($actual, $expected1, 'example - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'example - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/exponent-part-float.t b/t/toml-test/valid/exponent-part-float.t new file mode 100644 index 0000000..c19418d --- /dev/null +++ b/t/toml-test/valid/exponent-part-float.t @@ -0,0 +1,86 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'million' => bless( { + '_file' => '(eval 377)', + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('1000000')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ), + 'minustenth' => bless( { + '_file' => '(eval 378)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('-0.1')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ), + 'beast' => bless( { + '_file' => '(eval 379)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('666')->beq($_); + }, + '_lines' => [ + 6 + ], + 'name' => '', + 'operator' => 'CODE(...)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{million = 1e6 +minustenth = -1E-1 +beast = 6.66E2 +}); + +is($actual, $expected1, 'exponent-part-float - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'exponent-part-float - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/float-exponent.t b/t/toml-test/valid/float-exponent.t new file mode 100644 index 0000000..6a5f4c1 --- /dev/null +++ b/t/toml-test/valid/float-exponent.t @@ -0,0 +1,154 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'pointlower' => bless( { + '_file' => '(eval 387)', + 'operator' => 'CODE(...)', + 'name' => '', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('310.0')->beq($_); + } + }, 'Test2::Compare::Custom' ), + 'pointupper' => bless( { + '_file' => '(eval 388)', + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('310.0')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ), + 'pos' => bless( { + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('300.0')->beq($_); + }, + '_lines' => [ + 6 + ], + 'name' => '', + 'operator' => 'CODE(...)', + '_file' => '(eval 389)' + }, 'Test2::Compare::Custom' ), + 'zero' => bless( { + '_file' => '(eval 390)', + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('3.0')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ), + 'upper' => bless( { + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('300.0')->beq($_); + }, + '_lines' => [ + 6 + ], + '_file' => '(eval 385)' + }, 'Test2::Compare::Custom' ), + 'lower' => bless( { + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('300.0')->beq($_); + }, + '_lines' => [ + 6 + ], + '_file' => '(eval 384)' + }, 'Test2::Compare::Custom' ), + 'neg' => bless( { + '_file' => '(eval 386)', + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('0.03')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{lower = 3e2 +upper = 3E2 +neg = 3e-2 +pos = 3E+2 +zero = 3e0 +pointlower = 3.1e2 +pointupper = 3.1E2 +}); + +is($actual, $expected1, 'float-exponent - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'float-exponent - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/float-underscore.t b/t/toml-test/valid/float-underscore.t new file mode 100644 index 0000000..7e9308a --- /dev/null +++ b/t/toml-test/valid/float-underscore.t @@ -0,0 +1,86 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'before' => bless( { + '_file' => '(eval 393)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('3141.5927')->beq($_); + }, + '_lines' => [ + 6 + ], + 'name' => '', + 'operator' => 'CODE(...)' + }, 'Test2::Compare::Custom' ), + 'after' => bless( { + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('3141.5927')->beq($_); + }, + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 392)' + }, 'Test2::Compare::Custom' ), + 'exponent' => bless( { + '_file' => '(eval 391)', + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('3e14')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{before = 3_141.5927 +after = 3141.592_7 +exponent = 3e1_4 +}); + +is($actual, $expected1, 'float-underscore - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'float-underscore - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/float.t b/t/toml-test/valid/float.t new file mode 100644 index 0000000..395a030 --- /dev/null +++ b/t/toml-test/valid/float.t @@ -0,0 +1,103 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'pi' => bless( { + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('3.14')->beq($_); + }, + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 381)' + }, 'Test2::Compare::Custom' ), + 'zero-intpart' => bless( { + '_file' => '(eval 380)', + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('0.123')->beq($_); + } + }, 'Test2::Compare::Custom' ), + 'pospi' => bless( { + '_file' => '(eval 383)', + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('3.14')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ), + 'negpi' => bless( { + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('-3.14')->beq($_); + }, + '_file' => '(eval 382)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{pi = 3.14 +pospi = +3.14 +negpi = -3.14 +zero-intpart = 0.123 +}); + +is($actual, $expected1, 'float - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'float - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/implicit-and-explicit-after.t b/t/toml-test/valid/implicit-and-explicit-after.t new file mode 100644 index 0000000..eaad20d --- /dev/null +++ b/t/toml-test/valid/implicit-and-explicit-after.t @@ -0,0 +1,78 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'a' => { + 'b' => { + 'c' => { + 'answer' => bless( { + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + }, + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 395)' + }, 'Test2::Compare::Custom' ) + } + }, + 'better' => bless( { + '_file' => '(eval 394)', + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('43')->beq($_); + } + }, 'Test2::Compare::Custom' ) + } + }; + + +my $actual = from_toml(q{[a.b.c] +answer = 42 + +[a] +better = 43 +}); + +is($actual, $expected1, 'implicit-and-explicit-after - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'implicit-and-explicit-after - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/implicit-and-explicit-before.t b/t/toml-test/valid/implicit-and-explicit-before.t new file mode 100644 index 0000000..82602e2 --- /dev/null +++ b/t/toml-test/valid/implicit-and-explicit-before.t @@ -0,0 +1,78 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'a' => { + 'b' => { + 'c' => { + 'answer' => bless( { + '_file' => '(eval 396)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ) + } + }, + 'better' => bless( { + '_file' => '(eval 397)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('43')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ) + } + }; + + +my $actual = from_toml(q{[a] +better = 43 + +[a.b.c] +answer = 42 +}); + +is($actual, $expected1, 'implicit-and-explicit-before - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'implicit-and-explicit-before - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/implicit-groups.t b/t/toml-test/valid/implicit-groups.t new file mode 100644 index 0000000..458ba5a --- /dev/null +++ b/t/toml-test/valid/implicit-groups.t @@ -0,0 +1,59 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'a' => { + 'b' => { + 'c' => { + 'answer' => bless( { + '_file' => '(eval 398)', + 'operator' => 'CODE(...)', + 'name' => '', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + } + }, 'Test2::Compare::Custom' ) + } + } + } + }; + + +my $actual = from_toml(q{[a.b.c] +answer = 42 +}); + +is($actual, $expected1, 'implicit-groups - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'implicit-groups - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/inline-table-array.t b/t/toml-test/valid/inline-table-array.t new file mode 100644 index 0000000..d4b446d --- /dev/null +++ b/t/toml-test/valid/inline-table-array.t @@ -0,0 +1,52 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'people' => [ + { + 'last_name' => 'Springsteen', + 'first_name' => 'Bruce' + }, + { + 'last_name' => 'Clapton', + 'first_name' => 'Eric' + }, + { + 'last_name' => 'Seger', + 'first_name' => 'Bob' + } + ] + }; + + +my $actual = from_toml(q{people = [{first_name = "Bruce", last_name = "Springsteen"}, + {first_name = "Eric", last_name = "Clapton"}, + {first_name = "Bob", last_name = "Seger"}] +}); + +is($actual, $expected1, 'inline-table-array - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'inline-table-array - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/inline-table.t b/t/toml-test/valid/inline-table.t new file mode 100644 index 0000000..4019c15 --- /dev/null +++ b/t/toml-test/valid/inline-table.t @@ -0,0 +1,152 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'name' => { + 'first' => 'Tom', + 'last' => 'Preston-Werner' + }, + 'point' => { + 'y' => bless( { + '_file' => '(eval 399)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('2')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ), + 'x' => bless( { + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + '_lines' => [ + 6 + ], + '_file' => '(eval 400)' + }, 'Test2::Compare::Custom' ) + }, + 'simple' => { + 'a' => bless( { + '_file' => '(eval 401)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ) + }, + 'str-key' => { + 'a' => bless( { + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + '_file' => '(eval 404)' + }, 'Test2::Compare::Custom' ) + }, + 'table-array' => [ + { + 'a' => bless( { + 'operator' => 'CODE(...)', + 'name' => '', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + '_file' => '(eval 402)' + }, 'Test2::Compare::Custom' ) + }, + { + 'b' => bless( { + '_file' => '(eval 403)', + 'operator' => 'CODE(...)', + 'name' => '', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('2')->beq($_); + } + }, 'Test2::Compare::Custom' ) + } + ] + }; + + +my $actual = from_toml(q{name = { first = "Tom", last = "Preston-Werner" } +point = { x = 1, y = 2 } +simple = { a = 1 } +str-key = { "a" = 1 } +table-array = [{ "a" = 1 }, { "b" = 2 }] +}); + +is($actual, $expected1, 'inline-table - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'inline-table - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/integer-underscore.t b/t/toml-test/valid/integer-underscore.t new file mode 100644 index 0000000..4cb7e12 --- /dev/null +++ b/t/toml-test/valid/integer-underscore.t @@ -0,0 +1,52 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'kilo' => bless( { + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1000')->beq($_); + }, + '_lines' => [ + 6 + ], + '_file' => '(eval 409)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{kilo = 1_000 +}); + +is($actual, $expected1, 'integer-underscore - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'integer-underscore - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/integer.t b/t/toml-test/valid/integer.t new file mode 100644 index 0000000..ce1d2ce --- /dev/null +++ b/t/toml-test/valid/integer.t @@ -0,0 +1,103 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'zero' => bless( { + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('0')->beq($_); + }, + '_lines' => [ + 6 + ], + '_file' => '(eval 406)' + }, 'Test2::Compare::Custom' ), + 'neganswer' => bless( { + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('-42')->beq($_); + }, + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 407)' + }, 'Test2::Compare::Custom' ), + 'posanswer' => bless( { + '_file' => '(eval 405)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + }, + 'name' => '', + 'operator' => 'CODE(...)' + }, 'Test2::Compare::Custom' ), + 'answer' => bless( { + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + }, + 'name' => '', + 'operator' => 'CODE(...)', + '_file' => '(eval 408)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{answer = 42 +posanswer = +42 +neganswer = -42 +zero = 0 +}); + +is($actual, $expected1, 'integer - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'integer - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/key-equals-nospace.t b/t/toml-test/valid/key-equals-nospace.t new file mode 100644 index 0000000..faf80b7 --- /dev/null +++ b/t/toml-test/valid/key-equals-nospace.t @@ -0,0 +1,52 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'answer' => bless( { + '_file' => '(eval 410)', + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{answer=42 +}); + +is($actual, $expected1, 'key-equals-nospace - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'key-equals-nospace - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/key-numeric.t b/t/toml-test/valid/key-numeric.t new file mode 100644 index 0000000..ed2da32 --- /dev/null +++ b/t/toml-test/valid/key-numeric.t @@ -0,0 +1,52 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + '1' => bless( { + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + '_lines' => [ + 6 + ], + '_file' => '(eval 411)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{1 = 1 +}); + +is($actual, $expected1, 'key-numeric - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'key-numeric - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/key-space.t b/t/toml-test/valid/key-space.t new file mode 100644 index 0000000..42ace11 --- /dev/null +++ b/t/toml-test/valid/key-space.t @@ -0,0 +1,52 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'a b' => bless( { + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 412)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{"a b" = 1 +}); + +is($actual, $expected1, 'key-space - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'key-space - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/key-special-chars.t b/t/toml-test/valid/key-special-chars.t new file mode 100644 index 0000000..9d2db15 --- /dev/null +++ b/t/toml-test/valid/key-special-chars.t @@ -0,0 +1,52 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + '~!@$^&*()_+-`1234567890[]|/?><.,;:\'' => bless( { + '_file' => '(eval 413)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{"~!@$^&*()_+-`1234567890[]|/?><.,;:'" = 1 +}); + +is($actual, $expected1, 'key-special-chars - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'key-special-chars - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/keys-with-dots.t b/t/toml-test/valid/keys-with-dots.t new file mode 100644 index 0000000..7366893 --- /dev/null +++ b/t/toml-test/valid/keys-with-dots.t @@ -0,0 +1,146 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'plain_table' => { + 'with.dot' => bless( { + '_file' => '(eval 415)', + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('4')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ), + 'plain' => bless( { + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('3')->beq($_); + }, + '_lines' => [ + 6 + ], + '_file' => '(eval 414)' + }, 'Test2::Compare::Custom' ) + }, + 'table' => { + 'withdot' => { + 'plain' => bless( { + '_file' => '(eval 416)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('5')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ), + 'key.with.dots' => bless( { + '_file' => '(eval 417)', + 'operator' => 'CODE(...)', + 'name' => '', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('6')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ) + } + }, + 'plain' => bless( { + '_file' => '(eval 418)', + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ), + 'with.dot' => bless( { + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('2')->beq($_); + }, + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 419)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{plain = 1 +"with.dot" = 2 + +[plain_table] +plain = 3 +"with.dot" = 4 + +[table.withdot] +plain = 5 +"key.with.dots" = 6}); + +is($actual, $expected1, 'keys-with-dots - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'keys-with-dots - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/long-float.t b/t/toml-test/valid/long-float.t new file mode 100644 index 0000000..f694959 --- /dev/null +++ b/t/toml-test/valid/long-float.t @@ -0,0 +1,69 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'neglongpi' => bless( { + 'name' => '', + 'operator' => 'CODE(...)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('-3.141592653589793')->beq($_); + }, + '_file' => '(eval 420)' + }, 'Test2::Compare::Custom' ), + 'longpi' => bless( { + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('3.141592653589793')->beq($_); + }, + 'operator' => 'CODE(...)', + 'name' => '', + '_file' => '(eval 421)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{longpi = 3.141592653589793 +neglongpi = -3.141592653589793 +}); + +is($actual, $expected1, 'long-float - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'long-float - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/long-integer.t b/t/toml-test/valid/long-integer.t new file mode 100644 index 0000000..4ee0e91 --- /dev/null +++ b/t/toml-test/valid/long-integer.t @@ -0,0 +1,69 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'neganswer' => bless( { + '_file' => '(eval 423)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('-9223372036854775808')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ), + 'answer' => bless( { + '_file' => '(eval 422)', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('9223372036854775807')->beq($_); + }, + 'name' => '', + 'operator' => 'CODE(...)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{answer = 9223372036854775807 +neganswer = -9223372036854775808 +}); + +is($actual, $expected1, 'long-integer - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'long-integer - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/multiline-string.t b/t/toml-test/valid/multiline-string.t new file mode 100644 index 0000000..8ac171f --- /dev/null +++ b/t/toml-test/valid/multiline-string.t @@ -0,0 +1,65 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'equivalent_three' => 'The quick brown fox jumps over the lazy dog.', + 'equivalent_one' => 'The quick brown fox jumps over the lazy dog.', + 'equivalent_two' => 'The quick brown fox jumps over the lazy dog.', + 'multiline_empty_four' => '', + 'multiline_empty_one' => '', + 'multiline_empty_two' => '', + 'multiline_empty_three' => '' + }; + + +my $actual = from_toml(q{multiline_empty_one = """""" +multiline_empty_two = """ +""" +multiline_empty_three = """\\ + """ +multiline_empty_four = """\\ + \\ + \\ + """ + +equivalent_one = "The quick brown fox jumps over the lazy dog." +equivalent_two = """ +The quick brown \\ + + + fox jumps over \\ + the lazy dog.""" + +equivalent_three = """\\ + The quick brown \\ + fox jumps over \\ + the lazy dog.\\ + """ +}); + +is($actual, $expected1, 'multiline-string - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'multiline-string - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/nested-inline-table-array.t b/t/toml-test/valid/nested-inline-table-array.t new file mode 100644 index 0000000..0afd5f2 --- /dev/null +++ b/t/toml-test/valid/nested-inline-table-array.t @@ -0,0 +1,41 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'a' => [ + { + 'b' => {} + } + ] + }; + + +my $actual = from_toml(q{a = [ { b = {} } ] +}); + +is($actual, $expected1, 'nested-inline-table-array - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'nested-inline-table-array - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/newline-crlf.t b/t/toml-test/valid/newline-crlf.t new file mode 100644 index 0000000..bea9477 --- /dev/null +++ b/t/toml-test/valid/newline-crlf.t @@ -0,0 +1,39 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'newline' => 'crlf', + 'os' => 'DOS' + }; + + +my $actual = from_toml(q{os = "DOS" +newline = "crlf" +}); + +is($actual, $expected1, 'newline-crlf - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'newline-crlf - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/newline-lf.t b/t/toml-test/valid/newline-lf.t new file mode 100644 index 0000000..0046668 --- /dev/null +++ b/t/toml-test/valid/newline-lf.t @@ -0,0 +1,39 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'os' => 'unix', + 'newline' => 'lf' + }; + + +my $actual = from_toml(q{os = "unix" +newline = "lf" +}); + +is($actual, $expected1, 'newline-lf - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'newline-lf - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/raw-multiline-string.t b/t/toml-test/valid/raw-multiline-string.t new file mode 100644 index 0000000..0d2496f --- /dev/null +++ b/t/toml-test/valid/raw-multiline-string.t @@ -0,0 +1,51 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'multiline' => 'This string +has \' a quote character +and more than +one newline +in it.', + 'firstnl' => 'This string has a \' quote character.', + 'oneline' => 'This string has a \' quote character.' + }; + + +my $actual = from_toml(q{oneline = '''This string has a ' quote character.''' +firstnl = ''' +This string has a ' quote character.''' +multiline = ''' +This string +has ' a quote character +and more than +one newline +in it.''' +}); + +is($actual, $expected1, 'raw-multiline-string - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'raw-multiline-string - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/raw-string.t b/t/toml-test/valid/raw-string.t new file mode 100644 index 0000000..d1aac75 --- /dev/null +++ b/t/toml-test/valid/raw-string.t @@ -0,0 +1,49 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'formfeed' => 'This string has a \\f form feed character.', + 'slash' => 'This string has a \\/ slash character.', + 'carriage' => 'This string has a \\r carriage return character.', + 'tab' => 'This string has a \\t tab character.', + 'backspace' => 'This string has a \\b backspace character.', + 'newline' => 'This string has a \\n new line character.', + 'backslash' => 'This string has a \\\\ backslash character.' + }; + + +my $actual = from_toml(q{backspace = 'This string has a \\b backspace character.' +tab = 'This string has a \\t tab character.' +newline = 'This string has a \\n new line character.' +formfeed = 'This string has a \\f form feed character.' +carriage = 'This string has a \\r carriage return character.' +slash = 'This string has a \\/ slash character.' +backslash = 'This string has a \\\\ backslash character.' +}); + +is($actual, $expected1, 'raw-string - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'raw-string - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/right-curly-brace-after-boolean.t b/t/toml-test/valid/right-curly-brace-after-boolean.t new file mode 100644 index 0000000..dd3a70d --- /dev/null +++ b/t/toml-test/valid/right-curly-brace-after-boolean.t @@ -0,0 +1,41 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'black' => { + 'python' => '>3.6', + 'allow_prereleases' => 1, + 'version' => '>=18.9b0' + } + }; + + +my $actual = from_toml(q{black = { python=">3.6", version=">=18.9b0", allow_prereleases=true } +}); + +is($actual, $expected1, 'right-curly-brace-after-boolean - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'right-curly-brace-after-boolean - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/string-empty.t b/t/toml-test/valid/string-empty.t new file mode 100644 index 0000000..25e85a2 --- /dev/null +++ b/t/toml-test/valid/string-empty.t @@ -0,0 +1,37 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'answer' => '' + }; + + +my $actual = from_toml(q{answer = "" +}); + +is($actual, $expected1, 'string-empty - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'string-empty - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/string-escapes.t b/t/toml-test/valid/string-escapes.t new file mode 100644 index 0000000..4df271a --- /dev/null +++ b/t/toml-test/valid/string-escapes.t @@ -0,0 +1,58 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'notunicode1' => 'This string does not have a unicode \\u escape.', + 'notunicode4' => 'This string does not have a unicode \\u escape.', + 'newline' => 'This string has a + new line character.', + 'tab' => 'This string has a tab character.', + 'carriage' => 'This string has a carriage return character.', + 'backspace' => 'This string has a  backspace character.', + 'formfeed' => 'This string has a form feed character.', + 'backslash' => 'This string has a \\ backslash character.', + 'quote' => 'This string has a " quote character.', + 'notunicode2' => 'This string does not have a unicode \\u escape.', + 'notunicode3' => 'This string does not have a unicode \\u0075 escape.' + }; + + +my $actual = from_toml(q{backspace = "This string has a \\b backspace character." +tab = "This string has a \\t tab character." +newline = "This string has a \\n new line character." +formfeed = "This string has a \\f form feed character." +carriage = "This string has a \\r carriage return character." +quote = "This string has a \\" quote character." +backslash = "This string has a \\\\ backslash character." +notunicode1 = "This string does not have a unicode \\\\u escape." +notunicode2 = "This string does not have a unicode \\u005Cu escape." +notunicode3 = "This string does not have a unicode \\\\u0075 escape." +notunicode4 = "This string does not have a unicode \\\\\\u0075 escape." +}); + +is($actual, $expected1, 'string-escapes - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'string-escapes - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/string-nl.t b/t/toml-test/valid/string-nl.t new file mode 100644 index 0000000..282d903 --- /dev/null +++ b/t/toml-test/valid/string-nl.t @@ -0,0 +1,48 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'lit_nl_end' => 'value\\n', + 'lit_nl_uni' => 'val\\ue', + 'lit_nl_mid' => 'val\\nue', + 'nl_mid' => 'val +ue', + 'nl_end' => 'value +' + }; + + +my $actual = from_toml(q{nl_mid = "val\\nue" +nl_end = """value\\n""" + +lit_nl_end = '''value\\n''' +lit_nl_mid = 'val\\nue' +lit_nl_uni = 'val\\ue' +}); + +is($actual, $expected1, 'string-nl - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'string-nl - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/string-simple.t b/t/toml-test/valid/string-simple.t new file mode 100644 index 0000000..85b62e5 --- /dev/null +++ b/t/toml-test/valid/string-simple.t @@ -0,0 +1,37 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'answer' => 'You are not drinking enough whisky.' + }; + + +my $actual = from_toml(q{answer = "You are not drinking enough whisky." +}); + +is($actual, $expected1, 'string-simple - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'string-simple - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/string-with-pound.t b/t/toml-test/valid/string-with-pound.t new file mode 100644 index 0000000..55bcb4d --- /dev/null +++ b/t/toml-test/valid/string-with-pound.t @@ -0,0 +1,39 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'poundcomment' => 'But there are # some comments here.', + 'pound' => 'We see no # comments here.' + }; + + +my $actual = from_toml(q{pound = "We see no # comments here." +poundcomment = "But there are # some comments here." # Did I # mess you up? +}); + +is($actual, $expected1, 'string-with-pound - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'string-with-pound - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-array-implicit.t b/t/toml-test/valid/table-array-implicit.t new file mode 100644 index 0000000..d26a5a3 --- /dev/null +++ b/t/toml-test/valid/table-array-implicit.t @@ -0,0 +1,44 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'albums' => { + 'songs' => [ + { + 'name' => 'Glory Days' + } + ] + } + }; + + +my $actual = from_toml(q{[[albums.songs]] +name = "Glory Days" +}); + +is($actual, $expected1, 'table-array-implicit - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-array-implicit - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-array-many.t b/t/toml-test/valid/table-array-many.t new file mode 100644 index 0000000..bda74bb --- /dev/null +++ b/t/toml-test/valid/table-array-many.t @@ -0,0 +1,60 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'people' => [ + { + 'first_name' => 'Bruce', + 'last_name' => 'Springsteen' + }, + { + 'first_name' => 'Eric', + 'last_name' => 'Clapton' + }, + { + 'last_name' => 'Seger', + 'first_name' => 'Bob' + } + ] + }; + + +my $actual = from_toml(q{[[people]] +first_name = "Bruce" +last_name = "Springsteen" + +[[people]] +first_name = "Eric" +last_name = "Clapton" + +[[people]] +first_name = "Bob" +last_name = "Seger" +}); + +is($actual, $expected1, 'table-array-many - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-array-many - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-array-nest.t b/t/toml-test/valid/table-array-nest.t new file mode 100644 index 0000000..4ed1f21 --- /dev/null +++ b/t/toml-test/valid/table-array-nest.t @@ -0,0 +1,76 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'albums' => [ + { + 'name' => 'Born to Run', + 'songs' => [ + { + 'name' => 'Jungleland' + }, + { + 'name' => 'Meeting Across the River' + } + ] + }, + { + 'songs' => [ + { + 'name' => 'Glory Days' + }, + { + 'name' => 'Dancing in the Dark' + } + ], + 'name' => 'Born in the USA' + } + ] + }; + + +my $actual = from_toml(q{[[albums]] +name = "Born to Run" + + [[albums.songs]] + name = "Jungleland" + + [[albums.songs]] + name = "Meeting Across the River" + +[[albums]] +name = "Born in the USA" + + [[albums.songs]] + name = "Glory Days" + + [[albums.songs]] + name = "Dancing in the Dark" +}); + +is($actual, $expected1, 'table-array-nest - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-array-nest - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-array-one.t b/t/toml-test/valid/table-array-one.t new file mode 100644 index 0000000..f8a9c83 --- /dev/null +++ b/t/toml-test/valid/table-array-one.t @@ -0,0 +1,44 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'people' => [ + { + 'first_name' => 'Bruce', + 'last_name' => 'Springsteen' + } + ] + }; + + +my $actual = from_toml(q{[[people]] +first_name = "Bruce" +last_name = "Springsteen" +}); + +is($actual, $expected1, 'table-array-one - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-array-one - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-array-table-array.t b/t/toml-test/valid/table-array-table-array.t new file mode 100644 index 0000000..04fe42e --- /dev/null +++ b/t/toml-test/valid/table-array-table-array.t @@ -0,0 +1,58 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'a' => [ + { + 'b' => [ + { + 'c' => { + 'd' => 'val0' + } + }, + { + 'c' => { + 'd' => 'val1' + } + } + ] + } + ] + }; + + +my $actual = from_toml(q{[[a]] + [[a.b]] + [a.b.c] + d = "val0" + [[a.b]] + [a.b.c] + d = "val1" +}); + +is($actual, $expected1, 'table-array-table-array - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-array-table-array - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-empty.t b/t/toml-test/valid/table-empty.t new file mode 100644 index 0000000..b41b5cf --- /dev/null +++ b/t/toml-test/valid/table-empty.t @@ -0,0 +1,37 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'a' => {} + }; + + +my $actual = from_toml(q{[a] +}); + +is($actual, $expected1, 'table-empty - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-empty - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-no-eol.t b/t/toml-test/valid/table-no-eol.t new file mode 100644 index 0000000..40d6e45 --- /dev/null +++ b/t/toml-test/valid/table-no-eol.t @@ -0,0 +1,36 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'table' => {} + }; + + +my $actual = from_toml(q{[table]}); + +is($actual, $expected1, 'table-no-eol - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-no-eol - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-sub-empty.t b/t/toml-test/valid/table-sub-empty.t new file mode 100644 index 0000000..7324c87 --- /dev/null +++ b/t/toml-test/valid/table-sub-empty.t @@ -0,0 +1,40 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'a' => { + 'b' => {} + } + }; + + +my $actual = from_toml(q{[a] +[a.b] +}); + +is($actual, $expected1, 'table-sub-empty - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-sub-empty - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-whitespace.t b/t/toml-test/valid/table-whitespace.t new file mode 100644 index 0000000..da94dd3 --- /dev/null +++ b/t/toml-test/valid/table-whitespace.t @@ -0,0 +1,37 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'valid key' => {} + }; + + +my $actual = from_toml(q{["valid key"] +}); + +is($actual, $expected1, 'table-whitespace - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-whitespace - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-with-literal-string.t b/t/toml-test/valid/table-with-literal-string.t new file mode 100644 index 0000000..bc580ee --- /dev/null +++ b/t/toml-test/valid/table-with-literal-string.t @@ -0,0 +1,61 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'a' => { + '"b"' => { + 'c' => { + 'answer' => bless( { + '_file' => '(eval 424)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + }, + '_lines' => [ + 6 + ], + 'operator' => 'CODE(...)', + 'name' => '' + }, 'Test2::Compare::Custom' ) + } + } + } + }; + + +my $actual = from_toml(q{['a'] +[a.'"b"'] +[a.'"b"'.c] +answer = 42 +}); + +is($actual, $expected1, 'table-with-literal-string - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-with-literal-string - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-with-pound.t b/t/toml-test/valid/table-with-pound.t new file mode 100644 index 0000000..1039f41 --- /dev/null +++ b/t/toml-test/valid/table-with-pound.t @@ -0,0 +1,55 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'key#group' => { + 'answer' => bless( { + '_file' => '(eval 425)', + 'name' => '', + 'operator' => 'CODE(...)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + }, + '_lines' => [ + 6 + ] + }, 'Test2::Compare::Custom' ) + } + }; + + +my $actual = from_toml(q{["key#group"] +answer = 42 +}); + +is($actual, $expected1, 'table-with-pound - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-with-pound - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/table-with-single-quotes.t b/t/toml-test/valid/table-with-single-quotes.t new file mode 100644 index 0000000..139fba2 --- /dev/null +++ b/t/toml-test/valid/table-with-single-quotes.t @@ -0,0 +1,61 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'a' => { + 'b' => { + 'c' => { + 'answer' => bless( { + '_file' => '(eval 426)', + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('42')->beq($_); + }, + '_lines' => [ + 6 + ], + 'name' => '', + 'operator' => 'CODE(...)' + }, 'Test2::Compare::Custom' ) + } + } + } + }; + + +my $actual = from_toml(q{['a'] +[a.'b'] +[a.'b'.c] +answer = 42 +}); + +is($actual, $expected1, 'table-with-single-quotes - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-with-single-quotes - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/underscored-float.t b/t/toml-test/valid/underscored-float.t new file mode 100644 index 0000000..177d3c0 --- /dev/null +++ b/t/toml-test/valid/underscored-float.t @@ -0,0 +1,52 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'electron_mass' => bless( { + '_file' => '(eval 427)', + 'operator' => 'CODE(...)', + 'name' => '', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigFloat; + 'Math::BigFloat'->new('9.109109383e-31')->beq($_); + } + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{electron_mass = 9_109.109_383e-3_4 +}); + +is($actual, $expected1, 'underscored-float - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'underscored-float - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/underscored-integer.t b/t/toml-test/valid/underscored-integer.t new file mode 100644 index 0000000..ec6ac4f --- /dev/null +++ b/t/toml-test/valid/underscored-integer.t @@ -0,0 +1,52 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'million' => bless( { + 'operator' => 'CODE(...)', + 'name' => '', + '_lines' => [ + 6 + ], + 'code' => sub { + BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"} + use strict; + no feature ':all'; + use feature ':5.16'; + require Math::BigInt; + 'Math::BigInt'->new('1000000')->beq($_); + }, + '_file' => '(eval 428)' + }, 'Test2::Compare::Custom' ) + }; + + +my $actual = from_toml(q{million = 1_000_000 +}); + +is($actual, $expected1, 'underscored-integer - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'underscored-integer - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/unicode-escape.t b/t/toml-test/valid/unicode-escape.t new file mode 100644 index 0000000..c42211c --- /dev/null +++ b/t/toml-test/valid/unicode-escape.t @@ -0,0 +1,39 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'answer8' => "\x{3b4}", + 'answer4' => "\x{3b4}" + }; + + +my $actual = from_toml(q{answer4 = "\\u03B4" +answer8 = "\\U000003B4" +}); + +is($actual, $expected1, 'unicode-escape - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'unicode-escape - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file diff --git a/t/toml-test/valid/unicode-literal.t b/t/toml-test/valid/unicode-literal.t new file mode 100644 index 0000000..217e956 --- /dev/null +++ b/t/toml-test/valid/unicode-literal.t @@ -0,0 +1,37 @@ +# File automatically generated from BurntSushi/toml-test +use utf8; +use Test2::V0; +use Data::Dumper; +use TOML::Tiny; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; + +my $expected1 = { + 'answer' => "\x{3b4}" + }; + + +my $actual = from_toml(q{answer = "δ" +}); + +is($actual, $expected1, 'unicode-literal - from_toml') or do{ + diag 'EXPECTED:'; + diag Dumper($expected1); + + diag 'ACTUAL:'; + diag Dumper($actual); +}; + +is(eval{ from_toml(to_toml($actual)) }, $actual, 'unicode-literal - to_toml') or do{ + diag 'INPUT:'; + diag Dumper($actual); + + diag 'TOML OUTPUT:'; + diag to_toml($actual); + + diag 'REPARSED OUTPUT:'; + diag Dumper(from_toml(to_toml($actual))); +}; + +done_testing; \ No newline at end of file