-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from rafaelbailo/main
Automatically test julia examples in README.md
- Loading branch information
Showing
4 changed files
with
42 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Satisfiability | ||
using Test | ||
|
||
function test_julia_examples_in_markdown(path) | ||
file = read(path, String) | ||
file_by_code_blocks = split(file, "```julia")[2:end] | ||
possible_examples = map(s -> first(split(s, "```")), file_by_code_blocks) | ||
for example ∈ possible_examples | ||
quote_example = "begin\n" * example * "\nend" | ||
parsed = | ||
@test_nowarn Meta.parse(quote_example) | ||
@test try | ||
eval(parsed) | ||
true | ||
catch e | ||
showerror(stdout, e, catch_backtrace()) | ||
println() | ||
false | ||
end | ||
end | ||
end | ||
|
||
@testset "Test README.md examples" begin | ||
using Satisfiability | ||
test_julia_examples_in_markdown("../README.md") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters