Skip to content

Commit

Permalink
Some minor fixes
Browse files Browse the repository at this point in the history
Some minor things I noticed while doing all the other stuff
  • Loading branch information
arduano@localhost committed May 9, 2024
1 parent fa867b4 commit adbf5a7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/eval/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fn try_js_error_to_rust(
}
_ => {
return Ok(NixError {
message: vec![NixErrorMessagePart::Plain("An error occurred.".to_owned())],
message: vec![NixErrorMessagePart::Plain("An unrecognized NixError occurred.".to_owned())],
kind: NixErrorKind::UnexpectedJsError {
message: error.to_rust_string_lossy(scope),
},
Expand Down
2 changes: 1 addition & 1 deletion src/tests/attr_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn eval_attrset_non_string_attr() {
fn eval_attrset_update() {
assert_eq!(eval_ok("{} // {}"), Value::AttrSet(HashMap::new()));
assert_eq!(
eval_ok("{a = 1; b = 2;} // {a = 3; c = 1;"),
eval_ok("{a = 1; b = 2;} // {a = 3; c = 1;}"),
Value::AttrSet(HashMap::from([
("a".to_owned(), Value::Int(3)),
("b".to_owned(), Value::Int(2)),
Expand Down
10 changes: 8 additions & 2 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![allow(clippy::expect_fun_call)]
#![allow(clippy::approx_constant)]

use crate::eval::{error::NixErrorKind, execution::evaluate, types::Value};
use crate::eval::{error::NixErrorKind, execution::evaluate, types::{NixTypeKind, Value}};

mod attr_set;
mod builtins;
Expand Down Expand Up @@ -34,7 +34,13 @@ fn eval_if_then_else() {

#[test]
fn eval_if_then_else_invalid_type() {
assert!(evaluate("if 0 then 1 else 0").is_err());
assert_eq!(
eval_err("if 0 then 1 else 0"),
NixErrorKind::TypeMismatch {
expected: vec![NixTypeKind::Bool],
got: NixTypeKind::Int,
}
);
}

#[test]
Expand Down
11 changes: 11 additions & 0 deletions src/tests/operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ fn eval_path_string_concatenation() {

#[test]
fn eval_path_concat() {
let curr_dir = std::env::current_dir().unwrap();

assert_eq!(
eval_ok("./foo + ./bar"),
Value::Path(format!(
"{}/foo{}/bar",
curr_dir.display(),
curr_dir.display()
))
);

assert_eq!(eval_ok(r#"/. + "a""#), Value::Path("/a".to_owned()));
assert_eq!(eval_ok(r#"/. + "./a/../b""#), Value::Path("/b".to_owned()));
}
Expand Down

0 comments on commit adbf5a7

Please sign in to comment.