2021-02-22 14:32:45 +01:00
|
|
|
{ depot, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (depot.nix.runTestsuite)
|
|
|
|
it
|
|
|
|
assertEq
|
|
|
|
runTestsuite
|
|
|
|
;
|
|
|
|
|
|
|
|
inherit (depot.users.sterni.nix)
|
|
|
|
char
|
|
|
|
string
|
2023-08-05 15:39:56 +02:00
|
|
|
num
|
2021-02-22 14:32:45 +01:00
|
|
|
fun
|
|
|
|
;
|
|
|
|
|
|
|
|
charList = string.toChars char.allChars;
|
|
|
|
|
|
|
|
testAllCharConversion = it "tests conversion of all chars" [
|
|
|
|
(assertEq "char.chr converts to char.allChars"
|
2023-08-05 15:39:56 +02:00
|
|
|
(builtins.genList (fun.rl char.chr (num.add 1)) 255)
|
2021-02-22 14:32:45 +01:00
|
|
|
charList)
|
|
|
|
(assertEq "char.ord converts from char.allChars"
|
2023-08-05 15:39:56 +02:00
|
|
|
(builtins.genList (num.add 1) 255)
|
2021-02-22 14:32:45 +01:00
|
|
|
(builtins.map char.ord charList))
|
|
|
|
];
|
|
|
|
|
|
|
|
in
|
2022-01-30 17:06:58 +01:00
|
|
|
runTestsuite "char" [
|
|
|
|
testAllCharConversion
|
|
|
|
]
|