Remove old code.
This commit is contained in:
		
							parent
							
								
									ef549d3b19
								
							
						
					
					
						commit
						78befc7665
					
				
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -1,386 +0,0 @@ | ||||
| use super::diff::WasmDiffResult; | ||||
| use super::diff::WasmDiffStatus; | ||||
| use crate::compare::get_emacs_standard_properties; | ||||
| use crate::compare::get_property; | ||||
| use crate::compare::get_property_quoted_string; | ||||
| use crate::compare::unquote; | ||||
| use crate::compare::Token; | ||||
| use crate::wasm::AdditionalProperties; | ||||
| use crate::wasm::AdditionalPropertyValue; | ||||
| use crate::wasm::WasmStandardProperties; | ||||
| 
 | ||||
| // pub(crate) fn wasm_compare_list<'b, 's: 'b, 'p, EI, WI, WC>(
 | ||||
| //     source: &'s str,
 | ||||
| //     emacs: EI,
 | ||||
| //     wasm: WI,
 | ||||
| // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>>
 | ||||
| // where
 | ||||
| //     EI: Iterator<Item = &'b Token<'s>> + ExactSizeIterator,
 | ||||
| //     WI: Iterator<Item = WC> + ExactSizeIterator,
 | ||||
| //     WC: WasmElispCompare<'s, 'p>,
 | ||||
| // {
 | ||||
| //     let status = Vec::new();
 | ||||
| //     let emacs_length = emacs.len();
 | ||||
| //     let wasm_length = wasm.len();
 | ||||
| //     if emacs_length != wasm_length {
 | ||||
| //         return Ok(WasmDiffResult {
 | ||||
| //             status: vec![WasmDiffStatus::Bad(
 | ||||
| //                 format!(
 | ||||
| //                     "Child length mismatch (emacs != rust) {:?} != {:?}",
 | ||||
| //                     emacs_length, wasm_length
 | ||||
| //                 )
 | ||||
| //                 .into(),
 | ||||
| //             )],
 | ||||
| //             children: Vec::new(),
 | ||||
| //             name: "".into(),
 | ||||
| //         });
 | ||||
| //     }
 | ||||
| 
 | ||||
| //     let mut child_status = Vec::with_capacity(emacs_length);
 | ||||
| //     for (emacs_child, wasm_child) in emacs.zip(wasm) {
 | ||||
| //         child_status.push(wasm_child.compare_ast_node(source, emacs_child)?);
 | ||||
| //     }
 | ||||
| //     Ok(WasmDiffResult {
 | ||||
| //         status,
 | ||||
| //         children: child_status,
 | ||||
| //         name: "".into(),
 | ||||
| //     })
 | ||||
| // }
 | ||||
| 
 | ||||
| // pub(crate) fn wasm_compare_property_quoted_string<
 | ||||
| //     'b,
 | ||||
| //     's,
 | ||||
| //     W,
 | ||||
| //     WV: AsRef<str> + std::fmt::Debug,
 | ||||
| //     WG: Fn(W) -> Option<WV>,
 | ||||
| // >(
 | ||||
| //     _source: &'s str,
 | ||||
| //     emacs: &'b Token<'s>,
 | ||||
| //     wasm_node: W,
 | ||||
| //     emacs_field: &str,
 | ||||
| //     wasm_value_getter: WG,
 | ||||
| // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
 | ||||
| //     let mut result = WasmDiffResult::default();
 | ||||
| //     let emacs_value = get_property_quoted_string(emacs, emacs_field)?;
 | ||||
| //     let wasm_value = wasm_value_getter(wasm_node);
 | ||||
| //     if wasm_value.as_ref().map(|s| s.as_ref()) != emacs_value.as_deref() {
 | ||||
| //         result.status.push(WasmDiffStatus::Bad(
 | ||||
| //             format!(
 | ||||
| //                 "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                 property = emacs_field,
 | ||||
| //                 emacs = emacs_value,
 | ||||
| //                 wasm = wasm_value,
 | ||||
| //             )
 | ||||
| //             .into(),
 | ||||
| //         ))
 | ||||
| //     }
 | ||||
| //     Ok(result)
 | ||||
| // }
 | ||||
| 
 | ||||
| // pub(crate) fn wasm_compare_property_list_of_quoted_string<
 | ||||
| //     'b,
 | ||||
| //     's,
 | ||||
| //     WI: Iterator<Item = WV> + ExactSizeIterator,
 | ||||
| //     W,
 | ||||
| //     WV: AsRef<str> + std::fmt::Debug,
 | ||||
| //     WG: Fn(W) -> Option<WI>,
 | ||||
| // >(
 | ||||
| //     _source: &'s str,
 | ||||
| //     emacs: &'b Token<'s>,
 | ||||
| //     wasm_node: W,
 | ||||
| //     emacs_field: &str,
 | ||||
| //     wasm_value_getter: WG,
 | ||||
| // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
 | ||||
| //     let mut result = WasmDiffResult::default();
 | ||||
| //     let emacs_value = get_property(emacs, emacs_field)?
 | ||||
| //         .map(Token::as_list)
 | ||||
| //         .map_or(Ok(None), |r| r.map(Some))?;
 | ||||
| //     let wasm_value = wasm_value_getter(wasm_node);
 | ||||
| //     match (emacs_value, wasm_value) {
 | ||||
| //         (None, None) => {}
 | ||||
| //         (None, Some(_)) | (Some(_), None) => {
 | ||||
| //             return Ok(WasmDiffResult {
 | ||||
| //             status: vec![WasmDiffStatus::Bad(
 | ||||
| //                 format!(
 | ||||
| //                     "Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                     property = emacs_field,
 | ||||
| //                     emacs = if emacs_value.is_some() {"Some"} else {"None"},
 | ||||
| //                     wasm = if !emacs_value.is_some() {"Some"} else {"None"}
 | ||||
| //                 )
 | ||||
| //                 .into(),
 | ||||
| //             )],
 | ||||
| //             children: Vec::new(),
 | ||||
| //             name: "".into(),
 | ||||
| //         });
 | ||||
| //         }
 | ||||
| //         (Some(el), Some(wl)) if el.len() != wl.len() => {
 | ||||
| //             return Ok(WasmDiffResult {
 | ||||
| //             status: vec![WasmDiffStatus::Bad(
 | ||||
| //                 format!(
 | ||||
| //                     "Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                     property = emacs_field,
 | ||||
| //                     emacs = el.len(),
 | ||||
| //                     wasm = wl.len()
 | ||||
| //                 )
 | ||||
| //                 .into(),
 | ||||
| //             )],
 | ||||
| //             children: Vec::new(),
 | ||||
| //             name: "".into(),
 | ||||
| //         });
 | ||||
| //         }
 | ||||
| //         (Some(el), Some(wl)) => {
 | ||||
| //             for (e, w) in el.iter().zip(wl) {
 | ||||
| //                 let e = unquote(e.as_atom()?)?;
 | ||||
| //                 let w = w.as_ref();
 | ||||
| //                 if e != w {
 | ||||
| //                     result.status.push(WasmDiffStatus::Bad(
 | ||||
| //                         format!(
 | ||||
| //                             "Property list value mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                             property = emacs_field,
 | ||||
| //                             emacs = e,
 | ||||
| //                             wasm = w
 | ||||
| //                         )
 | ||||
| //                             .into(),
 | ||||
| //                     ));
 | ||||
| //                 }
 | ||||
| //             }
 | ||||
| //         }
 | ||||
| //     };
 | ||||
| 
 | ||||
| //     Ok(result)
 | ||||
| // }
 | ||||
| 
 | ||||
| // pub(crate) fn wasm_compare_property_optional_pair<
 | ||||
| //     'b,
 | ||||
| //     's,
 | ||||
| //     W,
 | ||||
| //     WV: AsRef<str> + std::fmt::Debug,
 | ||||
| //     WOV: AsRef<str> + std::fmt::Debug,
 | ||||
| //     WG: Fn(W) -> Option<(Option<WOV>, WV)>,
 | ||||
| // >(
 | ||||
| //     _source: &'s str,
 | ||||
| //     emacs: &'b Token<'s>,
 | ||||
| //     wasm_node: W,
 | ||||
| //     emacs_field: &str,
 | ||||
| //     wasm_value_getter: WG,
 | ||||
| // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
 | ||||
| //     let mut result = WasmDiffResult::default();
 | ||||
| //     let emacs_value = get_property(emacs, emacs_field)?
 | ||||
| //         .map(Token::as_list)
 | ||||
| //         .map_or(Ok(None), |r| r.map(Some))?;
 | ||||
| //     let wasm_value = wasm_value_getter(wasm_node);
 | ||||
| //     match (emacs_value, &wasm_value) {
 | ||||
| //         (None, None) => {}
 | ||||
| //         (None, Some(_)) | (Some(_), None) => {
 | ||||
| //             return Ok(WasmDiffResult {
 | ||||
| //             status: vec![WasmDiffStatus::Bad(
 | ||||
| //                 format!(
 | ||||
| //                     "Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                     property = emacs_field,
 | ||||
| //                     emacs = if emacs_value.is_some() {"Some"} else {"None"},
 | ||||
| //                     wasm = if !emacs_value.is_some() {"Some"} else {"None"}
 | ||||
| //                 )
 | ||||
| //                 .into(),
 | ||||
| //             )],
 | ||||
| //             children: Vec::new(),
 | ||||
| //             name: "".into(),
 | ||||
| //         });
 | ||||
| //         }
 | ||||
| //         (Some(el), Some((Some(owl), wl))) if el.len() == 3 => {
 | ||||
| //             let e = el
 | ||||
| //                 .first()
 | ||||
| //                 .map(Token::as_atom)
 | ||||
| //                 .map_or(Ok(None), |r| r.map(Some))?
 | ||||
| //                 .map(unquote)
 | ||||
| //                 .map_or(Ok(None), |r| r.map(Some))?
 | ||||
| //                 .expect("Above match proved length to be 3.");
 | ||||
| //             let oe = el
 | ||||
| //                 .get(2)
 | ||||
| //                 .map(Token::as_atom)
 | ||||
| //                 .map_or(Ok(None), |r| r.map(Some))?
 | ||||
| //                 .map(unquote)
 | ||||
| //                 .map_or(Ok(None), |r| r.map(Some))?
 | ||||
| //                 .expect("Above match proved length to be 3.");
 | ||||
| //             let w = wl.as_ref();
 | ||||
| //             let ow = owl.as_ref();
 | ||||
| //             if e != w {
 | ||||
| //                 result.status.push(WasmDiffStatus::Bad(
 | ||||
| //                     format!(
 | ||||
| //                         "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                         property = "end",
 | ||||
| //                         emacs = e,
 | ||||
| //                         wasm = w,
 | ||||
| //                     )
 | ||||
| //                         .into(),
 | ||||
| //                 ));
 | ||||
| //             }
 | ||||
| //             if oe != ow {
 | ||||
| //                 result.status.push(WasmDiffStatus::Bad(
 | ||||
| //                     format!(
 | ||||
| //                         "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                         property = "end",
 | ||||
| //                         emacs = oe,
 | ||||
| //                         wasm = ow,
 | ||||
| //                     )
 | ||||
| //                         .into(),
 | ||||
| //                 ));
 | ||||
| //             }
 | ||||
| //         }
 | ||||
| //         (Some(el), Some((None, wl))) if el.len() == 1 => {
 | ||||
| //             let e = el
 | ||||
| //                 .first()
 | ||||
| //                 .map(Token::as_atom)
 | ||||
| //                 .map_or(Ok(None), |r| r.map(Some))?
 | ||||
| //                 .map(unquote)
 | ||||
| //                 .map_or(Ok(None), |r| r.map(Some))?
 | ||||
| //                 .expect("Above match proved length to be 3.");
 | ||||
| //             let w = wl.as_ref();
 | ||||
| //             if e != w {
 | ||||
| //                 result.status.push(WasmDiffStatus::Bad(
 | ||||
| //                     format!(
 | ||||
| //                         "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                         property = "end",
 | ||||
| //                         emacs = e,
 | ||||
| //                         wasm = w,
 | ||||
| //                     )
 | ||||
| //                         .into(),
 | ||||
| //                 ));
 | ||||
| //             }
 | ||||
| //         }
 | ||||
| //         (Some(el), Some(_)) => {
 | ||||
| //             return Ok(WasmDiffResult {
 | ||||
| //             status: vec![WasmDiffStatus::Bad(
 | ||||
| //                 format!(
 | ||||
| //                     "Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                     property = emacs_field,
 | ||||
| //                     emacs = el.len(),
 | ||||
| //                     wasm = wasm_value
 | ||||
| //                 )
 | ||||
| //                 .into(),
 | ||||
| //             )],
 | ||||
| //             children: Vec::new(),
 | ||||
| //             name: "".into(),
 | ||||
| //         });
 | ||||
| //         }
 | ||||
| //     }
 | ||||
| //     Ok(result)
 | ||||
| // }
 | ||||
| 
 | ||||
| // pub(crate) fn wasm_compare_standard_properties<'b, 's>(
 | ||||
| //     _source: &'s str,
 | ||||
| //     emacs: &'b Token<'s>,
 | ||||
| //     wasm: &WasmStandardProperties,
 | ||||
| // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
 | ||||
| //     let mut result = WasmDiffResult::default();
 | ||||
| //     let mut layer = WasmDiffResult::default();
 | ||||
| //     layer.name = "standard-properties".into();
 | ||||
| //     let standard_properties = get_emacs_standard_properties(emacs)?;
 | ||||
| 
 | ||||
| //     if Some(wasm.begin) != standard_properties.begin {
 | ||||
| //         layer.status.push(WasmDiffStatus::Bad(
 | ||||
| //             format!(
 | ||||
| //                 "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                 property = "begin",
 | ||||
| //                 emacs = standard_properties.begin,
 | ||||
| //                 wasm = Some(wasm.begin),
 | ||||
| //             )
 | ||||
| //             .into(),
 | ||||
| //         ));
 | ||||
| //     }
 | ||||
| //     if Some(wasm.end) != standard_properties.end {
 | ||||
| //         layer.status.push(WasmDiffStatus::Bad(
 | ||||
| //             format!(
 | ||||
| //                 "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                 property = "end",
 | ||||
| //                 emacs = standard_properties.end,
 | ||||
| //                 wasm = Some(wasm.end),
 | ||||
| //             )
 | ||||
| //             .into(),
 | ||||
| //         ));
 | ||||
| //     }
 | ||||
| //     if wasm.contents_begin != standard_properties.contents_begin {
 | ||||
| //         layer.status.push(WasmDiffStatus::Bad(
 | ||||
| //             format!(
 | ||||
| //                 "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                 property = "contents-begin",
 | ||||
| //                 emacs = standard_properties.contents_begin,
 | ||||
| //                 wasm = wasm.contents_begin,
 | ||||
| //             )
 | ||||
| //             .into(),
 | ||||
| //         ));
 | ||||
| //     }
 | ||||
| //     if wasm.contents_end != standard_properties.contents_end {
 | ||||
| //         layer.status.push(WasmDiffStatus::Bad(
 | ||||
| //             format!(
 | ||||
| //                 "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                 property = "contents-end",
 | ||||
| //                 emacs = standard_properties.contents_end,
 | ||||
| //                 wasm = wasm.contents_end,
 | ||||
| //             )
 | ||||
| //             .into(),
 | ||||
| //         ));
 | ||||
| //     }
 | ||||
| //     if Some(wasm.post_blank).map(|post_blank| post_blank as usize) != standard_properties.post_blank
 | ||||
| //     {
 | ||||
| //         layer.status.push(WasmDiffStatus::Bad(
 | ||||
| //             format!(
 | ||||
| //                 "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
 | ||||
| //                 property = "post-blank",
 | ||||
| //                 emacs = standard_properties.post_blank,
 | ||||
| //                 wasm = Some(wasm.post_blank),
 | ||||
| //             )
 | ||||
| //             .into(),
 | ||||
| //         ));
 | ||||
| //     }
 | ||||
| 
 | ||||
| //     result.children.push(layer);
 | ||||
| //     Ok(result)
 | ||||
| // }
 | ||||
| 
 | ||||
| // pub(crate) fn wasm_compare_additional_properties<'b, 's>(
 | ||||
| //     source: &'s str,
 | ||||
| //     emacs: &'b Token<'s>,
 | ||||
| //     wasm: &AdditionalProperties<'_, '_>,
 | ||||
| // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
 | ||||
| //     let mut result = WasmDiffResult::default();
 | ||||
| //     let mut layer = WasmDiffResult::default();
 | ||||
| //     layer.name = "additional-properties".into();
 | ||||
| 
 | ||||
| //     for (property_name, property_value) in wasm.properties.iter() {
 | ||||
| //         let emacs_property_name = format!(":{property_name}", property_name = property_name);
 | ||||
| //         match property_value {
 | ||||
| //             AdditionalPropertyValue::SingleString(wasm_value) => {
 | ||||
| //                 layer.extend(wasm_compare_property_quoted_string(
 | ||||
| //                     source,
 | ||||
| //                     emacs,
 | ||||
| //                     wasm,
 | ||||
| //                     &emacs_property_name,
 | ||||
| //                     |_| Some(wasm_value),
 | ||||
| //                 )?)?;
 | ||||
| //             }
 | ||||
| //             AdditionalPropertyValue::ListOfStrings(wasm_value) => {
 | ||||
| //                 layer.extend(wasm_compare_property_list_of_quoted_string(
 | ||||
| //                     source,
 | ||||
| //                     emacs,
 | ||||
| //                     wasm,
 | ||||
| //                     &emacs_property_name,
 | ||||
| //                     |_| Some(wasm_value.iter()),
 | ||||
| //                 )?)?;
 | ||||
| //             }
 | ||||
| //             // TODO: similar to compare_affiliated_keywords
 | ||||
| //             AdditionalPropertyValue::OptionalPair { optval, val } => {
 | ||||
| //                 layer.extend(wasm_compare_property_optional_pair(
 | ||||
| //                     source,
 | ||||
| //                     emacs,
 | ||||
| //                     wasm,
 | ||||
| //                     &emacs_property_name,
 | ||||
| //                     |_| Some((*optval, *val)),
 | ||||
| //                 )?)?;
 | ||||
| //             }
 | ||||
| //             AdditionalPropertyValue::ObjectTree(_) => todo!(),
 | ||||
| //         }
 | ||||
| //     }
 | ||||
| 
 | ||||
| //     result.children.push(layer);
 | ||||
| //     Ok(result)
 | ||||
| // }
 | ||||
| @ -1,6 +1,5 @@ | ||||
| mod compare; | ||||
| mod diff; | ||||
| mod logic; | ||||
| mod macros; | ||||
| mod runner; | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander