add thiserror to edn module; 38.57% total cov

This commit is contained in:
🪞👃🪞 2025-02-26 15:09:44 +02:00
parent 77d617f9a0
commit 3837dbd47b
7 changed files with 66 additions and 36 deletions

25
Cargo.lock generated
View file

@ -1511,6 +1511,7 @@ dependencies = [
"konst", "konst",
"proptest", "proptest",
"tek_tui", "tek_tui",
"thiserror 2.0.11",
] ]
[[package]] [[package]]
@ -1619,7 +1620,16 @@ version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl 1.0.69",
]
[[package]]
name = "thiserror"
version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc"
dependencies = [
"thiserror-impl 2.0.11",
] ]
[[package]] [[package]]
@ -1633,6 +1643,17 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "thiserror-impl"
version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.8.19" version = "0.8.19"
@ -1820,7 +1841,7 @@ dependencies = [
"i24", "i24",
"num-traits", "num-traits",
"paste", "paste",
"thiserror", "thiserror 1.0.69",
] ]
[[package]] [[package]]

View file

@ -7,6 +7,7 @@ version = "0.1.0"
clojure-reader = "0.3.0" clojure-reader = "0.3.0"
konst = { version = "0.3.16", features = [ "rust_1_83" ] } konst = { version = "0.3.16", features = [ "rust_1_83" ] }
itertools = "0.14.0" itertools = "0.14.0"
thiserror = "2.0"
[features] [features]
default = [] default = []

View file

@ -115,3 +115,16 @@ impl<T: Context<U>, U> Context<U> for Option<T> {
} }
}; };
} }
#[cfg(test)] #[test] fn test_edn_context () {
struct Test;
provide_bool!(bool: |self: Test|{
":provide-bool" => true
});
let test = Test;
assert_eq!(test.get(&Value::Sym(":false")), Some(false));
assert_eq!(test.get(&Value::Sym(":true")), Some(true));
assert_eq!(test.get(&Value::Sym(":provide-bool")), Some(true));
assert_eq!(test.get(&Value::Sym(":missing-bool")), None);
assert_eq!(test.get(&Value::Num(0)), Some(false));
assert_eq!(test.get(&Value::Num(1)), Some(true));
}

View file

@ -1,21 +1,15 @@
use crate::*; use crate::*;
use thiserror::Error;
pub type ParseResult<T> = Result<T, ParseError>; pub type ParseResult<T> = Result<T, ParseError>;
#[derive(Debug, Copy, Clone, PartialEq)] pub enum ParseError { #[derive(Error, Debug, Copy, Clone, PartialEq)] pub enum ParseError {
#[error("parse failed: not implemented")]
Unimplemented, Unimplemented,
#[error("parse failed: empty")]
Empty, Empty,
#[error("parse failed: incomplete")]
Incomplete, Incomplete,
#[error("parse failed: unexpected character '{0}'")]
Unexpected(char), Unexpected(char),
#[error("parse failed: error #{0}")]
Code(u8), Code(u8),
} }
impl Error for ParseError {}
impl Display for ParseError {
fn fmt (&self, f: &mut Formatter) -> FormatResult {
match self {
Unimplemented => write!(f, "unimplemented"),
Empty => write!(f, "empty"),
Incomplete => write!(f, "incomplete"),
Unexpected(c) => write!(f, "unexpected '{c}'"),
Code(i) => write!(f, "error #{i}"),
}
}
}

View file

@ -25,5 +25,8 @@ pub(crate) type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
} }
fn done (&self) {} fn done (&self) {}
} }
let _ = TestInput(true).event();
assert!(TestInput(true).is_done());
assert!(!TestInput(false).is_done());
Ok(()) Ok(())
} }

View file

@ -1,24 +1,13 @@
#!/usr/bin/env nix-shell #!/usr/bin/env nix-shell
{pkgs?import<nixpkgs>{}}:let {pkgs?import<nixpkgs>{}}:let
#suil = pkgs.enableDebugging (pkgs.suil.overrideAttrs (a: b: { stdenv = pkgs.clang19Stdenv;
#dontStrip = true; separateDebugInfo = true; name = "tek";
#})); nativeBuildInputs = with pkgs; [ pkg-config freetype libclang ];
in pkgs.mkShell { buildInputs = with pkgs; let
nativeBuildInputs = with pkgs; [ #suil = pkgs.enableDebugging (pkgs.suil.overrideAttrs (a: b: {
pkg-config #dontStrip = true; separateDebugInfo = true;
freetype #}));
libclang in [ jack2 lilv serd libclang /*suil*/ glib gtk3 ];
#bear
];
buildInputs = with pkgs; [
jack2
lilv
serd
libclang
#suil
glib
gtk3
];
VST3_SDK_DIR = "/home/user/Lab/Music/tek/vst3sdk/"; VST3_SDK_DIR = "/home/user/Lab/Music/tek/vst3sdk/";
LIBCLANG_PATH = "${pkgs.libclang.lib.outPath}/lib"; LIBCLANG_PATH = "${pkgs.libclang.lib.outPath}/lib";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (with pkgs; [ LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (with pkgs; [
@ -38,4 +27,8 @@ in pkgs.mkShell {
libglvnd libglvnd
#xorg_sys_opengl #xorg_sys_opengl
]); ]);
in pkgs.mkShell.override {
inherit stdenv;
} {
inherit name nativeBuildInputs buildInputs VST3_SDK_DIR LIBCLANG_PATH LD_LIBRARY_PATH;
} }

View file

@ -1,6 +1,11 @@
use crate::*; use crate::*;
impl Tek { impl Tek {
// FIXME: The memoized arranger is too complex.
// Just render a slice of the arranger for now,
// starting from tracks[scroll_offset] and ending
// at the last track that fits fully.
/// Blit the currently visible section of the arranger view buffer to the output. /// Blit the currently visible section of the arranger view buffer to the output.
/// ///
/// If the arranger is larger than the available display area, /// If the arranger is larger than the available display area,
@ -32,8 +37,8 @@ impl Tek {
/// Draw the full arranger to the arranger view buffer. /// Draw the full arranger to the arranger view buffer.
/// ///
/// This should happen on changes to the arrangement contents, /// This should happen on changes to the arrangement contents,
/// i.e. not on scroll. Scrolling just determines which /// i.e. not on scroll. Scrolling just determines which part
/// part of the arranger buffer to blit in [view_arranger]. /// of the arranger buffer to blit in [view_arranger].
pub fn redraw_arranger (&self) { pub fn redraw_arranger (&self) {
let width = self.w_tracks(); let width = self.w_tracks();
let height = self.h_scenes() + self.h_inputs() + self.h_outputs(); let height = self.h_scenes() + self.h_inputs() + self.h_outputs();