mod common;
use std::path::Path;
use common::fixture::{add_path_capture, new_parser};
use tabnas_support::{find_spec_dir, Failure, Runner, Value};
#[test]
fn spec() {
let dir = find_spec_dir(Some(Path::new(env!("CARGO_MANIFEST_DIR")))).expect("test/spec");
let mut parser = new_parser();
add_path_capture(&mut parser);
Runner::new_with_row(move |input, row| {
let opts = row.named("opts");
let meta = if opts.trim().is_empty() {
tabnas::Value::Undefined
} else {
let json: serde_json::Value = serde_json::from_str(opts)
.map_err(|error| Failure::message(format!("opts is not JSON: {error}")))?;
tabnas::Value::from_json(&json)
};
parser
.parse_with_meta(input, meta)
.map(|value| Value::from(value.to_json()))
.map_err(|error| Failure::new(error.code.clone()).with_message(error.to_string()))
})
.dir(&dir);
}