mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 02:40:31 +08:00
lib: add fromHexString tests for distressing behaviour
This was cherry‐picked from
<https://github.com/NixOS/nixpkgs/pull/266705> and merged as part of
<https://github.com/NixOS/nixpkgs/pull/318712>, despite there being
a blocking review on the former pointing out these kinds of issues.
This documents some of the dodgy behaviour. It also can’t handle
negative literals. It might be worth considering deprecating and
dropping this, by inlining it into `lib.network.ipv6.fromString`,
its only in‐tree user.
(cherry picked from commit 6673e05ad0)
This commit is contained in:
committed by
github-actions[bot]
parent
8afe8c5f08
commit
b591001250
@@ -390,6 +390,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 = [
|
||||
|
||||
Reference in New Issue
Block a user