chiark / gitweb /
Add 'TOML-Tiny/' from commit 'dab92c92905923c50929c14cc59adadff5b9eedf'
[nailing-cargo.git] / TOML-Tiny / t / toml-test / valid / string-escapes.t
1 # File automatically generated from BurntSushi/toml-test
2 use utf8;
3 use Test2::V0;
4 use Data::Dumper;
5 use DateTime;
6 use DateTime::Format::RFC3339;
7 use Math::BigInt;
8 use Math::BigFloat;
9 use TOML::Tiny;
10
11 binmode STDIN,  ':encoding(UTF-8)';
12 binmode STDOUT, ':encoding(UTF-8)';
13
14 my $expected1 = {
15                'formfeed' => 'This string has a \f form feed character.',
16                'notunicode1' => 'This string does not have a unicode \\u escape.',
17                'quote' => 'This string has a " quote character.',
18                'newline' => 'This string has a 
19  new line character.',
20                'notunicode3' => 'This string does not have a unicode \\u0075 escape.',
21                'carriage' => 'This string has a \r carriage return character.',
22                'tab' => 'This string has a       tab character.',
23                'backslash' => 'This string has a \\ backslash character.',
24                'backspace' => 'This string has a \b backspace character.',
25                'notunicode2' => 'This string does not have a unicode \\u escape.',
26                'notunicode4' => 'This string does not have a unicode \\u escape.'
27              };
28
29
30 my $actual = from_toml(q{backspace = "This string has a \\b backspace character."
31 tab = "This string has a \\t tab character."
32 newline = "This string has a \\n new line character."
33 formfeed = "This string has a \\f form feed character."
34 carriage = "This string has a \\r carriage return character."
35 quote = "This string has a \\" quote character."
36 backslash = "This string has a \\\\ backslash character."
37 notunicode1 = "This string does not have a unicode \\\\u escape."
38 notunicode2 = "This string does not have a unicode \\u005Cu escape."
39 notunicode3 = "This string does not have a unicode \\\\u0075 escape."
40 notunicode4 = "This string does not have a unicode \\\\\\u0075 escape."
41 });
42
43 is($actual, $expected1, 'string-escapes - from_toml') or do{
44   diag 'EXPECTED:';
45   diag Dumper($expected1);
46
47   diag 'ACTUAL:';
48   diag Dumper($actual);
49 };
50
51 is(eval{ from_toml(to_toml($actual)) }, $actual, 'string-escapes - to_toml') or do{
52   diag 'INPUT:';
53   diag Dumper($actual);
54
55   diag 'TOML OUTPUT:';
56   diag to_toml($actual);
57
58   diag 'REPARSED OUTPUT:';
59   diag Dumper(from_toml(to_toml($actual)));
60 };
61
62 done_testing;