diff options
author | vsrs <[email protected]> | 2020-05-16 15:25:12 +0100 |
---|---|---|
committer | vsrs <[email protected]> | 2020-05-16 15:27:23 +0100 |
commit | cd45c73b660f85acc9b564e536bc407f0836891d (patch) | |
tree | 47fc05ab69ac4a23e9de6fb4d05c3c5cbf997850 /crates | |
parent | 7e9c7ac4ee5c9295d811670277bc1aeb9775998c (diff) |
JFF, ra_fixture arg name for a code highlighting
Diffstat (limited to 'crates')
-rw-r--r-- | crates/test_utils/src/lib.rs | 20 |
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 | /// ``` |
248 | pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> { | 248 | pub 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] |
420 | fn parse_fixture_gets_full_meta() { | 420 | fn 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 |
438 | pub fn parse_single_fixture(fixture: &str) -> Option<FixtureEntry> { | 440 | pub 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 | } |