diff options
| author | Matthew Russo <matthew@edapp.com> | 2018-12-04 15:18:03 -0500 |
|---|---|---|
| committer | Matthew Russo <matthew@edapp.com> | 2018-12-04 19:52:42 -0500 |
| commit | f0f8aa9e05726bfbc065fa2504daf3232f29bc03 (patch) | |
| tree | 5027e1682248fb6e535546046f43dff45d6e2b50 /src/libsyntax/parse/mod.rs | |
| parent | 88130f1796e98837dc6f58aea9b9a0f49b85f426 (diff) | |
| download | rust-f0f8aa9e05726bfbc065fa2504daf3232f29bc03.tar.gz rust-f0f8aa9e05726bfbc065fa2504daf3232f29bc03.zip | |
adds DocTest filename variant, refactors doctest_offset out of source_map, fixes remaining test failures
Diffstat (limited to 'src/libsyntax/parse/mod.rs')
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index ac972f20f94..a229ccfa265 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -977,23 +977,25 @@ mod tests { with_globals(|| { let sess = ParseSess::new(FilePathMapping::empty()); - let name = FileName::Custom("source".to_string()); + let name_1 = FileName::Custom("crlf_source_1".to_string()); let source = "/// doc comment\r\nfn foo() {}".to_string(); - let item = parse_item_from_source_str(name.clone(), source, &sess) + let item = parse_item_from_source_str(name_1, source, &sess) .unwrap().unwrap(); let doc = first_attr_value_str_by_name(&item.attrs, "doc").unwrap(); assert_eq!(doc, "/// doc comment"); + let name_2 = FileName::Custom("crlf_source_2".to_string()); let source = "/// doc comment\r\n/// line 2\r\nfn foo() {}".to_string(); - let item = parse_item_from_source_str(name.clone(), source, &sess) + let item = parse_item_from_source_str(name_2, source, &sess) .unwrap().unwrap(); let docs = item.attrs.iter().filter(|a| a.path == "doc") .map(|a| a.value_str().unwrap().to_string()).collect::<Vec<_>>(); let b: &[_] = &["/// doc comment".to_string(), "/// line 2".to_string()]; assert_eq!(&docs[..], b); + let name_3 = FileName::Custom("clrf_source_3".to_string()); let source = "/** doc comment\r\n * with CRLF */\r\nfn foo() {}".to_string(); - let item = parse_item_from_source_str(name, source, &sess).unwrap().unwrap(); + let item = parse_item_from_source_str(name_3, source, &sess).unwrap().unwrap(); let doc = first_attr_value_str_by_name(&item.attrs, "doc").unwrap(); assert_eq!(doc, "/** doc comment\n * with CRLF */"); }); |
