mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
lib: fix overflowing fromHexString tests and example (#433710)
This commit is contained in:
@@ -386,8 +386,9 @@ runTests {
|
||||
expected = 255;
|
||||
};
|
||||
|
||||
testFromHexStringSecondExample = {
|
||||
expr = fromHexString (builtins.hashString "sha256" "test");
|
||||
# Highest supported integer value in Nix.
|
||||
testFromHexStringMaximum = {
|
||||
expr = fromHexString "7fffffffffffffff";
|
||||
expected = 9223372036854775807;
|
||||
};
|
||||
|
||||
@@ -396,6 +397,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 = [
|
||||
|
||||
@@ -1114,7 +1114,7 @@ in
|
||||
fromHexString "FF"
|
||||
=> 255
|
||||
|
||||
fromHexString (builtins.hashString "sha256" "test")
|
||||
fromHexString "0x7fffffffffffffff"
|
||||
=> 9223372036854775807
|
||||
```
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user