Skip to content

Commit

Permalink
Write some tests for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobjpeters committed Jul 5, 2024
1 parent 8a2e113 commit ac1bc03
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 20 deletions.
65 changes: 65 additions & 0 deletions test/TestCommands.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,69 @@

module TestCommands

using Test: @test, @testset, @test_throws, @test_warn
using Typstry

const tc = typst`help`
const tc_error = typst``
const tc_ignorestatus = ignorestatus(tc_error)

@testset "`Typstry`" begin
@testset "`TypstCommand`" begin end

@testset "`TypstError`" begin end

@testset "`@typst_cmd`" begin end

@testset "`julia_mono`" begin
# TODO: write more tests
@test julia_mono isa String
end

@testset "`render`" begin end
end

@testset "`Base`" begin
@testset "`==`" begin end

@testset "`addenv`" begin end

@testset "`detach`" begin end

@testset "`eltype`" begin @test eltype(TypstCommand) == String end

@testset "`firstindex`" begin @test firstindex(tc) == 1 end

@testset "`getindex`" begin end

@testset "`hash`" begin end

@testset "`ignorestatus`" begin
@test tc_ignorestatus == TypstCommand(tc_error; ignorestatus = true)
@test_warn "error" run(tc_ignorestatus)
end

@testset "`iterate`" begin end

@testset "`keys`" begin end

@testset "`lastindex`" begin end

@testset "`length`" begin end

@testset "`run`" begin
# TODO: write more tests
@test_throws TypstError redirect_stderr(() -> run(tc_error), devnull)
@test_warn "error" try run(tc_error) catch end
end

@testset "`setcpuaffinity`" begin end

@testset "`setenv`" begin end

@testset "`show`" begin end

@testset "`showerror`" begin end
end

end # TestCommands
58 changes: 38 additions & 20 deletions test/TestStrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,52 @@ const x_context = Dict(:x => 1)

context(::X) = x_context

@testset "`Mode`" begin
@test Mode <: Enum
@test instances(Mode) == map(Mode, (0, 1, 2)) == (code, markup, math)
end
@testset "`Typstry`" begin
@testset "`Mode`" begin
@test Mode <: Enum
@test instances(Mode) == map(Mode, (0, 1, 2)) == (code, markup, math)
end

@testset "`Typst`" begin
@test typst == typst
@test typst != Typst(1.0)
@test typeof(typst) == Typst{Int}
@test string(typst) == "Typst{Int64}(1)"
end
@testset "`Typst`" begin
@test typst == typst
@test typst != Typst(1.0)
@test typeof(typst) == Typst{Int}
@test string(typst) == "Typst{Int64}(1)"
end

@testset "`TypstString`" begin end

@testset "`TypstString`" begin end
@testset "`TypstText`" begin end

@testset "`TypstText`" begin end
@testset "`@typst_str`" begin end

@testset "`@typst_str`" begin end
@testset "`context`" begin
@test context(1) == Dict{Symbol, Union{}}()
@test context(X()) == x_context
@test context(typst) == default_context
@test context(Typst(x)) == merge(default_context, x_context)
end

@testset "`context`" begin
@test context(1) == Dict{Symbol, Union{}}()
@test context(X()) == x_context
@test context(typst) == default_context
@test context(Typst(x)) == merge(default_context, x_context)
@testset "`show_typst`" begin end
end

@testset "`show_typst`" begin end
@testset "`Base`" begin
@testset "`IOBuffer`" begin end

@testset "`codeunit`" begin end

@testset "`isvalid`" begin end

@testset "`Base`" begin end
@testset "`iterate`" begin end

@testset "`ncodeunits`" begin end

@testset "`pointer`" begin end

@testset "`repr`" begin end

@testset "`show`" begin end
end

end # TestStrings

0 comments on commit ac1bc03

Please sign in to comment.