Skip to content

[all-your-base, leap, hamming] tests are swapped #263

@NobbZ

Description

@NobbZ

By stepwise doing all-your-base, I encountered that a Just [1] was expected but a Nothing got, while my code was only able to return Justs at that stage:

rebase :: Integral a => a -> a -> [a] -> Maybe [Integer]
rebase inputBase outputBase input =
  let x = fromBase (toInteger inputBase) input
  in Just [x]

fromBase :: Integral a => Integer -> [a] -> Integer
fromBase b = go 0
  where
    go !n []     = n
    go !n (d:ds) = go (n * (toInteger b) + (toInteger d)) ds

And I got following test-output (only one out of many):

### Failure in: 20:both bases are negative
test\Tests.hs:25
expected: Just [1]
 but got: Nothing

After changing all occurences of (~=?) with (~?=) in the test/Tests.hs I got a more appropriate output in the testrun:

### Failure in: 20:both bases are negative
test\Tests.hs:25
expected: Nothing
 but got: Just [1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions