This commit is contained in:
2026-04-04 11:34:54 +08:00
parent ee54ab8895
commit f697eaf0ce
34 changed files with 1799 additions and 4221 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
use fix::value::Value;
use fix_common::Value;
use crate::utils::{eval_deep, eval_deep_result};
+6 -6
View File
@@ -1,6 +1,6 @@
use fix::error::Source;
use fix::runtime::Runtime;
use fix::value::Value;
use fix::Evaluator;
use fix_common::Value;
use fix_error::Source;
use crate::utils::{eval, eval_result};
@@ -97,7 +97,7 @@ fn import_with_complex_dependency_graph() {
#[test_log::test]
fn path_with_file() {
let mut ctx = Runtime::new().unwrap();
let mut ctx = Evaluator::new();
let temp_dir = tempfile::tempdir().unwrap();
let test_file = temp_dir.path().join("test.txt");
std::fs::write(&test_file, "Hello, World!").unwrap();
@@ -136,7 +136,7 @@ fn path_with_custom_name() {
#[test_log::test]
fn path_with_directory_recursive() {
let mut ctx = Runtime::new().unwrap();
let mut ctx = Evaluator::new();
let temp_dir = tempfile::tempdir().unwrap();
let test_dir = temp_dir.path().join("mydir");
std::fs::create_dir_all(&test_dir).unwrap();
@@ -159,7 +159,7 @@ fn path_with_directory_recursive() {
#[test_log::test]
fn path_flat_with_file() {
let mut ctx = Runtime::new().unwrap();
let mut ctx = Evaluator::new();
let temp_dir = tempfile::tempdir().unwrap();
let test_file = temp_dir.path().join("flat.txt");
std::fs::write(&test_file, "Flat content").unwrap();
+5 -5
View File
@@ -2,9 +2,9 @@
use std::path::PathBuf;
use fix::error::Source;
use fix::runtime::Runtime;
use fix::value::Value;
use fix::Evaluator;
use fix_common::Value;
use fix_error::{Source, SourceType};
fn get_lang_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/tests/lang")
@@ -14,10 +14,10 @@ fn eval_file(name: &str) -> Result<(Value, Source), String> {
let lang_dir = get_lang_dir();
let nix_path = lang_dir.join(format!("{name}.nix"));
let mut ctx = Runtime::new().map_err(|e| e.to_string())?;
let mut ctx = Evaluator::new();
let content = std::fs::read_to_string(&nix_path).unwrap();
let source = Source {
ty: fix::error::SourceType::File(nix_path.into()),
ty: SourceType::File(nix_path.into()),
src: content.into(),
};
ctx.eval_deep(source.clone())
+5 -5
View File
@@ -1,5 +1,5 @@
use fix::runtime::Runtime;
use fix::value::Value;
use fix::Evaluator;
use fix_common::Value;
use crate::utils::eval_result;
@@ -153,7 +153,7 @@ fn string_add_merges_context() {
#[test_log::test]
fn context_in_derivation_args() {
let mut rt = Runtime::new().unwrap();
let mut rt = Evaluator::new();
let result = rt
.eval(
r#"
@@ -182,7 +182,7 @@ fn context_in_derivation_args() {
#[test_log::test]
fn context_in_derivation_env() {
let mut rt = Runtime::new().unwrap();
let mut rt = Evaluator::new();
let result = rt
.eval(
r#"
@@ -224,7 +224,7 @@ fn tostring_preserves_context() {
#[test_log::test]
fn interpolation_derivation_returns_outpath() {
let mut rt = Runtime::new().unwrap();
let mut rt = Evaluator::new();
let result = rt
.eval(
r#"
+8 -15
View File
@@ -1,38 +1,31 @@
#![allow(dead_code)]
use fix::error::{Result, Source};
use fix::runtime::Runtime;
use fix::value::Value;
use fix::Evaluator;
use fix_common::Value;
use fix_error::{Result, Source};
pub fn eval(expr: &str) -> Value {
Runtime::new()
.unwrap()
Evaluator::new()
.eval(Source::new_eval(expr.into()).unwrap())
.unwrap()
}
pub fn eval_shallow(expr: &str) -> Value {
Runtime::new()
.unwrap()
Evaluator::new()
.eval_shallow(Source::new_eval(expr.into()).unwrap())
.unwrap()
}
pub fn eval_deep(expr: &str) -> Value {
Runtime::new()
.unwrap()
Evaluator::new()
.eval_deep(Source::new_eval(expr.into()).unwrap())
.unwrap()
}
pub fn eval_deep_result(expr: &str) -> Result<Value> {
Runtime::new()
.unwrap()
.eval_deep(Source::new_eval(expr.into()).unwrap())
Evaluator::new().eval_deep(Source::new_eval(expr.into()).unwrap())
}
pub fn eval_result(expr: &str) -> Result<Value> {
Runtime::new()
.unwrap()
.eval(Source::new_eval(expr.into()).unwrap())
Evaluator::new().eval(Source::new_eval(expr.into()).unwrap())
}