Added tests for changing chunk options

pull/35/head
Matti Pastell 2016-04-20 11:30:22 +03:00
parent a1de2c64e2
commit 57fdbe72f9
4 changed files with 97 additions and 2 deletions

View File

@ -9,3 +9,10 @@ result = readall(open("documents/test_hold.md"))
ref = readall(open("documents/test_hold_ref.md"))
@test result == ref
cleanup && rm("documents/test_hold.md")
#Test setting and restoring chunk options
Weave.weave("documents/default_opts.noweb", doctype = "tex")
result = readall(open("documents/default_opts.tex"))
ref = readall(open("documents/default_opts_ref.tex"))
@test result == ref
cleanup && rm("documents/default_opts.tex")

View File

@ -0,0 +1,30 @@
<<>>=
using Gadfly
print(1:10)
plot(x = 1:10)
@
<<>>=
import Weave
Weave.set_chunk_defaults(Dict{Symbol, Any}(
:out_width => "\\0.5linewidth",
:results => "tex"
))
@
<<>>=
print(1:10)
plot(x = 1:10)
@
<<echo = false>>=
Weave.restore_chunk_defaults()
@
<<>>=
print(1:10)
plot(x = 1:10)
@

View File

@ -0,0 +1,58 @@
\begin{juliacode}
using Gadfly
print(1:10)
\end{juliacode}
\begin{juliaout}
1:10
\end{juliaout}
\begin{juliacode}
plot(x = 1:10)
\end{juliacode}
\includegraphics[width=\linewidth]{figures/default_opts_1_1.pdf}
\begin{juliacode}
import Weave
Weave.set_chunk_defaults(Dict{Symbol, Any}(
:out_width => "\\0.5linewidth",
:results => "tex"
))
\end{juliacode}
\begin{juliacode}
print(1:10)
\end{juliacode}
1:10
\begin{juliacode}
plot(x = 1:10)
\end{juliacode}
\includegraphics[width=\0.5linewidth]{figures/default_opts_3_1.pdf}
\begin{juliacode}
print(1:10)
\end{juliacode}
\begin{juliaout}
1:10
\end{juliaout}
\begin{juliacode}
plot(x = 1:10)
\end{juliacode}
\includegraphics[width=\linewidth]{figures/default_opts_5_1.pdf}

View File

@ -9,8 +9,8 @@ using Base.Test
info("Test: Chunk options")
include("chunk_options.jl")
info("Test: hold and term options with plots")
include("test_hold.jl")
info("Test: Chunk options with Gadfly")
include("chunk_opts_gadfly.jl")
# Cache is currently not implemented for new output format
#info("Test: Caching")