-
Notifications
You must be signed in to change notification settings - Fork 26
/
2-scalars.t
60 lines (49 loc) · 1.21 KB
/
2-scalars.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# This test modified from YAML::Syck suite
use strict;
use Test::More;
require YAML;
YAML->import;
is(Dump(42), "--- 42\n");
is(Load("--- 42\n"), 42);
is(Dump(undef), "--- ~\n");
is(Load("--- ~\n"), undef);
is(Load("---\n"), undef);
is(Load("--- ''\n"), '');
is(Load("--- true\n"), "true");
is(Load("--- false\n"), "false");
# $YAML::Syck::ImplicitTyping = $YAML::Syck::ImplicitTyping = 1;
#
# is(Load("--- true\n"), 1);
# is(Load("--- false\n"), '');
my $Data = {
Test => '
Test Drive D:\\',
};
is_deeply(Load(Dump($Data)), $Data);
if ($^V ge v5.9.0) {
# Large data tests. See also https://bugzilla.redhat.com/show_bug.cgi?id=192400.
$Data = ' äø<> " \' " \'' x 40_000;
is(Load(Dump($Data)), $Data);
}
{
my $yaml1 = <<'EOM';
a: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
b: 2
EOM
my $yaml2 = <<'EOM';
a: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
b: 2
EOM
my $error;
eval {
my @data = Load($yaml1);
};
$error = $@;
cmp_ok($error, '=~', "Can't parse single", "Single quoted without end");
eval {
my @data = Load($yaml2);
};
$error = $@;
cmp_ok($error, '=~', "Can't parse double", "Double quoted without end");
}
done_testing;