Skip to content

Commit

Permalink
rot13: Autodetect bonus macros in tests (JuliaLang#231)
Browse files Browse the repository at this point in the history
This means markers and users don't need to fiddle with the tests file.
  • Loading branch information
cmcaine authored May 13, 2020
1 parent 242d3b9 commit 3ef2344
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion exercises/rotational-cipher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This is a good exercise to experiment with non-standard string literals and meta

A short introduction to non-standard string literals can be found in this [blog post](https://web.archive.org/web/20170625222109/https://iaindunning.com/blog/julia-unicode.html). A detailed metaprogramming guide can be found in the [manual](https://docs.julialang.org/en/v1/manual/metaprogramming/).

You can extend your solution by adding the functionality described below. To test your solution, you have to remove the comments at the end of `runtests.jl` before running the tests as usual.
You can extend your solution by adding the functionality described below.

Bonus A only requires basics as outlined in the blog post. Bonus B requires significantly more knowledge of metaprogramming in Julia.

Expand Down
4 changes: 2 additions & 2 deletions exercises/rotational-cipher/rotational-cipher.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions exercises/rotational-cipher/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ end

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Additional exercises #
# Change @test_skip to @test for the optional bonus exercises from HINTS.md #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# Bonus A
@testset "Bonus A: string literal R13" begin
@test_skip R13"The quick brown fox jumps over the lazy dog." == "Gur dhvpx oebja sbk whzcf bire gur ynml qbt."
if isdefined(Main, Symbol("@R13_str"))
@eval @testset "Bonus A: string literal R13" begin
@test R13"The quick brown fox jumps over the lazy dog." == "Gur dhvpx oebja sbk whzcf bire gur ynml qbt."
end
end

# Bonus B
@testset "Bonus B: string literals" begin
@test_skip R5"OMG" == "TRL"
@test_skip R4"Testing 1 2 3 testing" == "Xiwxmrk 1 2 3 xiwxmrk"
@test_skip R21"Let's eat, Grandma!" == "Gzo'n zvo, Bmviyhv!"
@test_skip R13"The quick brown fox jumps over the lazy dog." == "Gur dhvpx oebja sbk whzcf bire gur ynml qbt."
if isdefined(Main, Symbol("@R1_str"))
@eval @testset "Bonus B: string literals" begin
@test R5"OMG" == "TRL"
@test R4"Testing 1 2 3 testing" == "Xiwxmrk 1 2 3 xiwxmrk"
@test R21"Let's eat, Grandma!" == "Gzo'n zvo, Bmviyhv!"
@test R13"The quick brown fox jumps over the lazy dog." == "Gur dhvpx oebja sbk whzcf bire gur ynml qbt."
end
end

0 comments on commit 3ef2344

Please sign in to comment.