Unverified Commit 677ccc54 authored by Emily's avatar Emily Committed by GitHub
Browse files

lib: fix overflowing `fromHexString` tests and example (#433710)

parents 5df4afd7 449ad44f
Loading
Loading
Loading
Loading
+27 −2
Original line number Diff line number Diff line
@@ -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 = [
+1 −1
Original line number Diff line number Diff line
@@ -1114,7 +1114,7 @@ in
    fromHexString "FF"
    => 255

    fromHexString (builtins.hashString "sha256" "test")
    fromHexString "0x7fffffffffffffff"
    => 9223372036854775807
    ```
  */