From 4581fe8fe910694fd4572cd7a4a89a288987ed0a Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Fri, 4 Mar 2022 15:51:04 -0500 Subject: [PATCH] Enumerate error types instead of boxing, make error traits private --- mps-interpreter/README.md | 2 +- mps-interpreter/src/errors.rs | 50 +++++++++++++ mps-interpreter/src/interpretor.rs | 18 +++-- mps-interpreter/src/lang/mod.rs | 3 +- mps-interpreter/src/lib.rs | 4 +- mps-interpreter/src/runner.rs | 6 +- mps-interpreter/src/tokens/mod.rs | 2 +- mps-interpreter/tests/single_line.rs | 102 +++++++++++++-------------- 8 files changed, 119 insertions(+), 68 deletions(-) create mode 100644 mps-interpreter/src/errors.rs diff --git a/mps-interpreter/README.md b/mps-interpreter/README.md index 23cb344..2cbb8cd 100644 --- a/mps-interpreter/README.md +++ b/mps-interpreter/README.md @@ -23,7 +23,7 @@ let interpreter = MpsRunner::with_stream(cursor); // warning: my library has ~3800 songs, so this outputs too much information to be useful. for result in interpreter { match result { - Ok(item) => println!("Got song `{}` (file: `{}`)", item.title, item.filename), + Ok(item) => println!("Got song `{}` (file: `{}`)", item.field("title").unwrap(), item.field("filename").unwrap()), Err(e) => panic!("Got error while executing: {}", e), } } diff --git a/mps-interpreter/src/errors.rs b/mps-interpreter/src/errors.rs new file mode 100644 index 0000000..bf04b6a --- /dev/null +++ b/mps-interpreter/src/errors.rs @@ -0,0 +1,50 @@ +use std::fmt::{Debug, Display, Error, Formatter}; +use std::convert::From; + +use crate::lang::{SyntaxError, RuntimeError, MpsLanguageError}; +use crate::tokens::ParseError; + +#[derive(Debug)] +pub enum MpsError { + Syntax(SyntaxError), + Runtime(RuntimeError), + Parse(ParseError), +} + +impl Display for MpsError { + fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { + match self { + Self::Syntax(e) => (e as &dyn Display).fmt(f), + Self::Runtime(e) => (e as &dyn Display).fmt(f), + Self::Parse(e) => (e as &dyn Display).fmt(f), + } + } +} + +impl MpsLanguageError for MpsError { + fn set_line(&mut self, line: usize) { + match self { + Self::Syntax(e) => e.set_line(line), + Self::Runtime(e) => e.set_line(line), + Self::Parse(e) => e.set_line(line), + } + } +} + +impl From for MpsError { + fn from(e: SyntaxError) -> Self { + Self::Syntax(e) + } +} + +impl From for MpsError { + fn from(e: RuntimeError) -> Self { + Self::Runtime(e) + } +} + +impl From for MpsError { + fn from(e: ParseError) -> Self { + Self::Parse(e) + } +} diff --git a/mps-interpreter/src/interpretor.rs b/mps-interpreter/src/interpretor.rs index 4bebef0..183d04a 100644 --- a/mps-interpreter/src/interpretor.rs +++ b/mps-interpreter/src/interpretor.rs @@ -7,6 +7,7 @@ use super::lang::{MpsLanguageDictionary, MpsLanguageError, MpsOp}; use super::tokens::MpsToken; use super::MpsContext; use super::MpsItem; +use super::MpsError; /// The script interpreter. /// Use MpsRunner for a better interface. @@ -81,7 +82,7 @@ impl Iterator for MpsInterpretor where T: crate::tokens::MpsTokenReader, { - type Item = Result>; + type Item = Result; fn next(&mut self) -> Option { let mut is_stmt_done = false; @@ -91,7 +92,7 @@ where is_stmt_done = true; } next_item - .map(|item| item.map_err(|e| box_error_with_ctx(e, self.tokenizer.current_line()))) + .map(|item| item.map_err(|e| error_with_ctx(e.into(), self.tokenizer.current_line()))) } else { /*if self.tokenizer.end_of_file() { return None; @@ -101,7 +102,7 @@ where let token_result = self .tokenizer .next_statement(&mut self.buffer) - .map_err(|e| box_error_with_ctx(e, self.tokenizer.current_line())); + .map_err(|e| error_with_ctx(e.into(), self.tokenizer.current_line())); match token_result { Ok(_) => {} Err(x) => return Some(Err(x)), @@ -123,11 +124,11 @@ where is_stmt_done = true; } next_item.map(|item| { - item.map_err(|e| box_error_with_ctx(e, self.tokenizer.current_line())) + item.map_err(|e| error_with_ctx(e.into(), self.tokenizer.current_line())) }) } Err(e) => { - Some(Err(e).map_err(|e| box_error_with_ctx(e, self.tokenizer.current_line()))) + Some(Err(e).map_err(|e| error_with_ctx(e.into(), self.tokenizer.current_line()))) } } }; @@ -138,12 +139,9 @@ where } } -fn box_error_with_ctx( - mut error: E, - line: usize, -) -> Box { +fn error_with_ctx(mut error: MpsError, line: usize) -> MpsError { error.set_line(line); - Box::new(error) as Box + error } /// Builder function to add the standard statements of MPS. diff --git a/mps-interpreter/src/lang/mod.rs b/mps-interpreter/src/lang/mod.rs index b71f1ad..5b0662b 100644 --- a/mps-interpreter/src/lang/mod.rs +++ b/mps-interpreter/src/lang/mod.rs @@ -16,7 +16,8 @@ mod type_primitives; pub(crate) mod utility; pub use dictionary::MpsLanguageDictionary; -pub use error::{MpsLanguageError, RuntimeError, RuntimeMsg, RuntimeOp, SyntaxError}; +pub use error::{RuntimeError, RuntimeMsg, RuntimeOp, SyntaxError}; +pub(crate) use error::MpsLanguageError; pub use filter::{ MpsFilterFactory, MpsFilterPredicate, MpsFilterStatement, MpsFilterStatementFactory, }; diff --git a/mps-interpreter/src/lib.rs b/mps-interpreter/src/lib.rs index 2c67b8c..5f2c326 100644 --- a/mps-interpreter/src/lib.rs +++ b/mps-interpreter/src/lib.rs @@ -21,7 +21,7 @@ //! // warning: my library has ~3800 songs, so this outputs too much information to be useful. //! for result in interpreter { //! match result { -//! Ok(item) => println!("Got song `{}` (file: `{}`)", item.title, item.filename), +//! Ok(item) => println!("Got song `{}` (file: `{}`)", item.field("title").unwrap(), item.field("filename").unwrap()), //! Err(e) => panic!("Got error while executing: {}", e), //! } //! } @@ -240,6 +240,7 @@ //! mod context; +mod errors; mod interpretor; mod item; pub mod lang; @@ -251,6 +252,7 @@ mod runner; pub mod tokens; pub use context::MpsContext; +pub use errors::MpsError; pub use interpretor::{interpretor, MpsInterpretor}; pub use item::MpsItem; //pub(crate) use item::MpsItemRuntimeUtil; diff --git a/mps-interpreter/src/runner.rs b/mps-interpreter/src/runner.rs index 280e8ac..83cdf23 100644 --- a/mps-interpreter/src/runner.rs +++ b/mps-interpreter/src/runner.rs @@ -1,9 +1,9 @@ use std::io::Read; use std::iter::Iterator; -use super::lang::{MpsLanguageDictionary, MpsLanguageError}; +use super::lang::MpsLanguageDictionary; use super::tokens::{MpsTokenReader, MpsTokenizer}; -use super::{MpsContext, MpsInterpretor, MpsItem}; +use super::{MpsContext, MpsInterpretor, MpsItem, MpsError}; pub struct MpsRunnerSettings { pub vocabulary: MpsLanguageDictionary, @@ -57,7 +57,7 @@ impl MpsRunner> { } impl Iterator for MpsRunner { - type Item = Result>; + type Item = Result; fn next(&mut self) -> Option { let mut item = self.interpretor.next(); diff --git a/mps-interpreter/src/tokens/mod.rs b/mps-interpreter/src/tokens/mod.rs index e226a24..9a6ab99 100644 --- a/mps-interpreter/src/tokens/mod.rs +++ b/mps-interpreter/src/tokens/mod.rs @@ -2,6 +2,6 @@ mod error; mod token_enum; mod tokenizer; -pub use error::{MpsTokenError, ParseError}; +pub use error::ParseError; pub use token_enum::MpsToken; pub use tokenizer::{MpsTokenReader, MpsTokenizer}; diff --git a/mps-interpreter/tests/single_line.rs b/mps-interpreter/tests/single_line.rs index a7fa2c8..cff6ab4 100644 --- a/mps-interpreter/tests/single_line.rs +++ b/mps-interpreter/tests/single_line.rs @@ -1,4 +1,4 @@ -use mps_interpreter::lang::MpsLanguageError; +use mps_interpreter::MpsError; use mps_interpreter::tokens::{MpsToken, MpsTokenizer, ParseError}; use mps_interpreter::*; use std::collections::VecDeque; @@ -43,7 +43,7 @@ fn execute_single_line( line: &str, should_be_emtpy: bool, should_complete: bool, -) -> Result<(), Box> { +) -> Result<(), MpsError> { if line.contains('\n') { println!( "--- Executing MPS code ---\n{}\n--- Executing MPS code ---", @@ -108,23 +108,23 @@ fn execute_single_line( } #[test] -fn execute_sql_line() -> Result<(), Box> { +fn execute_sql_line() -> Result<(), MpsError> { execute_single_line("sql(`SELECT * FROM songs ORDER BY artist;`)", false, true) } #[test] -fn execute_simple_sql_line() -> Result<(), Box> { +fn execute_simple_sql_line() -> Result<(), MpsError> { execute_single_line("song(`lov`)", false, true) } #[test] -fn execute_comment_line() -> Result<(), Box> { +fn execute_comment_line() -> Result<(), MpsError> { execute_single_line("// this is a comment", true, true)?; execute_single_line("# this is a special comment", true, true) } #[test] -fn execute_repeat_line() -> Result<(), Box> { +fn execute_repeat_line() -> Result<(), MpsError> { execute_single_line( "repeat(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`))", false, @@ -143,7 +143,7 @@ fn execute_repeat_line() -> Result<(), Box> { } #[test] -fn execute_sql_init_line() -> Result<(), Box> { +fn execute_sql_init_line() -> Result<(), MpsError> { execute_single_line( "sql_init(generate = false, folder = `/home/ngnius/Music`)", true, @@ -152,7 +152,7 @@ fn execute_sql_init_line() -> Result<(), Box> { } #[test] -fn execute_assign_line() -> Result<(), Box> { +fn execute_assign_line() -> Result<(), MpsError> { execute_single_line( "let some_var = repeat(song(`Christmas in L.A.`))", true, @@ -162,7 +162,7 @@ fn execute_assign_line() -> Result<(), Box> { } #[test] -fn execute_emptyfilter_line() -> Result<(), Box> { +fn execute_emptyfilter_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).().().()", false, @@ -171,7 +171,7 @@ fn execute_emptyfilter_line() -> Result<(), Box> { } #[test] -fn execute_fieldfilter_line() -> Result<(), Box> { +fn execute_fieldfilter_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(year >= 2000)", false, @@ -195,7 +195,7 @@ fn execute_fieldfilter_line() -> Result<(), Box> { } #[test] -fn execute_fieldfiltermaybe_line() -> Result<(), Box> { +fn execute_fieldfiltermaybe_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(year? >= 2000)", false, @@ -219,7 +219,7 @@ fn execute_fieldfiltermaybe_line() -> Result<(), Box> { } #[test] -fn execute_files_line() -> Result<(), Box> { +fn execute_files_line() -> Result<(), MpsError> { execute_single_line( r"files(folder=`~/Music/MusicFlac/Bruno Mars/24K Magic/`, re=``, recursive=false)", false, @@ -234,7 +234,7 @@ fn execute_files_line() -> Result<(), Box> { } #[test] -fn execute_indexfilter_line() -> Result<(), Box> { +fn execute_indexfilter_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(2)", false, @@ -258,7 +258,7 @@ fn execute_indexfilter_line() -> Result<(), Box> { } #[test] -fn execute_rangefilter_line() -> Result<(), Box> { +fn execute_rangefilter_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(..)", false, @@ -282,7 +282,7 @@ fn execute_rangefilter_line() -> Result<(), Box> { } #[test] -fn execute_orfilter_line() -> Result<(), Box> { +fn execute_orfilter_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(4 || 5)", false, @@ -301,7 +301,7 @@ fn execute_orfilter_line() -> Result<(), Box> { } #[test] -fn execute_replacefilter_line() -> Result<(), Box> { +fn execute_replacefilter_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(if 4: files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(5))", false, @@ -320,7 +320,7 @@ fn execute_replacefilter_line() -> Result<(), Box> { } #[test] -fn execute_emptysort_line() -> Result<(), Box> { +fn execute_emptysort_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).sort()", false, @@ -334,7 +334,7 @@ fn execute_emptysort_line() -> Result<(), Box> { } #[test] -fn execute_likefilter_line() -> Result<(), Box> { +fn execute_likefilter_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(not_a_field? like `24K Magic`)", true, @@ -353,7 +353,7 @@ fn execute_likefilter_line() -> Result<(), Box> { } #[test] -fn execute_fieldsort_line() -> Result<(), Box> { +fn execute_fieldsort_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(title)", false, @@ -367,7 +367,7 @@ fn execute_fieldsort_line() -> Result<(), Box> { } #[test] -fn execute_blissfirstsort_line() -> Result<(), Box> { +fn execute_blissfirstsort_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(advanced bliss_first)", false, @@ -376,7 +376,7 @@ fn execute_blissfirstsort_line() -> Result<(), Box> { } #[test] -fn execute_blissnextsort_line() -> Result<(), Box> { +fn execute_blissnextsort_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(advanced bliss_next)", false, @@ -385,17 +385,17 @@ fn execute_blissnextsort_line() -> Result<(), Box> { } #[test] -fn execute_emptyfn_line() -> Result<(), Box> { +fn execute_emptyfn_line() -> Result<(), MpsError> { execute_single_line("empty()", true, true) } #[test] -fn execute_resetfn_line() -> Result<(), Box> { +fn execute_resetfn_line() -> Result<(), MpsError> { execute_single_line("reset(empty())", true, true) } #[test] -fn execute_shufflesort_line() -> Result<(), Box> { +fn execute_shufflesort_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(random shuffle)", false, @@ -410,7 +410,7 @@ fn execute_shufflesort_line() -> Result<(), Box> { } #[test] -fn execute_unionfn_line() -> Result<(), Box> { +fn execute_unionfn_line() -> Result<(), MpsError> { execute_single_line( "union(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`))", false, @@ -434,7 +434,7 @@ fn execute_unionfn_line() -> Result<(), Box> { } #[test] -fn execute_regexfilter_line() -> Result<(), Box> { +fn execute_regexfilter_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(title matches `24K\\\\s+Magic`)", // note: quad-escape not required in scripts false, @@ -448,7 +448,7 @@ fn execute_regexfilter_line() -> Result<(), Box> { } #[test] -fn execute_intersectionfn_line() -> Result<(), Box> { +fn execute_intersectionfn_line() -> Result<(), MpsError> { execute_single_line( "intersection(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`))", false, @@ -472,7 +472,7 @@ fn execute_intersectionfn_line() -> Result<(), Box> { } #[test] -fn execute_declareitemop_line() -> Result<(), Box> { +fn execute_declareitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{let x = empty()}", false, @@ -481,7 +481,7 @@ fn execute_declareitemop_line() -> Result<(), Box> { } #[test] -fn execute_removeitemop_line() -> Result<(), Box> { +fn execute_removeitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{remove item.title, remove item}", true, @@ -490,7 +490,7 @@ fn execute_removeitemop_line() -> Result<(), Box> { } #[test] -fn execute_multiitemop_line() -> Result<(), Box> { +fn execute_multiitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ let x = empty(), @@ -503,7 +503,7 @@ fn execute_multiitemop_line() -> Result<(), Box> { } #[test] -fn execute_fieldassignitemop_line() -> Result<(), Box> { +fn execute_fieldassignitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.potato = empty(), @@ -515,7 +515,7 @@ fn execute_fieldassignitemop_line() -> Result<(), Box> { } #[test] -fn execute_constitemop_line() -> Result<(), Box> { +fn execute_constitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ `str const`, @@ -530,7 +530,7 @@ fn execute_constitemop_line() -> Result<(), Box> { } #[test] -fn execute_retrieveitemop_line() -> Result<(), Box> { +fn execute_retrieveitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.path = item.filename, @@ -543,7 +543,7 @@ fn execute_retrieveitemop_line() -> Result<(), Box> { } #[test] -fn execute_additemop_line() -> Result<(), Box> { +fn execute_additemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.title = `TEST` + item.title, @@ -555,7 +555,7 @@ fn execute_additemop_line() -> Result<(), Box> { } #[test] -fn execute_subtractitemop_line() -> Result<(), Box> { +fn execute_subtractitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.test = 1234 - 94, @@ -566,7 +566,7 @@ fn execute_subtractitemop_line() -> Result<(), Box> { } #[test] -fn execute_negateitemop_line() -> Result<(), Box> { +fn execute_negateitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.test = 1234, @@ -579,7 +579,7 @@ fn execute_negateitemop_line() -> Result<(), Box> { } #[test] -fn execute_notitemop_line() -> Result<(), Box> { +fn execute_notitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.test = false, @@ -592,7 +592,7 @@ fn execute_notitemop_line() -> Result<(), Box> { } #[test] -fn execute_orlogicalitemop_line() -> Result<(), Box> { +fn execute_orlogicalitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.test = true || true, @@ -604,7 +604,7 @@ fn execute_orlogicalitemop_line() -> Result<(), Box> { } #[test] -fn execute_andlogicalitemop_line() -> Result<(), Box> { +fn execute_andlogicalitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.test = true && true, @@ -616,7 +616,7 @@ fn execute_andlogicalitemop_line() -> Result<(), Box> { } #[test] -fn execute_bracketsitemop_line() -> Result<(), Box> { +fn execute_bracketsitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.test = true && true && (false || false), @@ -628,7 +628,7 @@ fn execute_bracketsitemop_line() -> Result<(), Box> { } #[test] -fn execute_stringifyitemop_line() -> Result<(), Box> { +fn execute_stringifyitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.filepath = ~`test out: {test}` item, @@ -642,7 +642,7 @@ fn execute_stringifyitemop_line() -> Result<(), Box> { } #[test] -fn execute_branchitemop_line() -> Result<(), Box> { +fn execute_branchitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ if false { @@ -660,7 +660,7 @@ fn execute_branchitemop_line() -> Result<(), Box> { } #[test] -fn execute_compareitemop_line() -> Result<(), Box> { +fn execute_compareitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ if 42 != 42 { @@ -675,7 +675,7 @@ fn execute_compareitemop_line() -> Result<(), Box> { } #[test] -fn execute_computeitemop_line() -> Result<(), Box> { +fn execute_computeitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ let count = 1, @@ -694,7 +694,7 @@ fn execute_computeitemop_line() -> Result<(), Box> { } #[test] -fn execute_complexitemop_line() -> Result<(), Box> { +fn execute_complexitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).().{ let count = 1, @@ -713,7 +713,7 @@ fn execute_complexitemop_line() -> Result<(), Box> { } #[test] -fn execute_constructitemop_line() -> Result<(), Box> { +fn execute_constructitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ let other_item = Item (), @@ -731,7 +731,7 @@ fn execute_constructitemop_line() -> Result<(), Box> { } #[test] -fn execute_iteritemop_line() -> Result<(), Box> { +fn execute_iteritemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item = iter empty() @@ -742,7 +742,7 @@ fn execute_iteritemop_line() -> Result<(), Box> { } #[test] -fn execute_uniquefieldfilter_line() -> Result<(), Box> { +fn execute_uniquefieldfilter_line() -> Result<(), MpsError> { execute_single_line( "repeat(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`), 3).(unique title?)", false, @@ -761,7 +761,7 @@ fn execute_uniquefieldfilter_line() -> Result<(), Box> { } #[test] -fn execute_uniquefilter_line() -> Result<(), Box> { +fn execute_uniquefilter_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(unique)", false, @@ -770,7 +770,7 @@ fn execute_uniquefilter_line() -> Result<(), Box> { } #[test] -fn execute_fileitemop_line() -> Result<(), Box> { +fn execute_fileitemop_line() -> Result<(), MpsError> { execute_single_line( "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ item.title = `something else`, @@ -782,7 +782,7 @@ fn execute_fileitemop_line() -> Result<(), Box> { } #[test] -fn execute_emptiesop_line() -> Result<(), Box> { +fn execute_emptiesop_line() -> Result<(), MpsError> { execute_single_line( "empties(1).{let count = 0, item.title = ~`title #{}` count+1, item.filename = ~`filename_{}` count, count = count + 1}", false,