Skip to content

Commit

Permalink
Implement test for TypstString and TypstText
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobjpeters committed Jul 25, 2024
1 parent d8b526e commit 5076d6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions test/TestStrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module TestStrings
import Typstry: context, show_typst
using .Meta: parse
using Test: @test, @testset
using ..TestTypstry: test_strings
using Typstry

# TODO: test string escaping in `@typst_str`, `show`, `print`, `regex`, `TypstText`, etc
Expand All @@ -24,7 +25,7 @@ const x = X()
const x_context = Dict(:x => 1)

context(::X) = x_context
show_typst(io, ::X) = print(io, 1)
show_typst(io, ::X) = print(io, io[:x]::Int)

const pairs = [
typst"" => ""
Expand Down Expand Up @@ -71,9 +72,12 @@ test_equal(f) = test_pairs((ts, s) -> f(ts) == f(s))
@test string(typst_int) == "Typst{Int64}(1)"
end

@testset "`TypstString`" begin end
@testset "`TypstString`" begin
test_strings(TypstString(x), "1")
test_strings(TypstString(x; x = 2), "2")
end

@testset "`TypstText`" begin end
@testset "`TypstText`" begin @test TypstText(x) isa TypstText{X} end

@testset "`@typst_str`" begin end

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test_modes(x, ss) = @testset "modes" begin
end
end

test_strings(x, s; kwargs...) = @test TypstString(x; kwargs...).text == s
test_strings(x, s; kwargs...) = @test TypstString(x; kwargs...) == s

@testset "Typstry" begin
for (description, descriptions) in [
Expand Down

0 comments on commit 5076d6f

Please sign in to comment.