Fix tests for rename
This commit is contained in:
parent
3a4dce084e
commit
6f337a7379
6 changed files with 80 additions and 72 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,5 +1,5 @@
|
||||||
/target
|
/target
|
||||||
**/target
|
**/target
|
||||||
/*/metadata.mps.sqlite
|
/*/metadata.muss.sqlite
|
||||||
metadata.mps.sqlite
|
metadata.muss.sqlite
|
||||||
**.m3u8
|
**.m3u8
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub const DEFAULT_SQLITE_FILEPATH: &str = "metadata.sqlite";
|
pub const DEFAULT_SQLITE_FILEPATH: &str = "metadata.muss.sqlite";
|
||||||
|
|
||||||
pub trait DatabaseObj: Sized {
|
pub trait DatabaseObj: Sized {
|
||||||
fn map_row(row: &rusqlite::Row) -> rusqlite::Result<Self>;
|
fn map_row(row: &rusqlite::Row) -> rusqlite::Result<Self>;
|
||||||
|
|
|
@ -338,14 +338,22 @@ pub trait FilesystemQuerier: Debug {
|
||||||
#[cfg(feature = "shellexpand")]
|
#[cfg(feature = "shellexpand")]
|
||||||
match folder {
|
match folder {
|
||||||
Some(path) => Ok(Some(
|
Some(path) => Ok(Some(
|
||||||
shellexpand::full(path)
|
shellexpand::full(self.canonicalize(path))
|
||||||
.map_err(|e| RuntimeMsg(format!("Path expansion error: {}", e)))?
|
.map_err(|e| RuntimeMsg(format!("Path expansion error: {}", e)))?
|
||||||
.into_owned(),
|
.into_owned(),
|
||||||
)),
|
)),
|
||||||
None => Ok(None),
|
None => Ok(None),
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "shellexpand"))]
|
#[cfg(not(feature = "shellexpand"))]
|
||||||
Ok(folder.and_then(|s| Some(s.to_string())))
|
Ok(folder.and_then(|s| Some(self.canonicalize(s).to_string())))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn canonicalize<'a>(&self, path: &'a str) -> &'a str {
|
||||||
|
if let Some(new_path) = path.strip_prefix("file://") {
|
||||||
|
new_path
|
||||||
|
} else {
|
||||||
|
path
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#[cfg(feature = "music_library")]
|
#[cfg(feature = "music_library")]
|
||||||
mod music_lib_test {
|
mod music_lib_test {
|
||||||
use mps_interpreter::music::*;
|
use muss_interpreter::music::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn generate_library() {
|
fn generate_library() {
|
||||||
let mut lib = MpsLibrary::new();
|
let mut lib = Library::new();
|
||||||
lib.read_path("/home/ngnius/Music", 10).unwrap();
|
lib.read_path("/home/ngnius/Music", 10).unwrap();
|
||||||
println!("generated library size: {}", lib.len());
|
println!("generated library size: {}", lib.len());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
//! Integration tests for every syntax feature
|
//! Integration tests for every syntax feature
|
||||||
|
|
||||||
use mps_interpreter::tokens::{MpsToken, MpsTokenizer, ParseError};
|
use muss_interpreter::tokens::{Token, Tokenizer, ParseError};
|
||||||
use mps_interpreter::*;
|
use muss_interpreter::*;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_line() -> Result<(), ParseError> {
|
fn parse_line() -> Result<(), ParseError> {
|
||||||
let cursor = Cursor::new("sql(`SELECT * FROM songs;`)");
|
let cursor = Cursor::new("sql(`SELECT * FROM songs;`)");
|
||||||
let correct_tokens: Vec<MpsToken> = vec![
|
let correct_tokens: Vec<Token> = vec![
|
||||||
MpsToken::Name("sql".into()),
|
Token::Name("sql".into()),
|
||||||
MpsToken::OpenBracket,
|
Token::OpenBracket,
|
||||||
MpsToken::Literal("SELECT * FROM songs;".into()),
|
Token::Literal("SELECT * FROM songs;".into()),
|
||||||
MpsToken::CloseBracket,
|
Token::CloseBracket,
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut tokenizer = MpsTokenizer::new(cursor);
|
let mut tokenizer = Tokenizer::new(cursor);
|
||||||
let mut buf = VecDeque::<MpsToken>::new();
|
let mut buf = VecDeque::<Token>::new();
|
||||||
tokenizer.read_line(&mut buf)?; // operation being tested
|
tokenizer.read_line(&mut buf)?; // operation being tested
|
||||||
|
|
||||||
// debug output
|
// debug output
|
||||||
|
@ -44,7 +44,7 @@ fn execute_single_line(
|
||||||
line: &str,
|
line: &str,
|
||||||
should_be_emtpy: bool,
|
should_be_emtpy: bool,
|
||||||
should_complete: bool,
|
should_complete: bool,
|
||||||
) -> Result<(), MpsError> {
|
) -> Result<(), InterpreterError> {
|
||||||
if line.contains('\n') {
|
if line.contains('\n') {
|
||||||
println!(
|
println!(
|
||||||
"--- Executing MPS code ---\n{}\n--- Executing MPS code ---",
|
"--- Executing MPS code ---\n{}\n--- Executing MPS code ---",
|
||||||
|
@ -55,8 +55,8 @@ fn execute_single_line(
|
||||||
}
|
}
|
||||||
let cursor = Cursor::new(line);
|
let cursor = Cursor::new(line);
|
||||||
|
|
||||||
let tokenizer = MpsTokenizer::new(cursor);
|
let tokenizer = Tokenizer::new(cursor);
|
||||||
let interpreter = MpsFaye::with_standard_vocab(tokenizer);
|
let interpreter = Interpreter::with_standard_vocab(tokenizer);
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for result in interpreter {
|
for result in interpreter {
|
||||||
|
@ -109,23 +109,23 @@ fn execute_single_line(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_sql_line() -> Result<(), MpsError> {
|
fn execute_sql_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line("sql(`SELECT * FROM songs ORDER BY artist;`)", false, true)
|
execute_single_line("sql(`SELECT * FROM songs ORDER BY artist;`)", false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_simple_sql_line() -> Result<(), MpsError> {
|
fn execute_simple_sql_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line("song(`lov`)", false, true)
|
execute_single_line("song(`lov`)", false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_comment_line() -> Result<(), MpsError> {
|
fn execute_comment_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line("// this is a comment", true, true)?;
|
execute_single_line("// this is a comment", true, true)?;
|
||||||
execute_single_line("# this is a special comment", true, true)
|
execute_single_line("# this is a special comment", true, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_repeat_line() -> Result<(), MpsError> {
|
fn execute_repeat_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"repeat(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`))",
|
"repeat(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`))",
|
||||||
false,
|
false,
|
||||||
|
@ -144,7 +144,7 @@ fn execute_repeat_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_sql_init_line() -> Result<(), MpsError> {
|
fn execute_sql_init_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"sql_init(generate = false, folder = `/home/ngnius/Music`)",
|
"sql_init(generate = false, folder = `/home/ngnius/Music`)",
|
||||||
true,
|
true,
|
||||||
|
@ -153,7 +153,7 @@ fn execute_sql_init_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_assign_line() -> Result<(), MpsError> {
|
fn execute_assign_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"let some_var = repeat(song(`Christmas in L.A.`))",
|
"let some_var = repeat(song(`Christmas in L.A.`))",
|
||||||
true,
|
true,
|
||||||
|
@ -163,7 +163,7 @@ fn execute_assign_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_emptyfilter_line() -> Result<(), MpsError> {
|
fn execute_emptyfilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).().().()",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).().().()",
|
||||||
false,
|
false,
|
||||||
|
@ -172,7 +172,7 @@ fn execute_emptyfilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_fieldfilter_line() -> Result<(), MpsError> {
|
fn execute_fieldfilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(year >= 2000)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(year >= 2000)",
|
||||||
false,
|
false,
|
||||||
|
@ -196,7 +196,7 @@ fn execute_fieldfilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_fieldfiltermaybe_line() -> Result<(), MpsError> {
|
fn execute_fieldfiltermaybe_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(year? >= 2000)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(year? >= 2000)",
|
||||||
false,
|
false,
|
||||||
|
@ -220,7 +220,7 @@ fn execute_fieldfiltermaybe_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_files_line() -> Result<(), MpsError> {
|
fn execute_files_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
r"files(folder=`~/Music/MusicFlac/Bruno Mars/24K Magic/`, re=``, recursive=false)",
|
r"files(folder=`~/Music/MusicFlac/Bruno Mars/24K Magic/`, re=``, recursive=false)",
|
||||||
false,
|
false,
|
||||||
|
@ -235,7 +235,7 @@ fn execute_files_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_indexfilter_line() -> Result<(), MpsError> {
|
fn execute_indexfilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(2)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(2)",
|
||||||
false,
|
false,
|
||||||
|
@ -259,7 +259,7 @@ fn execute_indexfilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_rangefilter_line() -> Result<(), MpsError> {
|
fn execute_rangefilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(..)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(..)",
|
||||||
false,
|
false,
|
||||||
|
@ -283,7 +283,7 @@ fn execute_rangefilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_orfilter_line() -> Result<(), MpsError> {
|
fn execute_orfilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(4 || 5)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(4 || 5)",
|
||||||
false,
|
false,
|
||||||
|
@ -302,7 +302,7 @@ fn execute_orfilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_replacefilter_line() -> Result<(), MpsError> {
|
fn execute_replacefilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(if 4: files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(5))",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(if 4: files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(5))",
|
||||||
false,
|
false,
|
||||||
|
@ -321,7 +321,7 @@ fn execute_replacefilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_emptysort_line() -> Result<(), MpsError> {
|
fn execute_emptysort_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).sort()",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).sort()",
|
||||||
false,
|
false,
|
||||||
|
@ -335,7 +335,7 @@ fn execute_emptysort_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_likefilter_line() -> Result<(), MpsError> {
|
fn execute_likefilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(not_a_field? like `24K Magic`)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(not_a_field? like `24K Magic`)",
|
||||||
true,
|
true,
|
||||||
|
@ -359,7 +359,7 @@ fn execute_likefilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_fieldsort_line() -> Result<(), MpsError> {
|
fn execute_fieldsort_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(title)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(title)",
|
||||||
false,
|
false,
|
||||||
|
@ -373,7 +373,7 @@ fn execute_fieldsort_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_blissfirstsort_line() -> Result<(), MpsError> {
|
fn execute_blissfirstsort_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(advanced bliss_first)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(advanced bliss_first)",
|
||||||
false,
|
false,
|
||||||
|
@ -382,7 +382,7 @@ fn execute_blissfirstsort_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_blissnextsort_line() -> Result<(), MpsError> {
|
fn execute_blissnextsort_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(advanced bliss_next)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(advanced bliss_next)",
|
||||||
false,
|
false,
|
||||||
|
@ -391,17 +391,17 @@ fn execute_blissnextsort_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_emptyfn_line() -> Result<(), MpsError> {
|
fn execute_emptyfn_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line("empty()", true, true)
|
execute_single_line("empty()", true, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_resetfn_line() -> Result<(), MpsError> {
|
fn execute_resetfn_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line("reset(empty())", true, true)
|
execute_single_line("reset(empty())", true, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_shufflesort_line() -> Result<(), MpsError> {
|
fn execute_shufflesort_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(random shuffle)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`)~(random shuffle)",
|
||||||
false,
|
false,
|
||||||
|
@ -416,7 +416,7 @@ fn execute_shufflesort_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_unionfn_line() -> Result<(), MpsError> {
|
fn execute_unionfn_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"union(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`))",
|
"union(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`))",
|
||||||
false,
|
false,
|
||||||
|
@ -440,7 +440,7 @@ fn execute_unionfn_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_regexfilter_line() -> Result<(), MpsError> {
|
fn execute_regexfilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(title matches `24K\\\\s+Magic`)", // note: quad-escape not required in scripts
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(title matches `24K\\\\s+Magic`)", // note: quad-escape not required in scripts
|
||||||
false,
|
false,
|
||||||
|
@ -460,7 +460,7 @@ fn execute_regexfilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_intersectionfn_line() -> Result<(), MpsError> {
|
fn execute_intersectionfn_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"intersection(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`))",
|
"intersection(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`))",
|
||||||
false,
|
false,
|
||||||
|
@ -484,7 +484,7 @@ fn execute_intersectionfn_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_declareitemop_line() -> Result<(), MpsError> {
|
fn execute_declareitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{let x = empty()}",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{let x = empty()}",
|
||||||
false,
|
false,
|
||||||
|
@ -493,7 +493,7 @@ fn execute_declareitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_removeitemop_line() -> Result<(), MpsError> {
|
fn execute_removeitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{remove item.title, remove item}",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{remove item.title, remove item}",
|
||||||
true,
|
true,
|
||||||
|
@ -502,7 +502,7 @@ fn execute_removeitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_multiitemop_line() -> Result<(), MpsError> {
|
fn execute_multiitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
let x = empty(),
|
let x = empty(),
|
||||||
|
@ -515,7 +515,7 @@ fn execute_multiitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_fieldassignitemop_line() -> Result<(), MpsError> {
|
fn execute_fieldassignitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.potato = empty(),
|
item.potato = empty(),
|
||||||
|
@ -527,7 +527,7 @@ fn execute_fieldassignitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_constitemop_line() -> Result<(), MpsError> {
|
fn execute_constitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
`str const`,
|
`str const`,
|
||||||
|
@ -542,7 +542,7 @@ fn execute_constitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_retrieveitemop_line() -> Result<(), MpsError> {
|
fn execute_retrieveitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.path = item.filename,
|
item.path = item.filename,
|
||||||
|
@ -555,7 +555,7 @@ fn execute_retrieveitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_additemop_line() -> Result<(), MpsError> {
|
fn execute_additemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.title = `TEST` + item.title,
|
item.title = `TEST` + item.title,
|
||||||
|
@ -567,7 +567,7 @@ fn execute_additemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_subtractitemop_line() -> Result<(), MpsError> {
|
fn execute_subtractitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.test = 1234 - 94,
|
item.test = 1234 - 94,
|
||||||
|
@ -578,7 +578,7 @@ fn execute_subtractitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_negateitemop_line() -> Result<(), MpsError> {
|
fn execute_negateitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.test = 1234,
|
item.test = 1234,
|
||||||
|
@ -591,7 +591,7 @@ fn execute_negateitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_notitemop_line() -> Result<(), MpsError> {
|
fn execute_notitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.test = false,
|
item.test = false,
|
||||||
|
@ -604,7 +604,7 @@ fn execute_notitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_orlogicalitemop_line() -> Result<(), MpsError> {
|
fn execute_orlogicalitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.test = true || true,
|
item.test = true || true,
|
||||||
|
@ -616,7 +616,7 @@ fn execute_orlogicalitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_andlogicalitemop_line() -> Result<(), MpsError> {
|
fn execute_andlogicalitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.test = true && true,
|
item.test = true && true,
|
||||||
|
@ -628,7 +628,7 @@ fn execute_andlogicalitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_bracketsitemop_line() -> Result<(), MpsError> {
|
fn execute_bracketsitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.test = true && true && (false || false),
|
item.test = true && true && (false || false),
|
||||||
|
@ -640,7 +640,7 @@ fn execute_bracketsitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_stringifyitemop_line() -> Result<(), MpsError> {
|
fn execute_stringifyitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.filepath = ~`test out: {test}` item,
|
item.filepath = ~`test out: {test}` item,
|
||||||
|
@ -654,7 +654,7 @@ fn execute_stringifyitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_branchitemop_line() -> Result<(), MpsError> {
|
fn execute_branchitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
if false {
|
if false {
|
||||||
|
@ -672,7 +672,7 @@ fn execute_branchitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_compareitemop_line() -> Result<(), MpsError> {
|
fn execute_compareitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
if 42 != 42 {
|
if 42 != 42 {
|
||||||
|
@ -687,7 +687,7 @@ fn execute_compareitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_computeitemop_line() -> Result<(), MpsError> {
|
fn execute_computeitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
let count = 1,
|
let count = 1,
|
||||||
|
@ -706,7 +706,7 @@ fn execute_computeitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_complexitemop_line() -> Result<(), MpsError> {
|
fn execute_complexitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).().{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).().{
|
||||||
let count = 1,
|
let count = 1,
|
||||||
|
@ -725,7 +725,7 @@ fn execute_complexitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_constructitemop_line() -> Result<(), MpsError> {
|
fn execute_constructitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
let other_item = Item (),
|
let other_item = Item (),
|
||||||
|
@ -743,7 +743,7 @@ fn execute_constructitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_iteritemop_line() -> Result<(), MpsError> {
|
fn execute_iteritemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item = iter empty()
|
item = iter empty()
|
||||||
|
@ -754,7 +754,7 @@ fn execute_iteritemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_commentitemop_line() -> Result<(), MpsError> {
|
fn execute_commentitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"empty().{
|
"empty().{
|
||||||
// this is a comment
|
// this is a comment
|
||||||
|
@ -767,7 +767,7 @@ fn execute_commentitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_uniquefieldfilter_line() -> Result<(), MpsError> {
|
fn execute_uniquefieldfilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"repeat(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`), 3).(unique title?)",
|
"repeat(files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`), 3).(unique title?)",
|
||||||
false,
|
false,
|
||||||
|
@ -786,7 +786,7 @@ fn execute_uniquefieldfilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_uniquefilter_line() -> Result<(), MpsError> {
|
fn execute_uniquefilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(unique)",
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(unique)",
|
||||||
false,
|
false,
|
||||||
|
@ -795,7 +795,7 @@ fn execute_uniquefilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_fileitemop_line() -> Result<(), MpsError> {
|
fn execute_fileitemop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
item.title = `something else`,
|
item.title = `something else`,
|
||||||
|
@ -807,7 +807,7 @@ fn execute_fileitemop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_emptiesop_line() -> Result<(), MpsError> {
|
fn execute_emptiesop_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"empties(1).{let count = 0, item.title = ~`title #{}` count+1, item.filename = ~`filename_{}` count, count = count + 1}",
|
"empties(1).{let count = 0, item.title = ~`title #{}` count+1, item.filename = ~`filename_{}` count, count = count + 1}",
|
||||||
false,
|
false,
|
||||||
|
@ -822,7 +822,7 @@ fn execute_emptiesop_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_nonemptyfilter_line() -> Result<(), MpsError> {
|
fn execute_nonemptyfilter_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files().(??)",
|
"files().(??)",
|
||||||
false,
|
false,
|
||||||
|
@ -836,7 +836,7 @@ fn execute_nonemptyfilter_line() -> Result<(), MpsError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_mpdfunction_line() -> Result<(), MpsError> {
|
fn execute_mpdfunction_line() -> Result<(), InterpreterError> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"mpd(`127.0.0.1:6600`, artist=`Bruno Mars`)",
|
"mpd(`127.0.0.1:6600`, artist=`Bruno Mars`)",
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -275,7 +275,7 @@ fn music_filename(item: &Item) -> Option<String> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use mps_interpreter::Interpreter;
|
use muss_interpreter::Interpreter;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
Loading…
Reference in a new issue