Add a test for #2510

Closes #2510.
This commit is contained in:
Seiichi Uchida 2018-03-07 15:53:17 +09:00
parent 466caa77bb
commit e9f5382757
3 changed files with 34 additions and 4 deletions

View File

@ -330,26 +330,28 @@ fn check_files(files: Vec<PathBuf>) -> (Vec<FormatReport>, u32, u32) {
}
fn print_mismatches_default_message(result: HashMap<PathBuf, Vec<Mismatch>>) {
let mut t = term::stdout().unwrap();
for (file_name, diff) in result {
let mismatch_msg_formatter =
|line_num| format!("\nMismatch at {}:{}:", file_name.display(), line_num);
print_diff(diff, &mismatch_msg_formatter, Color::Auto);
}
t.reset().unwrap();
if let Some(mut t) = term::stdout() {
t.reset().unwrap_or(());
}
}
fn print_mismatches<T: Fn(u32) -> String>(
result: HashMap<PathBuf, Vec<Mismatch>>,
mismatch_msg_formatter: T,
) {
let mut t = term::stdout().unwrap();
for (_file_name, diff) in result {
print_diff(diff, &mismatch_msg_formatter, Color::Auto);
}
t.reset().unwrap();
if let Some(mut t) = term::stdout() {
t.reset().unwrap_or(());
}
}
fn read_config(filename: &Path) -> Config {

View File

@ -23,3 +23,18 @@ fn impl_trait_fn_2<E>() -> impl Future<Item=&'a i64,Error=E> {}
fn issue_1234() {
do_parse!(name: take_while1!(is_token) >> (Header))
}
// #2510
impl CombineTypes {
pub fn pop_callback(
&self,
query_id: Uuid,
) -> Option<
(
ProjectId,
Box<FnMut(&ProjectState, serde_json::Value, bool) -> () + Sync + Send>,
),
> {
self.query_callbacks()(&query_id)
}
}

View File

@ -29,3 +29,16 @@ fn impl_trait_fn_2<E>() -> impl Future<Item = &'a i64, Error = E> {}
fn issue_1234() {
do_parse!(name: take_while1!(is_token) >> (Header))
}
// #2510
impl CombineTypes {
pub fn pop_callback(
&self,
query_id: Uuid,
) -> Option<(
ProjectId,
Box<FnMut(&ProjectState, serde_json::Value, bool) -> () + Sync + Send>,
)> {
self.query_callbacks()(&query_id)
}
}