Setup a testing bench
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
4470af3926
commit
d3e6410ec0
16 changed files with 336 additions and 4 deletions
|
|
@ -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();
|
||||
|
|
|
|||
19
src/input.rs
19
src/input.rs
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue