-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement tests #10
Comments
I would rather not use bats for this, or any framework for that matter. I will implement testing myself in pure bash. That will be next on the list. So my order now is:
|
I have begun implementing a testing script here, as I've hit a bit of a snag with the output formatting: |
I like it a lot. Especially the fact that it's just one file and it runs the tests when the file is run. Simple. One thing I think would be better if we changed the debug outputs. It outputs directly to repo root and git sees the debug files as changes. We can have a separate folder named To keep the empty dir in repo but ignore the files inside, I usually create a file named
Or to keep it simple, mkdir can be added at the beginning of the script to make sure the debug dir is created and the debug dir can be in a variable which can be used inside tests. |
Also, I think adding something like this would allow it to be used from outside the dir: repo_root="$(dirname $(realpath $0))"
exe="${repo_root}/bcalc" |
It doesn't? I added this to the # Debug files created by the test script
*debug* And it doesn't pick them up.
I don't really see the point in running it out of the repo though. |
It actually does, I'm an idiot and forgot to commit the |
Fixed. |
I see. Great. It's now working, debug files are not seen by git. But still I think if there are many failures for some reason it will look like a mess. A separate directory would be nice to have. |
You are right about that for sure. |
I think it's good enough now to be merged into master, what do you think?
|
Yeah. I think it's better than I expected. Single file, no deps to test. Just needs bash and works with it. Best fit for a project like this. 💯 One small thing I noticed: if ! [ -d "./debug" ]; then mkdir debug; else :; fi Maybe this |
Oh and another thing. I think you should add a parenthesis inside parenthesis test. |
Oh shoot, yeah you're right. I always feel compelled to write an else case. |
The parser hasn't been re-written yet to accomodate for that. |
I'll keep this issue open until I feel we we have enough tests. We can use this issue to come up with more tests for |
I think that's a great idea. I had some tests in my bats based PR if you want to check out. Now that I checked it, I think modulus may have been missed in your tests. Another test I had is the decimal fail test. Maybe this can be used for testing errors as well, for checking if it triggers error messages on faulty user inputs. e.g.
|
Just made both basic PEMDAS tests pass. |
I just realized I forgot to respond to your last comment. //-_-// |
Added an error message for this.
This as well. What's wrong with the other ones though? The error messages for the others seem just as I intended. |
No, no problem there. I just presented those outputs to be added to tests. Now that the missing error messages are added, I think tests would be much more extensive and dependable. I really like where this is going. I can't believe all this is being done on pure bash. 👍 |
Another situation I think should have an error message is this one:
And just thought about this one, what if someone has a calculation starting with a negative number? Like this...
|
🤦 My bad, that totally slipped my mind. I can fix that real quick.
I can think of how I might go about it, but I'm not certain. So this one may or may not take a bit.
Ah, oke doke.
I agree. And same! |
Fixed. :) |
Added an error message! The answer was surprisingly simple. |
I was right, I broke starting with a negative number. However I have fixed it now. :) |
No problem, happens to everyone. :) |
We usually have to test ourselves when we have new features to see if that broke any old features. What if we had tests to do that automatically for us?
Found out that
bats
is a good testing system for bash. I have some tests written for it in a branch here.I'll push a PR shortly for your consideration, but I was thinking if bats is even too much for this project. I mean, if it can be done with pure bash only that would be awesome in a way.
The text was updated successfully, but these errors were encountered: