Skip to content

Commit 606ea5e

Browse files
committed
Add test of Literal span
1 parent 287979f commit 606ea5e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,26 @@ fn literal_parse() {
264264
assert!("-\"\"".parse::<Literal>().is_err());
265265
}
266266

267+
#[test]
268+
fn literal_span() {
269+
let positive = "0.1".parse::<Literal>().unwrap();
270+
let negative = "-0.1".parse::<Literal>().unwrap();
271+
272+
#[cfg(not(span_locations))]
273+
{
274+
let _ = positive;
275+
let _ = negative;
276+
}
277+
278+
#[cfg(span_locations)]
279+
{
280+
assert_eq!(positive.span().start().column, 0);
281+
assert_eq!(positive.span().end().column, 3);
282+
assert_eq!(negative.span().start().column, 0);
283+
assert_eq!(negative.span().end().column, 4);
284+
}
285+
}
286+
267287
#[test]
268288
fn roundtrip() {
269289
fn roundtrip(p: &str) {

0 commit comments

Comments
 (0)