-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Char tests #10054
Char tests #10054
Conversation
Per #9493, wrote tests for base/char.jl since the coverage is pretty low. This should be tests for all but bitwise operations.
Great! Could you wrap this in a let block so the test variables do not leak scope? |
Can I just put |
I think only at the top and bottom. While you're at it, could you add tests for a few non-ASCII characters in different Unicode planes? |
lowerchars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] | ||
upperchars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] | ||
|
||
#char(x::FloatingPoint) = char(round(UInt32,x)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though you're certainly right to test it, this behavior doesn't make any sense to me. Can we deprecate this function in 0.4? Or should we get rid of it as part of #1470?
@nalimilan: Yes, I can add a few unicode planes as well |
I'm pretty sure that if any variables used in the let block have been previously defined (globally), the previous definition will leak into the let block. This has caused testing problems previously (though it's tough to find the exact issue). |
@kmsquire Is this a suggestion to not define global variables, but rather put the arrays on each for loop? |
Add a let block around the entire test base to try to avoid leaking variables into other tests, add plane1 and plane2 examples
That was in response to the suggestion to put everything in a let block, I remember that big being hard to track down, because it only occurred when One solution is to define all local variables as let variables. Another is On Tuesday, February 3, 2015, Randy Zwitch notifications@github.com wrote:
|
Fix Travis CI error
One thing to note is that if an entire test file is wrapped in a |
@randyzwitch, here's a more concrete example of what I've been saying: julia> const a = 20.0
20.0
julia> let
a=10
end
10
julia> a
10 I don't know if there was an issue open, but here's a note of the previous problem I alluded to when variables have been previously defined globally and then used. |
I find it helpful to make a new module for every test file, since this fixes the scope issue without so much repetition. |
Thanks for adding Unicode chars! |
So where do we fall out on this? I have the time and desire to contribute more, and tests seem to be the easiest way for me to do it. But @JeffBezanson commented on undesirable property of let blocks in error reporting, @johnmyleswhite is talking about new modules, @kmsquire is talking about scope leaks... Should I just keep submitting PR's and we'll sort out each one? |
I would use a module wrapper for further PRs for now. With a module you'll On Wed, Feb 4, 2015 at 12:43 PM, Randy Zwitch notifications@github.com
|
Yes, modules seems like a reasonable way to go. |
Ref #9798 which doesn't quite work yet. For now more PR's with test additions are welcome, I don't think we have a single best answer for how to structure them yet. Though for the next one, 4-space indent would be good :) |
Juno uses 2 spaces, wasn't even something I even considered |
Thanks for informing me of that, now I know where to file an issue. |
Per #9493, wrote tests for base/char.jl since the coverage is pretty
low. This should be tests for all but bitwise operations.