Skip to content

Commit

Permalink
115: Comments: use RFC style
Browse files Browse the repository at this point in the history
Format using commit number 115 from nixfmt PR 2: piegamesde/nixfmt@25792d4
  • Loading branch information
GitHub Actions committed Mar 1, 2024
1 parent dd14674 commit d8f604b
Show file tree
Hide file tree
Showing 640 changed files with 11,917 additions and 10,749 deletions.
42 changes: 22 additions & 20 deletions lib/asserts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

rec {

/* Throw if pred is false, else return pred.
Intended to be used to augment asserts with helpful error messages.
/*
Throw if pred is false, else return pred.
Intended to be used to augment asserts with helpful error messages.
Example:
assertMsg false "nope"
stderr> error: nope
Example:
assertMsg false "nope"
stderr> error: nope
assert assertMsg ("foo" == "bar") "foo is not bar, silly"; ""
stderr> error: foo is not bar, silly
assert assertMsg ("foo" == "bar") "foo is not bar, silly"; ""
stderr> error: foo is not bar, silly
Type:
assertMsg :: Bool -> String -> Bool
Type:
assertMsg :: Bool -> String -> Bool
*/
# TODO(Profpatsch): add tests that check stderr
assertMsg =
Expand All @@ -23,19 +24,20 @@ rec {
msg:
pred || builtins.throw msg;

/* Specialized `assertMsg` for checking if `val` is one of the elements
of the list `xs`. Useful for checking enums.
/*
Specialized `assertMsg` for checking if `val` is one of the elements
of the list `xs`. Useful for checking enums.
Example:
let sslLibrary = "libressl";
in assertOneOf "sslLibrary" sslLibrary [ "openssl" "bearssl" ]
stderr> error: sslLibrary must be one of [
stderr> "openssl"
stderr> "bearssl"
stderr> ], but is: "libressl"
Example:
let sslLibrary = "libressl";
in assertOneOf "sslLibrary" sslLibrary [ "openssl" "bearssl" ]
stderr> error: sslLibrary must be one of [
stderr> "openssl"
stderr> "bearssl"
stderr> ], but is: "libressl"
Type:
assertOneOf :: String -> ComparableVal -> List ComparableVal -> Bool
Type:
assertOneOf :: String -> ComparableVal -> List ComparableVal -> Bool
*/
assertOneOf =
# The name of the variable the user entered `val` into, for inclusion in the error message
Expand Down
Loading

0 comments on commit d8f604b

Please sign in to comment.