chiark / gitweb /
4df271ade957b424d653e8fce3f0f05a86936b05
[nailing-cargo.git] / 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 TOML::Tiny;
6
7 binmode STDIN,  ':encoding(UTF-8)';
8 binmode STDOUT, ':encoding(UTF-8)';
9
10 my $expected1 = {
11                'notunicode1' => 'This string does not have a unicode \\u escape.',
12                'notunicode4' => 'This string does not have a unicode \\u escape.',
13                'newline' => 'This string has a 
14  new line character.',
15                'tab' => 'This string has a       tab character.',
16                'carriage' => 'This string has a \r carriage return character.',
17                'backspace' => 'This string has a \b backspace character.',
18                'formfeed' => 'This string has a \f form feed character.',
19                'backslash' => 'This string has a \\ backslash character.',
20                'quote' => 'This string has a " quote character.',
21                'notunicode2' => 'This string does not have a unicode \\u escape.',
22                'notunicode3' => 'This string does not have a unicode \\u0075 escape.'
23              };
24
25
26 my $actual = from_toml(q{backspace = "This string has a \\b backspace character."
27 tab = "This string has a \\t tab character."
28 newline = "This string has a \\n new line character."
29 formfeed = "This string has a \\f form feed character."
30 carriage = "This string has a \\r carriage return character."
31 quote = "This string has a \\" quote character."
32 backslash = "This string has a \\\\ backslash character."
33 notunicode1 = "This string does not have a unicode \\\\u escape."
34 notunicode2 = "This string does not have a unicode \\u005Cu escape."
35 notunicode3 = "This string does not have a unicode \\\\u0075 escape."
36 notunicode4 = "This string does not have a unicode \\\\\\u0075 escape."
37 });
38
39 is($actual, $expected1, 'string-escapes - from_toml') or do{
40   diag 'EXPECTED:';
41   diag Dumper($expected1);
42
43   diag 'ACTUAL:';
44   diag Dumper($actual);
45 };
46
47 is(eval{ from_toml(to_toml($actual)) }, $actual, 'string-escapes - to_toml') or do{
48   diag 'INPUT:';
49   diag Dumper($actual);
50
51   diag 'TOML OUTPUT:';
52   diag to_toml($actual);
53
54   diag 'REPARSED OUTPUT:';
55   diag Dumper(from_toml(to_toml($actual)));
56 };
57
58 done_testing;