Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NobbZ opened this issue Aug 7, 2016 · 3 comments
Closed

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

NobbZ opened this issue Aug 7, 2016 · 3 comments

Comments

@NobbZ
Copy link
Member

NobbZ commented Aug 7, 2016

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]
@rbasso
Copy link
Contributor

rbasso commented Aug 7, 2016

Thanks for reporting that, @NobbZ.

I guess I confused the operators when writing it. 😁

This behavior is already fixed in branch hspec-fail-fast...

    test Case{..} = it description assertion
      where
        assertion  = expression `shouldBe` outputDigits
        expression = rebase inputBase outputBase inputDigits

...but we only had plans to merge it to master after migrating the remaining 30 exercises to Hspec.

Should we fix that now in master or wait for the merge, probably in two weeks?

Edit: leap and hamming seem to have the same code (copy/paste). They where also accidentally fixed in hspec-fail-fast so we can wait for #211 to solve everything.

@rbasso rbasso changed the title [all-your-base] tests are swapped [all-your-base, leap, hamming] tests are swapped Aug 7, 2016
@NobbZ
Copy link
Member Author

NobbZ commented Aug 7, 2016

I've fixed it locally, so I'm fine with whatever you do :) As far as I did
understand the procedure, @kytrinix needs to sync the tests by hand into
the main repository. So I think we can just let it as is until HSpec is
there.

rbasso [email protected] schrieb am So., 7. Aug. 2016 um 22:28 Uhr:

Thanks for reporting that, @NobbZ https://github.com/NobbZ.

I guess I confused the operators when writing it. 😁

This behavior is already fixed in branch hspec-fail-fast...

test Case{..} = it description assertion
  where
    assertion  = expression `shouldBe` outputDigits
    expression = rebase inputBase outputBase inputDigits

...but we only had plans to merge it to master after migrating the
remaining 30 exercises to Hspec.

Should we fix that now in master or wait for the merge, probably in two
weeks?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#263 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADmR1A2tS3iy2O8DYwljeWeUX461QNwks5qdj_sgaJpZM4Jeko3
.

@kytrinyx
Copy link
Member

As far as I did
understand the procedure, @kytrinyx needs to sync the tests by hand into
the main repository.

Yeah basically. We have a separate API that delivers the problem data. It's not a lot of code, but it includes all of the language-specific tracks as submodules, so I have to update the submodules, commit, and deploy, which is still a manual process. I'm sure this could be automated to some degree, but I'm wary of missing something stupid and breaking the site while I'm asleep or traveling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants