test nix_state_create's lookupPath argument
(cherry picked from commit 6e5a259f60725b632e52d4839e6e3c285d6971d4)
This commit is contained in:
parent
d817e86c59
commit
9a62664fb1
3 changed files with 53 additions and 1 deletions
|
|
@ -385,6 +385,7 @@ pub fn test_init() {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ctor::ctor;
|
||||
use std::io::Write as _;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
@ -403,6 +404,37 @@ mod tests {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eval_state_lookup_path() {
|
||||
let import_expression = "import <test_file0> + import <test_file1>";
|
||||
let integer0 = 83;
|
||||
let integer1 = 103;
|
||||
let mut test_file0 = tempfile::NamedTempFile::new().unwrap();
|
||||
let mut test_file1 = tempfile::NamedTempFile::new().unwrap();
|
||||
writeln!(test_file0, "{integer0}").unwrap();
|
||||
writeln!(test_file1, "{integer1}").unwrap();
|
||||
gc_registering_current_thread(|| {
|
||||
let es = EvalState::new(Store::open("auto").unwrap(), []).unwrap();
|
||||
assert!(es.eval_from_string(import_expression, "<test>").is_err());
|
||||
|
||||
let es = EvalState::new(
|
||||
Store::open("auto").unwrap(),
|
||||
[
|
||||
format!("test_file0={}", test_file0.path().to_str().unwrap()).as_str(),
|
||||
format!("test_file1={}", test_file1.path().to_str().unwrap()).as_str(),
|
||||
],
|
||||
)
|
||||
.unwrap();
|
||||
let v = es
|
||||
.require_int(&es.eval_from_string(import_expression, "<test>").unwrap())
|
||||
.unwrap();
|
||||
assert_eq!(v, integer0 + integer1);
|
||||
})
|
||||
.unwrap();
|
||||
test_file0.close().unwrap();
|
||||
test_file1.close().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eval_state_eval_from_string() {
|
||||
gc_registering_current_thread(|| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue