From 346c9ee26725d84ea7d34d4f248055321ec51067 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Wed, 30 Aug 2023 09:32:40 -0400 Subject: [PATCH] misc --- build.rs | 3 +++ parsing/src/suggestions.rs | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index d6b6d77..0296f98 100644 --- a/build.rs +++ b/build.rs @@ -28,6 +28,7 @@ fn font_stripper(from: &str, out: &str, unicodes: Vec) -> Result, .collect::>() .join(","); + // Test to see if pyftsubset is found let pyftsubset_detect = run_script::run("whereis pyftsubset", &(vec![]), &ScriptOptions::new()); match pyftsubset_detect { Ok((_i, s1, _s2)) => { @@ -35,9 +36,11 @@ fn font_stripper(from: &str, out: &str, unicodes: Vec) -> Result, return Err(String::from("pyftsubset not found")); } } + // It was not, return an error and abort Err(x) => return Err(x.to_string()), } + let script_result = run_script::run( &format!( "pyftsubset {}/assets/{} --unicodes={} diff --git a/parsing/src/suggestions.rs b/parsing/src/suggestions.rs index 27ea51c..c609c9e 100644 --- a/parsing/src/suggestions.rs +++ b/parsing/src/suggestions.rs @@ -29,7 +29,7 @@ pub fn split_function(input: &str, split: SplitType) -> Vec { .collect::>() } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Debug, Copy, Clone)] pub enum SplitType { Multiplication, Term, @@ -279,7 +279,7 @@ include!(concat!(env!("OUT_DIR"), "/codegen.rs")); #[cfg(test)] fn assert_test(input: &str, expected: &[&str], split: SplitType) { - let output = split_function("sin(x)cos(x)", SplitType::Multiplication); + let output = split_function(input, split); let expected_owned = expected .iter() .map(|&x| x.to_owned()) @@ -305,4 +305,10 @@ fn split_function_test() { &["tanh(cos(x)", "x", "x)", "cos(x)"], SplitType::Multiplication, ); + + assert_test( + "tanh(sin(cos(x)xsin(x)))", + &["tanh(sin(cos(x)", "x", "sin(x)))"], + SplitType::Multiplication, + ); }