aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/runtests.jl19
-rw-r--r--test/test_gs.jl15
-rw-r--r--test/test_mime.jl28
-rw-r--r--test/test_objects.jl32
4 files changed, 94 insertions, 0 deletions
diff --git a/test/runtests.jl b/test/runtests.jl
index c723586..03eb48f 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -1,7 +1,23 @@
+println("Importing libs...")
include("../src/PyX.jl")
using PyX
+using LaTeXStrings
+using Base.Test
+##### Setup Common Objects
+println("Creating test objects...")
+include("test_objects.jl")
+
+##### MIME and Ghostscript output
+println("MIME and Ghostscript tests...")
+
+include("test_gs.jl")
+include("test_mime.jl")
+
+##### Run all the examples
+
+println("Drawing...")
include("../examples/drawing/arrow.jl")
#include("../examples/drawing/metapost.jl") # Python3 only?
include("../examples/drawing/pathitem.jl")
@@ -15,6 +31,7 @@ include("../examples/drawing2d/insert.jl")
include("../examples/drawing2d/parallel.jl")
include("../examples/drawing2d/smoothed.jl")
+println("Graphs...")
include("../examples/splitgraphs/minimal.jl")
include("../examples/splitgraphs/splitatvalue.jl")
@@ -39,7 +56,9 @@ include("../examples/graphstyles/usesymbol.jl")
include("../examples/graphstyles/errorbar.jl")
include("../examples/graphstyles/density.jl")
+println("3D Graphs...")
include("../examples/3dgraphs/bar.jl")
include("../examples/3dgraphs/color.jl")
include("../examples/3dgraphs/grid.jl")
include("../examples/3dgraphs/surface.jl")
+
diff --git a/test/test_gs.jl b/test/test_gs.jl
new file mode 100644
index 0000000..1004640
--- /dev/null
+++ b/test/test_gs.jl
@@ -0,0 +1,15 @@
+
+function try_gs(el)
+
+ writeGSfile(el, "/tmp/asdfasdf2.png", "png16m")
+ writeGSfile(el, "/tmp/asdfasdf2.jpeg", "jpeg")
+ pipeGS(el)
+ pipeGS(el, "png16m")
+ pipeGS(el, "jpeg")
+ true
+end
+
+@test try_gs(c)
+@test try_gs(g)
+@test try_gs(g3d)
+
diff --git a/test/test_mime.jl b/test/test_mime.jl
new file mode 100644
index 0000000..12c1e7c
--- /dev/null
+++ b/test/test_mime.jl
@@ -0,0 +1,28 @@
+
+function try_mime(el)
+
+ for m in (MIME("application/pdf"),
+ MIME("application/eps"),
+ MIME("application/postscript"),
+ MIME("image/png"),
+ MIME("image/jpeg"),
+ )
+ @assert mimewritable(m, c)
+ open("/dev/null", "w") do f
+ writemime(f, m, el)
+ end
+ end
+
+ if mimewritable(MIME("image/svg+xml"), el)
+ stringmime(MIME("image/svg+xml"), el)
+ open("/tmp/asdfasfd.svg", "w") do f
+ writemime(f, MIME"image/svg+xml"(), el)
+ end
+ end
+ true
+end
+
+@test try_mime(c)
+@test try_mime(g)
+@test try_mime(g3d)
+
diff --git a/test/test_objects.jl b/test/test_objects.jl
new file mode 100644
index 0000000..cf3f3dd
--- /dev/null
+++ b/test/test_objects.jl
@@ -0,0 +1,32 @@
+
+# PyxCanvas
+c = canvas.canvas()
+stroke(c, path.curve(0, 0, 0, 4, 2, 4, 3, 3),
+ [style_linewidth.THICK, style_linestyle.dashed, color_rgb.blue,
+ deco.earrow([deco.stroked([color_rgb.red, style_linejoin.round]),
+ deco.filled([color_rgb.green])], size=1)])
+
+@test typeof(c) == PyxCanvas
+
+# graph.graphxy
+g = graph.graphxy(width=8,
+ x=graph_axis.log(min=1e-1, max=1e4, title=L"$x$-axis"),
+ y=graph_axis.lin(max=5, title=L"$y$-axis"))
+plot(g, graph_data_function("y(x)=tan(log(1/x))**2"))
+
+@test typeof(g) == PyxCanvas
+
+# graph.graphxyz
+g3d = graph.graphxyz(0, 0, size=5,
+ x=graph_axis.bar(),
+ y=graph_axis.bar(),
+ z=nothing,
+ z2=graph_axis.lin())
+plot(g3d, graph_data.data(graph_data.points([[1 1 1.4];
+ [1 2 1.8];
+ [2 1 -0.5];
+ [2 2 0.9]]), xname=1, yname=2, z2=3),
+ [graph_style.barpos(fromvalue=0, frompathattrs=nothing),
+ graph_style.bar(barattrs=[style_linejoin.bevel])])
+
+@test typeof(g3d) == PyxCanvas