mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
minor: generalize
This commit is contained in:
parent
d783226381
commit
e366b3c730
1 changed files with 7 additions and 7 deletions
|
@ -9,7 +9,7 @@ use std::{
|
||||||
|
|
||||||
use expect_test::expect_file;
|
use expect_test::expect_file;
|
||||||
|
|
||||||
use crate::LexedStr;
|
use crate::{LexedStr, TopEntryPoint};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lex_ok() {
|
fn lex_ok() {
|
||||||
|
@ -45,7 +45,7 @@ fn lex(text: &str) -> String {
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_ok() {
|
fn parse_ok() {
|
||||||
for case in TestCase::list("parser/ok") {
|
for case in TestCase::list("parser/ok") {
|
||||||
let (actual, errors) = parse(&case.text);
|
let (actual, errors) = parse(TopEntryPoint::SourceFile, &case.text);
|
||||||
assert!(!errors, "errors in an OK file {}:\n{}", case.rs.display(), actual);
|
assert!(!errors, "errors in an OK file {}:\n{}", case.rs.display(), actual);
|
||||||
expect_file![case.txt].assert_eq(&actual);
|
expect_file![case.txt].assert_eq(&actual);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ fn parse_ok() {
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_inline_ok() {
|
fn parse_inline_ok() {
|
||||||
for case in TestCase::list("parser/inline/ok") {
|
for case in TestCase::list("parser/inline/ok") {
|
||||||
let (actual, errors) = parse(&case.text);
|
let (actual, errors) = parse(TopEntryPoint::SourceFile, &case.text);
|
||||||
assert!(!errors, "errors in an OK file {}:\n{}", case.rs.display(), actual);
|
assert!(!errors, "errors in an OK file {}:\n{}", case.rs.display(), actual);
|
||||||
expect_file![case.txt].assert_eq(&actual);
|
expect_file![case.txt].assert_eq(&actual);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ fn parse_inline_ok() {
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_err() {
|
fn parse_err() {
|
||||||
for case in TestCase::list("parser/err") {
|
for case in TestCase::list("parser/err") {
|
||||||
let (actual, errors) = parse(&case.text);
|
let (actual, errors) = parse(TopEntryPoint::SourceFile, &case.text);
|
||||||
assert!(errors, "no errors in an ERR file {}:\n{}", case.rs.display(), actual);
|
assert!(errors, "no errors in an ERR file {}:\n{}", case.rs.display(), actual);
|
||||||
expect_file![case.txt].assert_eq(&actual)
|
expect_file![case.txt].assert_eq(&actual)
|
||||||
}
|
}
|
||||||
|
@ -72,16 +72,16 @@ fn parse_err() {
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_inline_err() {
|
fn parse_inline_err() {
|
||||||
for case in TestCase::list("parser/inline/err") {
|
for case in TestCase::list("parser/inline/err") {
|
||||||
let (actual, errors) = parse(&case.text);
|
let (actual, errors) = parse(TopEntryPoint::SourceFile, &case.text);
|
||||||
assert!(errors, "no errors in an ERR file {}:\n{}", case.rs.display(), actual);
|
assert!(errors, "no errors in an ERR file {}:\n{}", case.rs.display(), actual);
|
||||||
expect_file![case.txt].assert_eq(&actual)
|
expect_file![case.txt].assert_eq(&actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(text: &str) -> (String, bool) {
|
fn parse(entry: TopEntryPoint, text: &str) -> (String, bool) {
|
||||||
let lexed = LexedStr::new(text);
|
let lexed = LexedStr::new(text);
|
||||||
let input = lexed.to_input();
|
let input = lexed.to_input();
|
||||||
let output = crate::TopEntryPoint::SourceFile.parse(&input);
|
let output = entry.parse(&input);
|
||||||
|
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
let mut errors = Vec::new();
|
let mut errors = Vec::new();
|
||||||
|
|
Loading…
Reference in a new issue