Dogfood tests

This commit is contained in:
Oliver Schneider
2017-04-12 10:55:34 +02:00
parent 3534149035
commit 7ee0d4f9c2
2 changed files with 16 additions and 10 deletions

View File

@@ -225,6 +225,7 @@ fn with_if_expr<F>(stmt: &ast::Stmt, mut func: F)
} }
/// A type to distinguish between the two distinct cases this lint handles. /// A type to distinguish between the two distinct cases this lint handles.
#[derive(Copy, Clone, Debug)]
enum LintType { enum LintType {
ContinueInsideElseBlock, ContinueInsideElseBlock,
ContinueInsideThenBlock, ContinueInsideThenBlock,
@@ -361,17 +362,18 @@ fn check_and_warn<'a>(ctx: &EarlyContext, expr: &'a ast::Expr) {
/// continues eating till a non-whitespace character is found. /// continues eating till a non-whitespace character is found.
/// e.g., the string /// e.g., the string
/// ///
/// " /// ```
/// { /// {
/// let x = 5; /// let x = 5;
/// } /// }
/// " /// ```
/// ///
/// is transformed to /// is transformed to
/// ///
/// " /// ```
/// { /// {
/// let x = 5;" /// let x = 5;"
/// ```
/// ///
/// NOTE: when there is no closing brace in `s`, `s` is _not_ preserved, i.e., /// NOTE: when there is no closing brace in `s`, `s` is _not_ preserved, i.e.,
/// an empty string will be returned in that case. /// an empty string will be returned in that case.
@@ -391,19 +393,21 @@ pub fn erode_from_back(s: &str) -> String {
/// any number of opening braces are eaten, followed by any number of newlines. /// any number of opening braces are eaten, followed by any number of newlines.
/// e.g., the string /// e.g., the string
/// ///
/// " /// ```
/// { /// {
/// something(); /// something();
/// inside_a_block(); /// inside_a_block();
/// } /// }
/// " /// ```
/// ///
/// is transformed to /// is transformed to
/// ///
/// " something(); /// ```
/// something();
/// inside_a_block(); /// inside_a_block();
/// } /// }
/// " ///
/// ```
/// ///
pub fn erode_from_front(s: &str) -> String { pub fn erode_from_front(s: &str) -> String {
s.chars() s.chars()

View File

@@ -1093,6 +1093,7 @@ pub fn align_two_snippets(s: &str, t: &str) -> String {
/// ///
/// For example, consider /// For example, consider
/// ///
/// ```
/// let s1 = "\ /// let s1 = "\
/// if (condition()) { /// if (condition()) {
/// do_something()"; /// do_something()";
@@ -1103,18 +1104,19 @@ pub fn align_two_snippets(s: &str, t: &str) -> String {
/// let s3 = "\ /// let s3 = "\
/// another_piece_of_code(); /// another_piece_of_code();
/// indented_here();"; /// indented_here();";
/// /// ```
/// ///
/// ///
/// ///
/// Now calling `align_snippets(&[s1, s2, s3])` will yield the following: /// Now calling `align_snippets(&[s1, s2, s3])` will yield the following:
/// ///
/// "\ /// ```
/// if (condition()) { /// if (condition()) {
/// do_something(); /// do_something();
/// code_from_somewhere_else(); /// code_from_somewhere_else();
/// another_piece_of_code(); /// another_piece_of_code();
/// indented_here();" /// indented_here();
/// ```
pub fn align_snippets(xs: &[&str]) -> String { pub fn align_snippets(xs: &[&str]) -> String {
if xs.is_empty() { if xs.is_empty() {
String::from("") String::from("")