~ubuntu-branches/ubuntu/saucy/libyaml-libyaml-perl/saucy-security

« back to all changes in this revision

Viewing changes to t/error.t

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur
  • Date: 2009-06-01 02:17:22 UTC
  • Revision ID: james.westby@ubuntu.com-20090601021722-8qlj45pmu8ffwzau
Tags: upstream-0.32
ImportĀ upstreamĀ versionĀ 0.32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use t::TestYAMLTests tests => 24;
 
2
 
 
3
filters {
 
4
    error => ['lines', 'chomp'],
 
5
};
 
6
 
 
7
run {
 
8
    my $test = shift;
 
9
    eval {
 
10
        Load($test->yaml);
 
11
    };
 
12
    for my $error ($test->error) {
 
13
        if ($error =~ s/^!//) {
 
14
            my $re = qr/$error/;
 
15
            unlike $@, $re, $test->name . " (!~ /$error/)";
 
16
        }
 
17
        else {
 
18
            my $re = qr/$error/;
 
19
            like $@, $re, $test->name . " (=~ /$error/)";
 
20
        }
 
21
    }
 
22
};
 
23
 
 
24
__DATA__
 
25
=== Bad hash indentation
 
26
+++ yaml
 
27
foo: 2
 
28
 bar: 4
 
29
+++ error
 
30
mapping values are not allowed in this context
 
31
document: 1
 
32
line: 2
 
33
column: 5
 
34
 
 
35
=== Unquoted * as hash key
 
36
+++ yaml
 
37
*: foo
 
38
+++ error
 
39
did not find expected alphabetic or numeric character
 
40
document: 1
 
41
column: 2
 
42
while scanning an alias
 
43
 
 
44
=== Unquoted * as hash value
 
45
+++ yaml
 
46
---
 
47
foo bar: *
 
48
+++ error
 
49
did not find expected alphabetic or numeric character
 
50
document: 1
 
51
line: 2
 
52
column: 11
 
53
while scanning an alias
 
54
 
 
55
=== Unquoted * as scalar
 
56
+++ yaml
 
57
--- xxx
 
58
--- * * *
 
59
+++ error
 
60
did not find expected alphabetic or numeric character
 
61
document: 2
 
62
line: 2
 
63
column: 6
 
64
while scanning an alias
 
65
 
 
66
=== Bad tag for array
 
67
+++ yaml
 
68
--- !!foo []
 
69
+++ error
 
70
bad tag found for array: 'tag:yaml.org,2002:foo'
 
71
document: 1
 
72
 
 
73
=== Bad tag for hash
 
74
+++ yaml
 
75
--- !!!foo {}
 
76
+++ error
 
77
bad tag found for hash: 'tag:yaml.org,2002:!foo'
 
78
document: 1
 
79
!line:
 
80
!column: