tvl-depot/users/sterni/nix/char/tests/default.nix
sterni 984ea69386 refactor(users/sterni/nix): move generic number operation into num
We omit type checks for performance reasons in most places currently, so
the library grouping is important in showing people what to use for what
sort of input. The moved functions make sense to use with floats as
well, so we'll move them to the num library. Some of the remaining
functions could theoretically be adapted and moved, but aren't for now.

Change-Id: Ifdecaa60be594f4438b2a58b9ea6445e2da080e3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9007
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
2023-08-09 12:12:47 +00:00

31 lines
602 B
Nix

{ depot, ... }:
let
inherit (depot.nix.runTestsuite)
it
assertEq
runTestsuite
;
inherit (depot.users.sterni.nix)
char
string
num
fun
;
charList = string.toChars char.allChars;
testAllCharConversion = it "tests conversion of all chars" [
(assertEq "char.chr converts to char.allChars"
(builtins.genList (fun.rl char.chr (num.add 1)) 255)
charList)
(assertEq "char.ord converts from char.allChars"
(builtins.genList (num.add 1) 255)
(builtins.map char.ord charList))
];
in
runTestsuite "char" [
testAllCharConversion
]