Enumerate error types instead of boxing, make error traits private

This commit is contained in:
NGnius (Graham) 2022-03-04 15:51:04 -05:00
parent 6abc3c7783
commit 4581fe8fe9
8 changed files with 119 additions and 68 deletions

View file

@ -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),
}
}

View file

@ -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<SyntaxError> for MpsError {
fn from(e: SyntaxError) -> Self {
Self::Syntax(e)
}
}
impl From<RuntimeError> for MpsError {
fn from(e: RuntimeError) -> Self {
Self::Runtime(e)
}
}
impl From<ParseError> for MpsError {
fn from(e: ParseError) -> Self {
Self::Parse(e)
}
}

View file

@ -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<T> Iterator for MpsInterpretor<T>
where
T: crate::tokens::MpsTokenReader,
{
type Item = Result<MpsItem, Box<dyn MpsLanguageError>>;
type Item = Result<MpsItem, MpsError>;
fn next(&mut self) -> Option<Self::Item> {
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<E: MpsLanguageError + 'static>(
mut error: E,
line: usize,
) -> Box<dyn MpsLanguageError> {
fn error_with_ctx(mut error: MpsError, line: usize) -> MpsError {
error.set_line(line);
Box::new(error) as Box<dyn MpsLanguageError>
error
}
/// Builder function to add the standard statements of MPS.

View file

@ -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,
};

View file

@ -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;

View file

@ -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<T: MpsTokenReader> {
pub vocabulary: MpsLanguageDictionary,
@ -57,7 +57,7 @@ impl<R: Read> MpsRunner<MpsTokenizer<R>> {
}
impl<T: MpsTokenReader> Iterator for MpsRunner<T> {
type Item = Result<MpsItem, Box<dyn MpsLanguageError>>;
type Item = Result<MpsItem, MpsError>;
fn next(&mut self) -> Option<Self::Item> {
let mut item = self.interpretor.next();

View file

@ -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};

View file

@ -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<dyn MpsLanguageError>> {
) -> 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<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
fn execute_simple_sql_line() -> Result<(), MpsError> {
execute_single_line("song(`lov`)", false, true)
}
#[test]
fn execute_comment_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_sql_init_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_assign_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_emptyfilter_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_fieldfilter_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_fieldfiltermaybe_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_files_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_indexfilter_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_rangefilter_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_orfilter_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_replacefilter_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_emptysort_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_likefilter_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_fieldsort_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_blissfirstsort_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_blissnextsort_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_emptyfn_line() -> Result<(), Box<dyn MpsLanguageError>> {
fn execute_emptyfn_line() -> Result<(), MpsError> {
execute_single_line("empty()", true, true)
}
#[test]
fn execute_resetfn_line() -> Result<(), Box<dyn MpsLanguageError>> {
fn execute_resetfn_line() -> Result<(), MpsError> {
execute_single_line("reset(empty())", true, true)
}
#[test]
fn execute_shufflesort_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_unionfn_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_regexfilter_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_intersectionfn_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_declareitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_removeitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_multiitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_fieldassignitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_constitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_retrieveitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_additemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_subtractitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_negateitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_notitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_orlogicalitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_andlogicalitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_bracketsitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_stringifyitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_branchitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_compareitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_computeitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_complexitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_constructitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_iteritemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_uniquefieldfilter_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_uniquefilter_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_fileitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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<dyn MpsLanguageError>> {
}
#[test]
fn execute_emptiesop_line() -> Result<(), Box<dyn MpsLanguageError>> {
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,