Setup a testing bench

Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
Marcel Müller 2026-03-06 13:56:39 +01:00
parent 4470af3926
commit d3e6410ec0
16 changed files with 336 additions and 4 deletions

View file

@ -15,7 +15,10 @@ pub enum EvaluationError {
ExplicitAbort,
}
pub fn execute(instructions: &[Instruction], global_context: &Context) -> Result<String, EvaluationError> {
pub fn execute(
instructions: &[Instruction],
global_context: &Context,
) -> Result<String, EvaluationError> {
let mut output = String::new();
let mut scopes: HashMap<crate::emit::VariableSlot, serde_json::Value> = HashMap::new();

View file

@ -14,12 +14,31 @@ pub struct TempleInput {
range: Range<usize>,
}
impl TempleInput {
pub fn from_parts(backing: Arc<str>, range: Range<usize>) -> TempleInput {
TempleInput { backing, range }
}
pub fn into_parts(self) -> (Arc<str>, Range<usize>) {
(self.backing, self.range)
}
}
impl std::fmt::Debug for TempleInput {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "\"{}\"", self.as_str())
}
}
impl From<String> for TempleInput {
fn from(value: String) -> Self {
let range = 0..value.len();
let backing = Arc::from(value);
TempleInput { backing, range }
}
}
impl From<&str> for TempleInput {
fn from(value: &str) -> Self {
let backing = Arc::from(value.to_string());

View file

@ -11,7 +11,7 @@ use crate::input::TempleInput;
pub mod ast;
pub mod emit;
pub mod eval;
mod input;
pub mod input;
pub mod parser;
#[derive(Debug, Error, Display)]