aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils/src
diff options
context:
space:
mode:
authorvsrs <[email protected]>2020-05-16 15:25:12 +0100
committervsrs <[email protected]>2020-05-16 15:27:23 +0100
commitcd45c73b660f85acc9b564e536bc407f0836891d (patch)
tree47fc05ab69ac4a23e9de6fb4d05c3c5cbf997850 /crates/test_utils/src
parent7e9c7ac4ee5c9295d811670277bc1aeb9775998c (diff)
JFF, ra_fixture arg name for a code highlighting
Diffstat (limited to 'crates/test_utils/src')
-rw-r--r--crates/test_utils/src/lib.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs
index fc5ae8f07..45abfead9 100644
--- a/crates/test_utils/src/lib.rs
+++ b/crates/test_utils/src/lib.rs
@@ -245,8 +245,8 @@ impl FixtureMeta {
245/// line 2 245/// line 2
246/// // - other meta 246/// // - other meta
247/// ``` 247/// ```
248pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> { 248pub fn parse_fixture(ra_fixture: &str) -> Vec<FixtureEntry> {
249 let fixture = indent_first_line(fixture); 249 let fixture = indent_first_line(ra_fixture);
250 let margin = fixture_margin(&fixture); 250 let margin = fixture_margin(&fixture);
251 251
252 let mut lines = fixture 252 let mut lines = fixture
@@ -418,14 +418,16 @@ struct Bar;
418 418
419#[test] 419#[test]
420fn parse_fixture_gets_full_meta() { 420fn parse_fixture_gets_full_meta() {
421 let fixture = r" 421 let parsed = parse_fixture(
422 r"
422 //- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b,atom env:OUTDIR=path/to,OTHER=foo 423 //- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b,atom env:OUTDIR=path/to,OTHER=foo
423 "; 424 mod m;
424 let parsed = parse_fixture(fixture); 425 ",
426 );
425 assert_eq!(1, parsed.len()); 427 assert_eq!(1, parsed.len());
426 428
427 let parsed = &parsed[0]; 429 let parsed = &parsed[0];
428 assert_eq!("\n", parsed.text); 430 assert_eq!("mod m;\n\n", parsed.text);
429 431
430 let meta = &parsed.meta; 432 let meta = &parsed.meta;
431 assert_eq!("foo", meta.crate_name().unwrap()); 433 assert_eq!("foo", meta.crate_name().unwrap());
@@ -435,12 +437,12 @@ fn parse_fixture_gets_full_meta() {
435} 437}
436 438
437/// Same as `parse_fixture`, except it allow empty fixture 439/// Same as `parse_fixture`, except it allow empty fixture
438pub fn parse_single_fixture(fixture: &str) -> Option<FixtureEntry> { 440pub fn parse_single_fixture(ra_fixture: &str) -> Option<FixtureEntry> {
439 if !fixture.lines().any(|it| it.trim_start().starts_with("//-")) { 441 if !ra_fixture.lines().any(|it| it.trim_start().starts_with("//-")) {
440 return None; 442 return None;
441 } 443 }
442 444
443 let fixtures = parse_fixture(fixture); 445 let fixtures = parse_fixture(ra_fixture);
444 if fixtures.len() > 1 { 446 if fixtures.len() > 1 {
445 panic!("too many fixtures"); 447 panic!("too many fixtures");
446 } 448 }