diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 99b335cdb295f..a44561fb1e691 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -380,8 +380,9 @@ runTests { expected = 255; }; - testFromHexStringSecondExample = { - expr = fromHexString (builtins.hashString "sha256" "test"); + # Highest supported integer value in Nix. + testFromHexStringMaximum = { + expr = fromHexString "7fffffffffffffff"; expected = 9223372036854775807; }; @@ -390,6 +391,30 @@ runTests { expected = 15; }; + # FIXME: This might be bad and should potentially be deprecated. + testFromHexStringQuestionableMixedCase = { + expr = fromHexString "eEeEe"; + expected = 978670; + }; + + # FIXME: This is probably bad and should potentially be deprecated. + testFromHexStringQuestionableUnderscore = { + expr = fromHexString "F_f"; + expected = 255; + }; + + # FIXME: This is definitely bad and should be deprecated. + testFromHexStringBadComment = { + expr = fromHexString "0 # oops"; + expected = 0; + }; + + # FIXME: Oh my god. + testFromHexStringAwfulInjection = { + expr = fromHexString "1\nwhoops = {}"; + expected = 1; + }; + testToBaseDigits = { expr = toBaseDigits 2 6; expected = [ diff --git a/lib/trivial.nix b/lib/trivial.nix index eba6dd69b12e3..ada83b8fb4bef 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -1114,7 +1114,7 @@ in fromHexString "FF" => 255 - fromHexString (builtins.hashString "sha256" "test") + fromHexString "0x7fffffffffffffff" => 9223372036854775807 ``` */