Is there an error on the all base tests?

When you pass from 10 base to other you make successive divisions. For example pass 5 base 10 to base 2 you result with 1 0 1. All fine. But if you have 0 in base 10 to pass it to base 4 (or whatever > 0), you divide 0 between 4 (or whatever > 0) and the quotient and residue is 0. Hence 0 base 10 = 0 base 4 (or whatever > 0). Saying this, in one of test of this problem exist the next code:

@test 'single zero' {
    [[ $BATS_RUN_SKIPPED == "true" ]] || skip
    run bash all_your_base.sh 10 "0" 2
    assert_success
    assert_output ""
}

and It must be output 0. Because zero is zero in whatever base greater of zero.

Agreed: this is not what should be expected.

Please create an issue (or even better, make a PR!) on the bash repo.

Hi Glenn, excuse me the ignorance, What is a PR? and yes I want to create it for get involved a more tiny in exercism.

Please tell me how. Thanks.

“PR” is a Github Pull Request: you make a change to the git repository and submit it for code review using a pull request.

If you are not familiar with git, I would strongly recommend you look for some tutorials online.

Creating a pull request - GitHub Docs may get you started.

I will consult how since the application is necessary. I saw the same problem in tcl but didn’t report it, just made the program pass the test to move on.

Thanks Isaac. I’m reading now. I hope soon have made the PR.

@gleenJ and @IsaacG. Well I see fixed the json on Github. Isn’t necessary my PR, I believe.

problem-specifications/canonical-data.json at main · exercism/problem-specifications · GitHub is the problem spec. Tracks, like bash, pull test data from there. As you have properly identified, the bash track test has a different value from what is in the problem spec. So there is an issue in the bash tests and a fix would be welcome.

Thanks @IsaacG, I want make it but I am a newbie in this works. I have to review how it works. I am now lose: I forked the problem-specification, Do I have to fork bash too?

Or, I can to edit directly…

I have made my first contribution to exercism ;-).

1 Like

It will be good to give the link that that here.

Ok, @kotp Update all_your_base.bats by ljsr · Pull Request #630 · exercism/bash · GitHub If lack something please tell me. I am beginning in the use of git hub.

This looks good so far! The updated test looks much better.

However, all the exercises have an example solution. If the tests change, the example may also need to change so the example solution still passes.

» ./bin/validate_one_exercise exercises/practice/all-your-base
Processing all-your-base
 ✓ single bit to one decimal
 ✓ binary to single decimal
 ✓ single decimal to binary
 ✓ binary to multiple decimal
 ✓ decimal to binary
 ✓ trinary to hexadecimal
 ✓ hexadecimal to trinary
 ✓ 15 bit integer
 ✓ empty list
 ✗ single zero
   (from function `assert_output' in file bats-extra.bash, line 394,
    in test file all_your_base.bats, line 73)
     `assert_output "0"' failed

   -- output differs --
   expected : 0
   actual   :
   --

 ✗ multiple zeroes
   (from function `assert_output' in file bats-extra.bash, line 394,
    in test file all_your_base.bats, line 80)
     `assert_output "0"' failed

   -- output differs --
   expected : 0
   actual   :
   --

The example solution lives at exercises/practice/all-your-base/.meta/example.sh

Thanks @IsaacG, I go to make it.

The change is maked: addition to code of all_your_base.sh.
The PR: Update example.sh by ljsr · Pull Request #631 · exercism/bash · GitHub

  1. Could you use (( for numeric comparisons?
  2. Both changes should be part of the same PR. You can add new commits to the same branch and push those commits. That should update the PR.

Thanks @IsaacG I make the change. For now I am trying to locate me in git from console with the help of @kotp (I am reviewing the complete extra rapid course that he gives me yesterday).

Good luck :slight_smile:

It looks like you got both the needed changes, but they just need to be in the same PR. You can update existing PRs without creating new ones.

Minor nit: (( $decimal == 0 )) should be (( decimal == 0 )) similar to how all the other variables are handled in the other ((.

Oh, yes. I have to accustomed to it. Thanks a lot!