-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
@static && || syntax #17498
@static && || syntax #17498
Conversation
build scripts don't really need |
@@ -56,12 +56,13 @@ Partially evaluates an expression at parse time. | |||
For example, `@static is_windows() ? foo : bar` will evaluate `is_windows()` and insert either `foo` or `bar` into the expression. | |||
This is useful in cases where a construct would be invalid on other platforms, | |||
such as a `ccall` to a non-existent function. | |||
`@static if is_apple() foo end` and `@static is_linux() <&&,||> foo` are also valid syntax. |
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.
probably need a make docs
run then commit the rst
docs are committed and checks have passed |
@test (@static if true 1 end) == 1 | ||
@test (@static if false 1 end) == nothing | ||
@test (@static true && 1) == 1 | ||
@test (@static false && 1) == nothing |
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.
This should actually return false? Similarly the ||
one below should return true.
thanks @yuyichao. fixed. tests are passing on 64-bit. |
now that the flurry of 0.5 activity has passed, come someone please look over this again? |
LGTM, although I'm not 100% on what needs to be done to add a file to the test suite these days. |
was done correctly here, but these are short and could easily have been added to one of the existing files |
bump? rebase? |
@@ -0,0 +1,8 @@ | |||
@test (@static true ? 1 : 2) == 1 |
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.
still better to just add these lines to one of the existing test files imo
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.
which one?
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.
how about test/misc.jl. there are only a couple of uses of at-static in existing tests, it doesn't appear to have dedicated unit tests of its own yet
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.
i'm easy. by putting it in test/osutils.jl i was just trying to mimic the pattern that there is generally a 1:1 correspondence between base/*.jl
and test/*.jl
. will make the change as soon as the current CI finishes so i know if there are any other problems.
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.
The other alternative is keeping an osutils.jl test file but making it worth the cost of spawning another test process by moving a few of the existing relevant os tests from other files into it.
@test (@static false ? 1 : 2) == 2 | ||
@test (@static if true 1 end) == 1 | ||
@test (@static if false 1 end) == nothing | ||
@test (@static true && 1) == 1 |
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.
oh, I'd also make these tests more picky by using ===
to check type equality too
expands @static syntax to include short-circuit evaluation, to facilitate making the build scripts for some packages (e.g. ImageMagick) more concise.