Skip to content

Commit

Permalink
added builtins.add
Browse files Browse the repository at this point in the history
  • Loading branch information
urbas committed Jul 18, 2023
1 parent b6f2328 commit 5faf412
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ implemented.
statement, functions
- 🌕 stage 1: lazy evaluation
- 🌘 stage 2:
- 🌘 built-in functions (progress: 2 out of 111)
- 🌘 built-in functions (progress: 3 out of 111)
- 🌑 derivations (hello world derivation)
- 🌑 stage 3: full implementation (all derivations in nixpkgs, nice error
messages, etc.)
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.70.0"
channel = "1.71.0"
components = [ "clippy", "rust-analyzer", "rustfmt" ]
profile = "minimal"
17 changes: 11 additions & 6 deletions src/eval/nix_v8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,23 +1227,28 @@ mod tests {
assert_eq!(eval_ok(r#"rec { a = "b"; ${a} = 1; }.b"#), Value::Int(1));
}

#[test]
fn test_eval_builtin_head() {
assert_eq!(eval_ok("builtins.head [ 1 2 ]"), Value::Int(1));
}

#[test]
fn test_eval_lists_are_lazy() {
assert_eq!(eval_ok("builtins.head [ 1 (1 / 0) ]"), Value::Int(1));
}

#[test]
fn test_eval_abort() {
fn test_eval_builtin_abort() {
let error_msg = evaluate(r#"abort "foo""#).unwrap_err();
let expected_msg = "Evaluation aborted with the following error message: 'foo'";
assert!(
error_msg.contains(expected_msg),
"Error message '{error_msg}' didn't contain '{expected_msg}'."
);
}

#[test]
fn test_eval_builtin_add() {
assert_eq!(eval_ok("builtins.add 1 2"), Value::Int(3));
}

#[test]
fn test_eval_builtin_head() {
assert_eq!(eval_ok("builtins.head [ 1 2 ]"), Value::Int(1));
}
}

0 comments on commit 5faf412

Please sign in to comment.