compare_properties babel call.
This commit is contained in:
		
							parent
							
								
									c2222c9102
								
							
						
					
					
						commit
						9f166278f4
					
				| @ -2488,73 +2488,64 @@ fn compare_keyword<'b, 's>( | ||||
| } | ||||
| 
 | ||||
| fn compare_babel_call<'b, 's>( | ||||
|     _source: &'s str, | ||||
|     source: &'s str, | ||||
|     emacs: &'b Token<'s>, | ||||
|     rust: &'b BabelCall<'s>, | ||||
| ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { | ||||
|     let child_status = Vec::new(); | ||||
|     let mut this_status = DiffStatus::Good; | ||||
|     let mut child_status = Vec::new(); | ||||
|     let mut message = None; | ||||
| 
 | ||||
|     // TODO: Compare :caption
 | ||||
|     // Compare name
 | ||||
|     let name = get_property_quoted_string(emacs, ":name")?; | ||||
|     if name.as_ref().map(String::as_str) != rust.name { | ||||
|         this_status = DiffStatus::Bad; | ||||
|         message = Some(format!( | ||||
|             "Name mismatch (emacs != rust) {:?} != {:?}", | ||||
|             name, rust.name | ||||
|         )); | ||||
|     } | ||||
|     assert_no_children(emacs, &mut this_status, &mut message)?; | ||||
| 
 | ||||
|     // Compare value
 | ||||
|     let value = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new()); | ||||
|     if value != rust.value { | ||||
|         this_status = DiffStatus::Bad; | ||||
|         message = Some(format!( | ||||
|             "Value mismatch (emacs != rust) {:?} != {:?}", | ||||
|             value, rust.value | ||||
|         )) | ||||
|     } | ||||
| 
 | ||||
|     // Compare call
 | ||||
|     let call = get_property_quoted_string(emacs, ":call")?; | ||||
|     if call.as_ref().map(String::as_str) != rust.call { | ||||
|         this_status = DiffStatus::Bad; | ||||
|         message = Some(format!( | ||||
|             "Call mismatch (emacs != rust) {:?} != {:?}", | ||||
|             call, rust.call | ||||
|         )) | ||||
|     } | ||||
| 
 | ||||
|     // Compare arguments
 | ||||
|     let arguments = get_property_quoted_string(emacs, ":arguments")?; | ||||
|     if arguments.as_ref().map(String::as_str) != rust.arguments { | ||||
|         this_status = DiffStatus::Bad; | ||||
|         message = Some(format!( | ||||
|             "Arguments mismatch (emacs != rust) {:?} != {:?}", | ||||
|             arguments, rust.arguments | ||||
|         )) | ||||
|     } | ||||
| 
 | ||||
|     // Compare inside header
 | ||||
|     let inside_header = get_property_quoted_string(emacs, ":inside-header")?; | ||||
|     if inside_header.as_ref().map(String::as_str) != rust.inside_header { | ||||
|         this_status = DiffStatus::Bad; | ||||
|         message = Some(format!( | ||||
|             "Inside header mismatch (emacs != rust) {:?} != {:?}", | ||||
|             inside_header, rust.inside_header | ||||
|         )) | ||||
|     } | ||||
| 
 | ||||
|     // Compare end header
 | ||||
|     let end_header = get_property_quoted_string(emacs, ":end-header")?; | ||||
|     if end_header.as_ref().map(String::as_str) != rust.end_header { | ||||
|         this_status = DiffStatus::Bad; | ||||
|         message = Some(format!( | ||||
|             "End header mismatch (emacs != rust) {:?} != {:?}", | ||||
|             end_header, rust.end_header | ||||
|         )) | ||||
|     for diff in compare_properties!( | ||||
|         source, | ||||
|         emacs, | ||||
|         rust, | ||||
|         ( | ||||
|             EmacsField::Optional(":name"), | ||||
|             |r| r.name, | ||||
|             compare_property_quoted_string | ||||
|         ), | ||||
|         ( | ||||
|             EmacsField::Optional(":caption"), | ||||
|             compare_identity, | ||||
|             compare_noop | ||||
|         ), | ||||
|         ( | ||||
|             EmacsField::Required(":value"), | ||||
|             |r| Some(r.value), | ||||
|             compare_property_quoted_string | ||||
|         ), | ||||
|         ( | ||||
|             EmacsField::Required(":call"), | ||||
|             |r| r.call, | ||||
|             compare_property_quoted_string | ||||
|         ), | ||||
|         ( | ||||
|             EmacsField::Required(":arguments"), | ||||
|             |r| r.arguments, | ||||
|             compare_property_quoted_string | ||||
|         ), | ||||
|         ( | ||||
|             EmacsField::Required(":inside-header"), | ||||
|             |r| r.inside_header, | ||||
|             compare_property_quoted_string | ||||
|         ), | ||||
|         ( | ||||
|             EmacsField::Required(":end-header"), | ||||
|             |r| r.end_header, | ||||
|             compare_property_quoted_string | ||||
|         ) | ||||
|     ) { | ||||
|         match diff { | ||||
|             ComparePropertiesResult::NoChange => {} | ||||
|             ComparePropertiesResult::SelfChange(new_status, new_message) => { | ||||
|                 this_status = new_status; | ||||
|                 message = new_message | ||||
|             } | ||||
|             ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry), | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     Ok(DiffResult { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander