Compare commits

..

No commits in common. "d41cd5784705453cba820ac0875f6704b16d956d" and "605798674f82020263a317f60965d8b963082804" have entirely different histories.

50 changed files with 267 additions and 268 deletions

13
Cargo.lock generated
View file

@ -442,7 +442,6 @@ dependencies = [
"insta", "insta",
"serde", "serde",
"serde_json", "serde_json",
"test_each_file",
"thiserror", "thiserror",
"winnow", "winnow",
] ]
@ -702,18 +701,6 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "test_each_file"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44619e49a1f62888c271dc50533f036363a7936f99c7cb467ca9d45224cf83b3"
dependencies = [
"proc-macro2",
"quote",
"syn",
"unicode-ident",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.18" version = "2.0.18"

View file

@ -7,10 +7,6 @@ edition = "2024"
name = "parsing" name = "parsing"
harness = false harness = false
[[bench]]
name = "asting"
harness = false
[profile.bench] [profile.bench]
debug = true debug = true
@ -27,7 +23,6 @@ criterion = "0.8.2"
insta = { version = "1.46.3", features = ["glob", "serde"] } insta = { version = "1.46.3", features = ["glob", "serde"] }
serde = { version = "1.0.228", features = ["derive"] } serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149" serde_json = "1.0.149"
test_each_file = "0.3.7"
[profile.dev.package] [profile.dev.package]
insta.opt-level = 3 insta.opt-level = 3

View file

@ -1,54 +0,0 @@
use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::criterion_group;
use criterion::criterion_main;
use nomo::input::NomoInput;
fn asting_benchmark(c: &mut Criterion) {
let mut parsing = c.benchmark_group("Asting");
for size in [1, 10, 200, 1000] {
let mut input = String::new();
for _ in 0..size {
input.push_str("{{ if foo }}{{= variable }}{{ end }}");
}
let input = NomoInput::from(input);
parsing.throughput(criterion::Throughput::Bytes(input.len() as u64));
parsing.bench_with_input(BenchmarkId::from_parameter(size), &input, |b, input| {
b.iter(|| {
let tokens = nomo::parser::parse(input.clone()).unwrap();
let _ast = nomo::ast::parse(tokens.tokens()).unwrap();
});
});
}
}
fn asting_nested(c: &mut Criterion) {
let mut parsing = c.benchmark_group("Asting");
for size in [1, 2, 8, 12] {
let mut input = String::new();
for _ in 0..size {
input = format!(
"{{{{ for foo in bar }}}} {input} {{{{ if foo }}}} Hi! {input} {{{{ end }}}} Yooo {{{{ end }}}}"
);
}
let input = NomoInput::from(input);
parsing.throughput(criterion::Throughput::Bytes(input.len() as u64));
parsing.bench_with_input(BenchmarkId::from_parameter(size), &input, |b, input| {
b.iter(|| {
let tokens = nomo::parser::parse(input.clone()).unwrap();
let _ast = nomo::ast::parse(tokens.tokens()).unwrap();
});
});
}
}
criterion_group!(benches, asting_benchmark, asting_nested);
criterion_main!(benches);

View file

@ -0,0 +1,152 @@
---
source: src/ast/mod.rs
expression: parsed
---
ParsedTemplate {
tokens: [
TemplateToken {
kind: LeftDelim,
source: "{{" (0..2),
},
TemplateToken {
kind: Whitespace,
source: " " (2..3),
},
TemplateToken {
kind: ConditionalIf,
source: "if" (3..5),
},
TemplateToken {
kind: Whitespace,
source: " " (5..6),
},
TemplateToken {
kind: Ident,
source: "foo" (6..9),
},
TemplateToken {
kind: Whitespace,
source: " " (9..10),
},
TemplateToken {
kind: RightDelim,
source: "}}" (10..12),
},
TemplateToken {
kind: Whitespace,
source: "\n " (12..25),
},
TemplateToken {
kind: LeftDelim,
source: "{{" (25..27),
},
TemplateToken {
kind: Whitespace,
source: " " (27..28),
},
TemplateToken {
kind: ConditionalIf,
source: "if" (28..30),
},
TemplateToken {
kind: Whitespace,
source: " " (30..31),
},
TemplateToken {
kind: Ident,
source: "bar" (31..34),
},
TemplateToken {
kind: Whitespace,
source: " " (34..35),
},
TemplateToken {
kind: RightDelim,
source: "}}" (35..37),
},
TemplateToken {
kind: Whitespace,
source: "\n " (37..54),
},
TemplateToken {
kind: Content,
source: "Hiii" (54..58),
},
TemplateToken {
kind: Whitespace,
source: "\n " (58..71),
},
TemplateToken {
kind: LeftDelim,
source: "{{" (71..73),
},
TemplateToken {
kind: Whitespace,
source: " " (73..74),
},
TemplateToken {
kind: End,
source: "end" (74..77),
},
TemplateToken {
kind: Whitespace,
source: " " (77..78),
},
TemplateToken {
kind: RightDelim,
source: "}}" (78..80),
},
TemplateToken {
kind: Whitespace,
source: "\n " (80..89),
},
TemplateToken {
kind: LeftDelim,
source: "{{" (89..91),
},
TemplateToken {
kind: Whitespace,
source: " " (91..92),
},
TemplateToken {
kind: End,
source: "end" (92..95),
},
TemplateToken {
kind: Whitespace,
source: " " (95..96),
},
TemplateToken {
kind: RightDelim,
source: "}}" (96..98),
},
TemplateToken {
kind: Whitespace,
source: "\n\n " (98..108),
},
TemplateToken {
kind: LeftDelim,
source: "{{" (108..110),
},
TemplateToken {
kind: Whitespace,
source: " " (110..111),
},
TemplateToken {
kind: Ident,
source: "value" (111..116),
},
TemplateToken {
kind: Whitespace,
source: " " (116..117),
},
TemplateToken {
kind: RightDelim,
source: "}}" (117..119),
},
TemplateToken {
kind: Whitespace,
source: "\n " (119..128),
},
],
}

View file

@ -1,11 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: parsed expression: parsed
info: input_file: tests/cases/condition.nomo
input: "{{ if test }}\n Hello World!\n{{ end }}\n\n{{= stuff }}"
context:
stuff: more
test: true
--- ---
ParsedTemplate { ParsedTemplate {
tokens: [ tokens: [

View file

@ -4,12 +4,13 @@ expression: parsed
info: info:
input: "{{= _name }}\n{{= a_name }}\n{{= name }}\n{{= _name1 }}\n{{= _namE }}\n{{= name1 }}" input: "{{= _name }}\n{{= a_name }}\n{{= name }}\n{{= _name1 }}\n{{= _namE }}\n{{= name1 }}"
context: context:
name1: Foo
_name: Foo
_namE: Foo _namE: Foo
a_name: Foo name1: Foo
name: Foo name: Foo
_name: Foo
a_name: Foo
_name1: Foo _name1: Foo
input_file: tests/cases/identifiers.nomo
--- ---
ParsedTemplate { ParsedTemplate {
tokens: [ tokens: [

View file

@ -1,12 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: parsed expression: parsed
info: input_file: tests/cases/if_else_if.nomo
input: "{{ if test }}\n Not Hello World! :C\n{{ else if another_test }}\n Hello World!\n{{ end }}"
context:
test: false
stuff: more
another_test: true
--- ---
ParsedTemplate { ParsedTemplate {
tokens: [ tokens: [

View file

@ -1,10 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: parsed expression: parsed
info: input_file: tests/cases/interpolation.nomo
input: "Hello! I'm {{= name }}"
context:
name: Hemera
--- ---
ParsedTemplate { ParsedTemplate {
tokens: [ tokens: [

View file

@ -4,6 +4,7 @@ expression: parsed
info: info:
input: "{{ if true }}\n Hello World!\n{{ end }}" input: "{{ if true }}\n Hello World!\n{{ end }}"
context: {} context: {}
input_file: tests/cases/literals.nomo
--- ---
ParsedTemplate { ParsedTemplate {
tokens: [ tokens: [

View file

@ -4,6 +4,7 @@ expression: parsed
info: info:
input: "{{= 5 * 3 }}\n{{= 2 * 3 + 4 * 3 }}\n{{= 3 / 3 + 3 }}" input: "{{= 5 * 3 }}\n{{= 2 * 3 + 4 * 3 }}\n{{= 3 / 3 + 3 }}"
context: {} context: {}
input_file: tests/cases/maths.nomo
--- ---
ParsedTemplate { ParsedTemplate {
tokens: [ tokens: [

View file

@ -1,11 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: parsed expression: parsed
info: input_file: tests/cases/multiple.nomo
input: "Hi there! My name is {{= name }} {{= lastname }}"
context:
name: Hemera
lastname: Green
--- ---
ParsedTemplate { ParsedTemplate {
tokens: [ tokens: [

View file

@ -1,9 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: parsed expression: parsed
info: input_file: tests/cases/simple.nomo
input: Hello World!
context: {}
--- ---
ParsedTemplate { ParsedTemplate {
tokens: [ tokens: [

View file

@ -8,6 +8,7 @@ info:
values: values:
- one - one
- two - two
input_file: tests/cases/simple_for.nomo
--- ---
ParsedTemplate { ParsedTemplate {
tokens: [ tokens: [

View file

@ -1,11 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: parsed expression: parsed
info: input_file: tests/cases/trim_whitespace.nomo
input: "{{ if test -}}\n Hello {{= stuff -}}\n{{- end }}"
context:
stuff: Hemera
test: true
--- ---
ParsedTemplate { ParsedTemplate {
tokens: [ tokens: [

View file

@ -1,11 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: ast expression: ast
info: input_file: tests/cases/condition.nomo
input: "{{ if test }}\n Hello World!\n{{ end }}\n\n{{= stuff }}"
context:
stuff: more
test: true
--- ---
TemplateAst { TemplateAst {
root: [ root: [

View file

@ -4,12 +4,13 @@ expression: ast
info: info:
input: "{{= _name }}\n{{= a_name }}\n{{= name }}\n{{= _name1 }}\n{{= _namE }}\n{{= name1 }}" input: "{{= _name }}\n{{= a_name }}\n{{= name }}\n{{= _name1 }}\n{{= _namE }}\n{{= name1 }}"
context: context:
name1: Foo
_name: Foo
_namE: Foo _namE: Foo
a_name: Foo name1: Foo
name: Foo name: Foo
_name: Foo
a_name: Foo
_name1: Foo _name1: Foo
input_file: tests/cases/identifiers.nomo
--- ---
TemplateAst { TemplateAst {
root: [ root: [

View file

@ -1,12 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: ast expression: ast
info: input_file: tests/cases/if_else_if.nomo
input: "{{ if test }}\n Not Hello World! :C\n{{ else if another_test }}\n Hello World!\n{{ end }}"
context:
test: false
stuff: more
another_test: true
--- ---
TemplateAst { TemplateAst {
root: [ root: [

View file

@ -1,10 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: ast expression: ast
info: input_file: tests/cases/interpolation.nomo
input: "Hello! I'm {{= name }}"
context:
name: Hemera
--- ---
TemplateAst { TemplateAst {
root: [ root: [

View file

@ -4,6 +4,7 @@ expression: ast
info: info:
input: "{{ if true }}\n Hello World!\n{{ end }}" input: "{{ if true }}\n Hello World!\n{{ end }}"
context: {} context: {}
input_file: tests/cases/literals.nomo
--- ---
TemplateAst { TemplateAst {
root: [ root: [

View file

@ -4,6 +4,7 @@ expression: ast
info: info:
input: "{{= 5 * 3 }}\n{{= 2 * 3 + 4 * 3 }}\n{{= 3 / 3 + 3 }}" input: "{{= 5 * 3 }}\n{{= 2 * 3 + 4 * 3 }}\n{{= 3 / 3 + 3 }}"
context: {} context: {}
input_file: tests/cases/maths.nomo
--- ---
TemplateAst { TemplateAst {
root: [ root: [

View file

@ -1,11 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: ast expression: ast
info: input_file: tests/cases/multiple.nomo
input: "Hi there! My name is {{= name }} {{= lastname }}"
context:
name: Hemera
lastname: Green
--- ---
TemplateAst { TemplateAst {
root: [ root: [

View file

@ -1,9 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: ast expression: ast
info: input_file: tests/cases/simple.nomo
input: Hello World!
context: {}
--- ---
TemplateAst { TemplateAst {
root: [ root: [

View file

@ -8,6 +8,7 @@ info:
values: values:
- one - one
- two - two
input_file: tests/cases/simple_for.nomo
--- ---
TemplateAst { TemplateAst {
root: [ root: [

View file

@ -1,11 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: ast expression: ast
info: input_file: tests/cases/trim_whitespace.nomo
input: "{{ if test -}}\n Hello {{= stuff -}}\n{{- end }}"
context:
stuff: Hemera
test: true
--- ---
TemplateAst { TemplateAst {
root: [ root: [

View file

@ -1,11 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: emit expression: emit
info: input_file: tests/cases/condition.nomo
input: "{{ if test }}\n Hello World!\n{{ end }}\n\n{{= stuff }}"
context:
stuff: more
test: true
--- ---
VMInstructions { VMInstructions {
labels: { labels: {

View file

@ -4,12 +4,13 @@ expression: emit
info: info:
input: "{{= _name }}\n{{= a_name }}\n{{= name }}\n{{= _name1 }}\n{{= _namE }}\n{{= name1 }}" input: "{{= _name }}\n{{= a_name }}\n{{= name }}\n{{= _name1 }}\n{{= _namE }}\n{{= name1 }}"
context: context:
name1: Foo
_name: Foo
_namE: Foo _namE: Foo
a_name: Foo name1: Foo
name: Foo name: Foo
_name: Foo
a_name: Foo
_name1: Foo _name1: Foo
input_file: tests/cases/identifiers.nomo
--- ---
VMInstructions { VMInstructions {
labels: {}, labels: {},

View file

@ -1,12 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: emit expression: emit
info: input_file: tests/cases/if_else_if.nomo
input: "{{ if test }}\n Not Hello World! :C\n{{ else if another_test }}\n Hello World!\n{{ end }}"
context:
test: false
stuff: more
another_test: true
--- ---
VMInstructions { VMInstructions {
labels: { labels: {

View file

@ -1,10 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: emit expression: emit
info: input_file: tests/cases/interpolation.nomo
input: "Hello! I'm {{= name }}"
context:
name: Hemera
--- ---
VMInstructions { VMInstructions {
labels: {}, labels: {},

View file

@ -4,6 +4,7 @@ expression: emit
info: info:
input: "{{ if true }}\n Hello World!\n{{ end }}" input: "{{ if true }}\n Hello World!\n{{ end }}"
context: {} context: {}
input_file: tests/cases/literals.nomo
--- ---
VMInstructions { VMInstructions {
labels: { labels: {

View file

@ -4,6 +4,7 @@ expression: emit
info: info:
input: "{{= 5 * 3 }}\n{{= 2 * 3 + 4 * 3 }}\n{{= 3 / 3 + 3 }}" input: "{{= 5 * 3 }}\n{{= 2 * 3 + 4 * 3 }}\n{{= 3 / 3 + 3 }}"
context: {} context: {}
input_file: tests/cases/maths.nomo
--- ---
VMInstructions { VMInstructions {
labels: {}, labels: {},

View file

@ -1,11 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: emit expression: emit
info: input_file: tests/cases/multiple.nomo
input: "Hi there! My name is {{= name }} {{= lastname }}"
context:
name: Hemera
lastname: Green
--- ---
VMInstructions { VMInstructions {
labels: {}, labels: {},

View file

@ -1,9 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: emit expression: emit
info: input_file: tests/cases/simple.nomo
input: Hello World!
context: {}
--- ---
VMInstructions { VMInstructions {
labels: {}, labels: {},

View file

@ -8,6 +8,7 @@ info:
values: values:
- one - one
- two - two
input_file: tests/cases/simple_for.nomo
--- ---
VMInstructions { VMInstructions {
labels: { labels: {

View file

@ -1,11 +1,7 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: emit expression: emit
info: input_file: tests/cases/trim_whitespace.nomo
input: "{{ if test -}}\n Hello {{= stuff -}}\n{{- end }}"
context:
stuff: Hemera
test: true
--- ---
VMInstructions { VMInstructions {
labels: { labels: {

View file

@ -0,0 +1,6 @@
---
source: tests/file_tests.rs
expression: output
input_file: tests/cases/condition.nomo
---
"\n Hello World!\n\n\nmore"

View file

@ -0,0 +1,6 @@
---
source: tests/file_tests.rs
expression: output
input_file: tests/cases/identifiers.nomo
---
"Foo\nFoo\nFoo\nFoo\nFoo\nFoo"

View file

@ -0,0 +1,6 @@
---
source: tests/file_tests.rs
expression: output
input_file: tests/cases/if_else_if.nomo
---
"\n Hello World!\n"

View file

@ -1,9 +1,6 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: output expression: output
info: input_file: tests/cases/interpolation.nomo
input: "Hello! I'm {{= name }}"
context:
name: Hemera
--- ---
"Hello! I'm Hemera" "Hello! I'm Hemera"

View file

@ -4,5 +4,6 @@ expression: output
info: info:
input: "{{ if true }}\n Hello World!\n{{ end }}" input: "{{ if true }}\n Hello World!\n{{ end }}"
context: {} context: {}
input_file: tests/cases/literals.nomo
--- ---
"\n Hello World!\n" "\n Hello World!\n"

View file

@ -4,5 +4,6 @@ expression: output
info: info:
input: "{{= 5 * 3 }}\n{{= 2 * 3 + 4 * 3 }}\n{{= 3 / 3 + 3 }}" input: "{{= 5 * 3 }}\n{{= 2 * 3 + 4 * 3 }}\n{{= 3 / 3 + 3 }}"
context: {} context: {}
input_file: tests/cases/maths.nomo
--- ---
"15\n18\n4" "15\n18\n4"

View file

@ -0,0 +1,6 @@
---
source: tests/file_tests.rs
expression: output
input_file: tests/cases/multiple.nomo
---
"Hi there! My name is Hemera Green"

View file

@ -1,8 +1,6 @@
--- ---
source: tests/file_tests.rs source: tests/file_tests.rs
expression: output expression: output
info: input_file: tests/cases/simple.nomo
input: Hello World!
context: {}
--- ---
"Hello World!" "Hello World!"

View file

@ -8,5 +8,6 @@ info:
values: values:
- one - one
- two - two
input_file: tests/cases/simple_for.nomo
--- ---
"one\ntwo\n\nNo Values >:C" "one\ntwo\n\nNo Values >:C"

View file

@ -0,0 +1,6 @@
---
source: tests/file_tests.rs
expression: output
input_file: tests/cases/trim_whitespace.nomo
---
"Hello Hemera"

View file

@ -1,10 +0,0 @@
---
source: tests/file_tests.rs
expression: output
info:
input: "{{ if test }}\n Hello World!\n{{ end }}\n\n{{= stuff }}"
context:
stuff: more
test: true
---
"\n Hello World!\n\n\nmore"

View file

@ -1,14 +0,0 @@
---
source: tests/file_tests.rs
expression: output
info:
input: "{{= _name }}\n{{= a_name }}\n{{= name }}\n{{= _name1 }}\n{{= _namE }}\n{{= name1 }}"
context:
name1: Foo
_name: Foo
_namE: Foo
a_name: Foo
name: Foo
_name1: Foo
---
"Foo\nFoo\nFoo\nFoo\nFoo\nFoo"

View file

@ -1,11 +0,0 @@
---
source: tests/file_tests.rs
expression: output
info:
input: "{{ if test }}\n Not Hello World! :C\n{{ else if another_test }}\n Hello World!\n{{ end }}"
context:
test: false
stuff: more
another_test: true
---
"\n Hello World!\n"

View file

@ -1,10 +0,0 @@
---
source: tests/file_tests.rs
expression: output
info:
input: "Hi there! My name is {{= name }} {{= lastname }}"
context:
name: Hemera
lastname: Green
---
"Hi there! My name is Hemera Green"

View file

@ -1,10 +0,0 @@
---
source: tests/file_tests.rs
expression: output
info:
input: "{{ if test -}}\n Hello {{= stuff -}}\n{{- end }}"
context:
stuff: Hemera
test: true
---
"Hello Hemera"

View file

@ -1,64 +1,64 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::path::Path;
use nomo::Context; use nomo::Context;
test_each_file::test_each_path! { for ["nomo"] in "./tests/cases/" as cases => check_for_input }
#[derive(serde::Serialize)] #[derive(serde::Serialize)]
struct Info { struct Info {
input: String, input: String,
context: HashMap<String, serde_json::Value>, context: HashMap<String, serde_json::Value>,
} }
fn check_for_input([path]: [&Path; 1]) { #[test]
let mut settings = insta::Settings::clone_current(); fn check_cases() {
settings.set_snapshot_path("cases"); insta::glob!("cases/*.nomo", |path| {
settings.set_prepend_module_to_snapshot(false); let mut settings = insta::Settings::clone_current();
settings.set_snapshot_path("cases");
settings.set_snapshot_suffix(path.file_stem().unwrap().display().to_string());
settings.set_prepend_module_to_snapshot(false);
let basename = path.file_stem().unwrap().to_string_lossy(); let input = std::fs::read_to_string(path).unwrap();
let input = std::fs::read_to_string(path).unwrap();
let (context, input) = input.split_once("\n---\n").unwrap_or_else(|| ("", &input)); let (context, input) = input.split_once("\n---\n").unwrap_or_else(|| ("", &input));
let map = if !context.is_empty() { let map = if !context.is_empty() {
serde_json::from_str::<HashMap<String, serde_json::Value>>(context).unwrap() serde_json::from_str::<HashMap<String, serde_json::Value>>(context).unwrap()
} else { } else {
HashMap::new() HashMap::new()
}; };
settings.set_info(&Info { settings.set_info(&Info {
input: input.to_string(), input: input.to_string(),
context: map.clone(), context: map.clone(),
}); });
let mut context = Context::new(); let mut context = Context::new();
for (k, v) in map { for (k, v) in map {
context.try_insert(k, v).unwrap(); context.try_insert(k, v).unwrap();
}
let parsed = nomo::parser::parse(input.into()).unwrap();
let _guard = settings.bind_to_scope();
insta::assert_debug_snapshot!(format!("{basename}.1-parsed"), parsed);
let ast = match nomo::ast::parse(parsed.tokens()) {
Ok(ast) => ast,
Err(err) => {
eprintln!("{}", err.to_report(input));
panic!("Could not evaluate ast");
} }
};
insta::assert_debug_snapshot!(format!("{basename}.2-ast"), ast); let parsed = nomo::parser::parse(input.into()).unwrap();
let emit = nomo::emit::emit_machine(ast); let _guard = settings.bind_to_scope();
insta::assert_debug_snapshot!(format!("{basename}.3-instructions"), emit); insta::assert_debug_snapshot!("1-parsed", parsed);
let output = nomo::eval::execute(&emit, &context).unwrap(); let ast = match nomo::ast::parse(parsed.tokens()) {
Ok(ast) => ast,
Err(err) => {
eprintln!("{}", err.to_report(input));
panic!("Could not evaluate ast");
}
};
insta::assert_debug_snapshot!(format!("{basename}.4-output"), output); insta::assert_debug_snapshot!("2-ast", ast);
let emit = nomo::emit::emit_machine(ast);
insta::assert_debug_snapshot!("3-instructions", emit);
let output = nomo::eval::execute(&emit, &context).unwrap();
insta::assert_debug_snapshot!("4-output", output);
});
} }