-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
64ce3cf
commit be4727e
Showing
10 changed files
with
164 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[Typstry] | ||
instability_check = "error" |
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,12 @@ | ||
|
||
module TestAqua | ||
|
||
using Aqua: test_all, test_ambiguities | ||
using Typstry | ||
|
||
function test() | ||
test_all(Typstry; ambiguities = false) | ||
test_ambiguities(Typstry) | ||
end | ||
|
||
end # TestAqua |
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,11 @@ | ||
|
||
module TestDatesExtension | ||
|
||
using Dates: Dates | ||
using Typstry | ||
|
||
function test() | ||
|
||
end | ||
|
||
end # TestDatesExtension |
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,44 @@ | ||
|
||
module TestDocumenter | ||
|
||
using Base: get_extension, disable_logging | ||
using Dates: Dates | ||
using Documenter: DocMeta.setdocmeta!, doctest | ||
using Logging: Debug, Info, disable_logging | ||
using Markdown: Markdown | ||
using LaTeXStrings: LaTeXStrings | ||
using Preferences: set_preferences! | ||
using Typstry | ||
|
||
const extensions = [:Dates, :LaTeXStrings, :Markdown] | ||
|
||
function _test(_module, x) | ||
setdocmeta!(_module, :DocTestSetup, quote | ||
using Preferences: set_preferences! | ||
using Typstry | ||
$x | ||
|
||
set_preferences!("Typstry", "instability_check" => "error") | ||
end; recursive = true) | ||
|
||
# TODO: errors print twice | ||
doctest(_module; manual = "source", testset = "`$_module` Doctests") | ||
end | ||
|
||
function test() | ||
set_preferences!("Typstry", "instability_check" => "error") | ||
disable_logging(Info) | ||
|
||
_test(Typstry, nothing) | ||
|
||
for extension in extensions | ||
_extension = Symbol(extension, "Extension") | ||
_module = get_extension(Typstry, _extension) | ||
|
||
_test(_module, :(using $extension)) | ||
end | ||
|
||
disable_logging(Debug) | ||
end | ||
|
||
end # TestDocumenter |
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,31 @@ | ||
|
||
module TestExplicitImports | ||
|
||
using ExplicitImports: | ||
check_all_explicit_imports_are_public, | ||
check_all_explicit_imports_via_owners, | ||
check_all_qualified_accesses_are_public, | ||
check_all_qualified_accesses_via_owners, | ||
check_no_implicit_imports, | ||
check_no_self_qualified_accesses, | ||
check_no_stale_explicit_imports | ||
using Test: @test | ||
using Typstry | ||
|
||
function test() | ||
@test isnothing(check_all_explicit_imports_are_public(Typstry; ignore = (:MD, :Stateful, | ||
:code_mode, :depth, :escape_raw_string, :indent, :parse, :print_parameters, :show_raw, :workload))) | ||
|
||
for check in ( | ||
check_all_explicit_imports_via_owners, | ||
check_all_qualified_accesses_are_public, | ||
check_all_qualified_accesses_via_owners, | ||
check_no_implicit_imports, | ||
check_no_self_qualified_accesses, | ||
check_no_stale_explicit_imports | ||
) | ||
@test isnothing(check(Typstry)) | ||
end | ||
end | ||
|
||
end # TestExplicitImports |
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,21 @@ | ||
|
||
module TestLaTeXStringsExtension | ||
|
||
using ..TestTypstry: test_modes, test_strings | ||
using LaTeXStrings: @L_str | ||
using Typstry | ||
|
||
const latex = L"a" | ||
|
||
function test() | ||
# test_modes(latex, [ | ||
# "```latex \$a\$ ```", | ||
# "```latex \$a\$ ```", | ||
# "#```latex \$a\$ ```" | ||
# ]) | ||
|
||
# test_strings(latex, "````latex\n a\n \n ````"; | ||
# backticks = 4, block = true, depth = 2, indent_size = 4) | ||
end | ||
|
||
end # TestLaTeXStringsExtension |
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,21 @@ | ||
|
||
module TestMarkdownExtension | ||
|
||
using ..TestTypstry: test_modes, test_strings | ||
using Markdown: Markdown | ||
using Typstry | ||
|
||
const markdown = Markdown.parse("a\\\nb") | ||
|
||
function test() | ||
# test_modes(markdown, [ | ||
# "```markdown a\nb ```", | ||
# "```markdown a\nb ```", | ||
# "#```markdown a\nb ```" | ||
# ]) | ||
|
||
# test_strings(markdown, "````markdown\n a \n b\n `````"; | ||
# backticks = 4, block = true, depth = 2, indent_size = 4) | ||
end | ||
|
||
end # TestMarkdownExtension |
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,63 +1,29 @@ | ||
|
||
using Aqua: test_all, test_ambiguities | ||
using Base: get_extension, disable_logging | ||
using ExplicitImports: | ||
check_all_explicit_imports_are_public, | ||
check_all_explicit_imports_via_owners, | ||
check_all_qualified_accesses_are_public, | ||
check_all_qualified_accesses_via_owners, | ||
check_no_implicit_imports, | ||
check_no_self_qualified_accesses, | ||
check_no_stale_explicit_imports | ||
using Dates: Dates | ||
using Documenter: DocMeta.setdocmeta!, doctest | ||
using LaTeXStrings: LaTeXStrings | ||
using Logging: Debug, Info, disable_logging | ||
using Markdown: Markdown | ||
using Preferences: set_preferences! | ||
using Test: @testset, @test | ||
using Typstry | ||
|
||
_doctest(_module, name) = doctest(_module; manual = "source", testset = "$name.jl Doctests") | ||
module TestTypstry | ||
|
||
_setdocmeta!(_module, x) = setdocmeta!(_module, :DocTestSetup, | ||
:(using Preferences: set_preferences!; using Typstry; $x; set_preferences!("Typstry", "instability_check" => "error")); | ||
recursive = true) | ||
using Test: @test, @testset | ||
|
||
set_preferences!("Typstry", "instability_check" => "error") | ||
|
||
@testset "Aqua.jl" begin | ||
test_all(Typstry; ambiguities = false) | ||
test_ambiguities(Typstry) | ||
end | ||
|
||
_setdocmeta!(Typstry, nothing) | ||
disable_logging(Info) | ||
|
||
@testset "Doctests" begin | ||
_doctest(Typstry, "Typstry") | ||
|
||
for extension in [:Dates, :LaTeXStrings, :Markdown] | ||
_module = get_extension(Typstry, Symbol(extension, "Extension")) | ||
_setdocmeta!(_module, :(using $extension)) | ||
_doctest(_module, extension) | ||
test_modes(x, ss) = @testset "modes" begin | ||
for (mode, s) in zip(instances(Mode), ss) | ||
test_strings(x, s; mode) | ||
end | ||
end | ||
|
||
disable_logging(Debug) | ||
|
||
@testset "ExplicitImports.jl" begin | ||
@test isnothing(check_all_explicit_imports_are_public(Typstry; ignore = (:MD, :Stateful, | ||
:code_mode, :depth, :escape_raw_string, :indent, :parse, :print_parameters, :show_raw, :workload))) | ||
|
||
for check in ( | ||
check_all_explicit_imports_via_owners, | ||
check_all_qualified_accesses_are_public, | ||
check_all_qualified_accesses_via_owners, | ||
check_no_implicit_imports, | ||
check_no_self_qualified_accesses, | ||
check_no_stale_explicit_imports | ||
) | ||
@test isnothing(check(Typstry)) | ||
test_strings(x, s; kwargs...) = @test TypstString(x; kwargs...).text == s | ||
|
||
@testset "Typstry" begin | ||
for description in [ | ||
"Aqua", | ||
"DatesExtension", | ||
"Documenter", | ||
"ExplicitImports", | ||
"LaTeXStringsExtension", | ||
"MarkdownExtension" | ||
] | ||
@testset "$description" include("Test" * description * ".jl").test() | ||
end | ||
end | ||
|
||
end # TestTypstry |