-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
91 additions
and
32 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
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 |
---|---|---|
@@ -1,46 +1,50 @@ | ||
const td = mktempdir() * "/" | ||
JuDoc.JD_FOLDER_PATH[] = td | ||
J.JD_FOLDER_PATH[] = td | ||
|
||
JuDoc.def_GLOB_VARS() | ||
JuDoc.def_GLOB_LXDEFS() | ||
J.def_GLOB_VARS() | ||
J.def_GLOB_LXDEFS() | ||
|
||
@testset "Paths" begin | ||
P = JuDoc.set_paths!() | ||
|
||
@test JuDoc.JD_PATHS[:f] == td | ||
@test JuDoc.JD_PATHS[:in] == td * "src/" | ||
@test JuDoc.JD_PATHS[:in_css] == td * "src/_css/" | ||
@test JuDoc.JD_PATHS[:in_html] == td * "src/_html_parts/" | ||
@test JuDoc.JD_PATHS[:libs] == td * "libs/" | ||
@test JuDoc.JD_PATHS[:out] == td * "pub/" | ||
@test JuDoc.JD_PATHS[:out_css] == td * "css/" | ||
@test P == JuDoc.JD_PATHS | ||
|
||
mkdir(JuDoc.JD_PATHS[:in]) | ||
mkdir(JuDoc.JD_PATHS[:in_pages]) | ||
mkdir(JuDoc.JD_PATHS[:libs]) | ||
mkdir(JuDoc.JD_PATHS[:in_css]) | ||
mkdir(JuDoc.JD_PATHS[:in_html]) | ||
P = J.set_paths!() | ||
|
||
@test J.JD_PATHS[:f] == td | ||
@test J.JD_PATHS[:in] == td * "src/" | ||
@test J.JD_PATHS[:in_css] == td * "src/_css/" | ||
@test J.JD_PATHS[:in_html] == td * "src/_html_parts/" | ||
@test J.JD_PATHS[:libs] == td * "libs/" | ||
@test J.JD_PATHS[:out] == td * "pub/" | ||
@test J.JD_PATHS[:out_css] == td * "css/" | ||
@test P == J.JD_PATHS | ||
|
||
mkdir(J.JD_PATHS[:in]) | ||
mkdir(J.JD_PATHS[:in_pages]) | ||
mkdir(J.JD_PATHS[:libs]) | ||
mkdir(J.JD_PATHS[:in_css]) | ||
mkdir(J.JD_PATHS[:in_html]) | ||
end | ||
|
||
@testset "Set vars" begin | ||
d = Dict{String, Pair{Any, Tuple}}( | ||
"a" => 0.5 => (Real,), | ||
"b" => "hello" => (String, Nothing)) | ||
JuDoc.set_vars!(d, ["a"=>"5", "b"=>"nothing"]) | ||
J.set_vars!(d, ["a"=>"5", "b"=>"nothing"]) | ||
|
||
@test d["a"].first == 5 | ||
@test d["b"].first == nothing | ||
@test (@test_logs (:warn, "Doc var 'a' (type(s): (Real,)) can't be set to value 'blah' (type: String). Assignment ignored.") JuDoc.set_vars!(d, ["a"=>"\"blah\""])) == nothing | ||
@test (@test_logs (:error, "I got an error (of type 'DomainError') trying to evaluate '__tmp__ = sqrt(-1)', fix the assignment.") JuDoc.set_vars!(d, ["a"=> "sqrt(-1)"])) == nothing | ||
@test (@test_logs (:warn, "Doc var name 'blah' is unknown. Assignment ignored.") JuDoc.set_vars!(d, ["blah"=>"1"])) == nothing | ||
|
||
@test_logs (:warn, "Doc var 'a' (type(s): (Real,)) can't be set to value 'blah' (type: String). Assignment ignored.") J.set_vars!(d, ["a"=>"\"blah\""]) | ||
@test_logs (:error, "I got an error (of type 'DomainError') trying to evaluate '__tmp__ = sqrt(-1)', fix the assignment.") J.set_vars!(d, ["a"=> "sqrt(-1)"]) | ||
@test_logs (:warn, "Doc var name 'blah' is unknown. Assignment ignored.") J.set_vars!(d, ["blah"=>"1"]) | ||
end | ||
|
||
|
||
@testset "Def+coms" begin # see #78 | ||
st = raw""" | ||
@def title = "blah" <!-- comment --> | ||
@def hasmath = false | ||
etc | ||
""" | ||
""" * J.EOS | ||
(m, jdv) = J.convert_md(st) | ||
@test jdv["title"].first == "blah" | ||
@test jdv["hasmath"].first == false | ||
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
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,55 @@ | ||
# This is a test file to make codecov happy, technically all of the | ||
# tests here are already done / integrated within other tests. | ||
|
||
@testset "strings" begin | ||
st = "blah" | ||
|
||
@test J.str(st) == "blah" | ||
|
||
sst = SubString("blahblah", 1:4) | ||
@test sst == "blah" | ||
@test J.str(sst) == "blahblah" | ||
|
||
sst = SubString("blah✅💕and etcσ⭒ but ∃⫙∀ done", 1:27) | ||
@test J.to(sst) == 27 | ||
end | ||
|
||
|
||
@testset "ocblock" begin | ||
|
||
st = "This is a block <!--comment--> and done" | ||
τ = J.find_tokens(st, J.MD_TOKENS, J.MD_1C_TOKENS) | ||
ocb = J.OCBlock(:COMMENT, (τ[1]=>τ[2])) | ||
@test J.otok(ocb) == τ[1] | ||
@test J.ctok(ocb) == τ[2] | ||
end | ||
|
||
|
||
@testset "isexactly" begin | ||
steps, b, λ = J.isexactly("<!--") | ||
@test steps == length("<!--") - 1 # minus start char | ||
@test b == false | ||
@test λ("<!--") == true | ||
@test λ("<--") == false | ||
|
||
steps, b, λ = J.isexactly("\$", ['\$']) | ||
@test steps == 1 | ||
@test b == true | ||
@test λ("\$\$") == true | ||
@test λ("\$a") == false | ||
@test λ("a\$") == false | ||
|
||
rs = "\$" | ||
steps, b, λ = J.isexactly(rs, ['\$'], false) | ||
@test steps == nextind(rs, prevind(rs, lastindex(rs))) | ||
@test b == true | ||
@test λ("\$\$") == false | ||
@test λ("\$a") == true | ||
@test λ("a\$") == false | ||
|
||
steps, b, λ = J.incrlook(isletter) | ||
@test steps == 0 | ||
@test b == false | ||
@test λ('c') == true | ||
@test λ('[') == false | ||
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