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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
extern crate milf;
macro_rules! bad {
($milf:expr, $msg:expr) => {
match $milf.parse::<milf::Value>() {
Ok(s) => panic!("parsed to: {:#?}", s),
Err(e) => assert_eq!(e.to_string(), $msg),
}
};
}
macro_rules! test( ($name:ident, $s:expr, $msg:expr) => (
#[test]
fn $name() { bad!($s, $msg); }
) );
test!(
datetime_malformed_no_leads,
include_str!("invalid/datetime-malformed-no-leads.milf"),
"failed to parse datetime for key `no-leads` at line 1 column 12"
);
test!(
datetime_malformed_no_secs,
include_str!("invalid/datetime-malformed-no-secs.milf"),
"expected a colon, found a newline at line 1 column 28"
);
test!(
datetime_malformed_no_t,
include_str!("invalid/datetime-malformed-no-t.milf"),
"failed to parse datetime for key `no-t` at line 1 column 8"
);
test!(
datetime_malformed_with_milli,
include_str!("invalid/datetime-malformed-with-milli.milf"),
"failed to parse datetime for key `with-milli` at line 1 column 14"
);
test!(
duplicate_key_table,
include_str!("invalid/duplicate-key-table.milf"),
"duplicate key: `type` for key `fruit` at line 4 column 1"
);
test!(
duplicate_keys,
include_str!("invalid/duplicate-keys.milf"),
"duplicate key: `dupe` at line 1 column 1"
);
test!(
duplicate_table,
include_str!("invalid/duplicate-table.milf"),
"redefinition of table `dependencies` for key `dependencies` at line 7 column 1"
);
test!(
duplicate_tables,
include_str!("invalid/duplicate-tables.milf"),
"redefinition of table `a` for key `a` at line 2 column 1"
);
test!(
empty_implicit_table,
include_str!("invalid/empty-implicit-table.milf"),
"expected a table key, found a period at line 1 column 10"
);
test!(
empty_table,
include_str!("invalid/empty-table.milf"),
"expected a table key, found a right bracket at line 1 column 2"
);
test!(
float_no_leading_zero,
include_str!("invalid/float-no-leading-zero.milf"),
"expected a value, found a period at line 1 column 10"
);
test!(
float_no_suffix,
include_str!("invalid/float-no-suffix.milf"),
"invalid number at line 1 column 5"
);
test!(
float_no_trailing_digits,
include_str!("invalid/float-no-trailing-digits.milf"),
"invalid number at line 1 column 12"
);
test!(
key_after_array,
include_str!("invalid/key-after-array.milf"),
"expected newline, found an identifier at line 1 column 14"
);
test!(
key_after_table,
include_str!("invalid/key-after-table.milf"),
"expected newline, found an identifier at line 1 column 11"
);
test!(
key_empty,
include_str!("invalid/key-empty.milf"),
"expected a table key, found an equals at line 1 column 2"
);
test!(
key_hash,
include_str!("invalid/key-hash.milf"),
"expected an equals, found a comment at line 1 column 2"
);
test!(
key_newline,
include_str!("invalid/key-newline.milf"),
"expected an equals, found a newline at line 1 column 2"
);
test!(
key_open_bracket,
include_str!("invalid/key-open-bracket.milf"),
"expected a right bracket, found an equals at line 1 column 6"
);
test!(
key_single_open_bracket,
include_str!("invalid/key-single-open-bracket.milf"),
"expected a table key, found eof at line 1 column 2"
);
test!(
key_space,
include_str!("invalid/key-space.milf"),
"expected an equals, found an identifier at line 1 column 3"
);
test!(
key_start_bracket,
include_str!("invalid/key-start-bracket.milf"),
"expected a right bracket, found an equals at line 2 column 6"
);
test!(
key_two_equals,
include_str!("invalid/key-two-equals.milf"),
"expected a value, found an equals at line 1 column 6"
);
test!(
string_bad_byte_escape,
include_str!("invalid/string-bad-byte-escape.milf"),
"invalid escape character in string: `x` at line 1 column 13"
);
test!(
string_bad_escape,
include_str!("invalid/string-bad-escape.milf"),
"invalid escape character in string: `a` at line 1 column 42"
);
test!(
string_bad_line_ending_escape,
include_str!("invalid/string-bad-line-ending-escape.milf"),
"invalid escape character in string: ` ` at line 2 column 79"
);
test!(
string_byte_escapes,
include_str!("invalid/string-byte-escapes.milf"),
"invalid escape character in string: `x` at line 1 column 12"
);
test!(
string_no_close,
include_str!("invalid/string-no-close.milf"),
"newline in string found at line 1 column 42"
);
test!(
table_array_implicit,
include_str!("invalid/table-array-implicit.milf"),
"table redefined as array for key `albums` at line 13 column 1"
);
test!(
table_array_malformed_bracket,
include_str!("invalid/table-array-malformed-bracket.milf"),
"expected a right bracket, found a newline at line 1 column 10"
);
test!(
table_array_malformed_empty,
include_str!("invalid/table-array-malformed-empty.milf"),
"expected a table key, found a right bracket at line 1 column 3"
);
test!(
table_empty,
include_str!("invalid/table-empty.milf"),
"expected a table key, found a right bracket at line 1 column 2"
);
test!(
table_nested_brackets_close,
include_str!("invalid/table-nested-brackets-close.milf"),
"expected newline, found an identifier at line 1 column 4"
);
test!(
table_nested_brackets_open,
include_str!("invalid/table-nested-brackets-open.milf"),
"expected a right bracket, found a left bracket at line 1 column 3"
);
test!(
table_whitespace,
include_str!("invalid/table-whitespace.milf"),
"expected a right bracket, found an identifier at line 1 column 10"
);
test!(
table_with_pound,
include_str!("invalid/table-with-pound.milf"),
"expected a right bracket, found a comment at line 1 column 5"
);
test!(
text_after_array_entries,
include_str!("invalid/text-after-array-entries.milf"),
"invalid MILF value, did you mean to use a quoted string? at line 2 column 46"
);
test!(
text_after_integer,
include_str!("invalid/text-after-integer.milf"),
"expected newline, found an identifier at line 1 column 13"
);
test!(
text_after_string,
include_str!("invalid/text-after-string.milf"),
"expected newline, found an identifier at line 1 column 41"
);
test!(
text_after_table,
include_str!("invalid/text-after-table.milf"),
"expected newline, found an identifier at line 1 column 9"
);
test!(
text_before_array_separator,
include_str!("invalid/text-before-array-separator.milf"),
"expected a right bracket, found an identifier at line 2 column 46"
);
test!(
text_in_array,
include_str!("invalid/text-in-array.milf"),
"invalid MILF value, did you mean to use a quoted string? at line 3 column 3"
);
|