-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(gd)!: New test set and its first test
The gd test set only runs on LuaTeX. `pgfgd-debug.lua` adds debugging code to `InterfaceToDisplay` functions which helps in checking tests based on states of display layer (Lua), rather than box content. Signed-off-by: muzimuzhi <[email protected]>
- Loading branch information
Showing
6 changed files
with
154 additions
and
0 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
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,5 @@ | ||
-- Tests for graph drawing (gd) library | ||
|
||
stdengine = "luatex" | ||
checkengines = {"luatex"} | ||
testfiledir = "testfiles-gd" |
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,39 @@ | ||
local InterfaceToDisplay = pgf.gd.interface.InterfaceToDisplay | ||
|
||
--- Wrap InterfaceToDisplay functions to prepend debugging code | ||
local createVertex = InterfaceToDisplay.createVertex | ||
-- here `...` is a vararg expression, | ||
-- see https://www.lua.org/manual/5.3/manual.html#3.4.11 | ||
function InterfaceToDisplay.createVertex(...) | ||
local name = ... | ||
debug("Create vertex '%s'", name) | ||
createVertex(...) | ||
end | ||
|
||
local createEdge = InterfaceToDisplay.createEdge | ||
function InterfaceToDisplay.createEdge(...) | ||
local tail, head, direction = ... | ||
debug("Create edge '%s' from '%s' to '%s'", direction, tail, head) | ||
createEdge(...) | ||
end | ||
|
||
-- this generates too many debug lines | ||
-- local createEvent = InterfaceToDisplay.createEvent | ||
-- function InterfaceToDisplay.createEvent(...) | ||
-- local kind = ... | ||
-- debug("Create event '%s'", kind) | ||
-- return createEvent(...) | ||
-- end | ||
|
||
local addToVertexOptions = InterfaceToDisplay.addToVertexOptions | ||
function InterfaceToDisplay.addToVertexOptions(...) | ||
local name = ... | ||
debug("Add options to vetex '%s'", name) | ||
addToVertexOptions(...) | ||
end | ||
|
||
|
||
-- helper | ||
function debug(format_str, ...) | ||
tex.sprint(string.format("\\pgfgdluainfo{" .. format_str .. "}", ...)) | ||
end |
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,18 @@ | ||
% This file should be loaded _after_ graphdrawing. | ||
\input regression-test.tex | ||
|
||
\catcode`\@=11 % \makeatletter | ||
|
||
\def\pgfgdBeforeBeginDocument{ | ||
% redirect error | ||
\def\pgfutil@packageerror#1#2#3{\immediate\write17{Package #1 Error: #2.}} | ||
|
||
% new message type "info" | ||
\def\pgftest@genericinfo#1#2{\immediate\write17{#1 Info: #2.}} | ||
\def\pgfgdluainfo{\pgftest@genericinfo{Gd Lua layer}} | ||
|
||
% insert debugging code | ||
\directlua{dofile('pgfgd-debug.lua')} | ||
} | ||
|
||
\catcode`\@=12 % \makeatother |
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,41 @@ | ||
\documentclass{minimal} | ||
\input{pgfgd-regression-test} | ||
|
||
\RequirePackage{tikz} | ||
\usetikzlibrary{graphs, graphdrawing} | ||
\usegdlibrary{layered} | ||
|
||
\pgfgdBeforeBeginDocument | ||
\begin{document} | ||
|
||
\START | ||
|
||
% use all five edge kinds | ||
\def\testgraph{ a -> {b, c <-> d} -- e <- f; a -!- f; } | ||
\SEPARATOR | ||
\TYPE{Graph: \testgraph} | ||
\SEPARATOR | ||
|
||
\BEGINTEST{Non-empty `name prefix`} | ||
\tikzpicture[name prefix=x-] | ||
\graph[layered layout] { [parse/.expand once=\testgraph] }; | ||
|
||
% works | ||
\path (b) (x-b); | ||
\path[name prefix=] (x-b); | ||
\path[name prefix=y-] (x-b); | ||
|
||
% throws errors | ||
\path[name prefix=] (b); | ||
\endtikzpicture | ||
\ENDTEST | ||
|
||
\BEGINTEST{Empty `name prefix`} | ||
\tikzpicture | ||
\graph[layered layout] { [parse/.expand once=\testgraph] }; | ||
\path (b); | ||
\path[name prefix=z-] (b); | ||
\endtikzpicture | ||
\ENDTEST | ||
|
||
\END |
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,48 @@ | ||
This is a generated file for the l3build validation system. | ||
Don't change this file in any respect. | ||
============================================================ | ||
Graph: a -> {b, c <-> d} -- e <- f; a -!- f; | ||
============================================================ | ||
============================================================ | ||
TEST 1: Non-empty `name prefix` | ||
============================================================ | ||
Gd Lua layer Info: Create vertex 'x-a'. | ||
Gd Lua layer Info: Create vertex 'x-b'. | ||
Gd Lua layer Info: Create vertex 'x-c'. | ||
Gd Lua layer Info: Create vertex 'x-d'. | ||
Gd Lua layer Info: Create edge '<->' from 'x-c' to 'x-d'. | ||
Gd Lua layer Info: Create edge '->' from 'x-a' to 'x-b'. | ||
Gd Lua layer Info: Create edge '->' from 'x-a' to 'x-c'. | ||
Gd Lua layer Info: Create vertex 'x-e'. | ||
Gd Lua layer Info: Create edge '--' from 'x-b' to 'x-e'. | ||
Gd Lua layer Info: Create edge '--' from 'x-d' to 'x-e'. | ||
Gd Lua layer Info: Create vertex 'x-f'. | ||
Gd Lua layer Info: Create edge '<-' from 'x-e' to 'x-f'. | ||
Gd Lua layer Info: Add options to vetex 'x-a'. | ||
Gd Lua layer Info: Add options to vetex 'x-a'. | ||
Gd Lua layer Info: Add options to vetex 'x-f'. | ||
Gd Lua layer Info: Add options to vetex 'x-f'. | ||
Gd Lua layer Info: Create edge '-!-' from 'x-a' to 'x-f'. | ||
Package pgf Error: No shape named `b' is known. | ||
============================================================ | ||
============================================================ | ||
TEST 2: Empty `name prefix` | ||
============================================================ | ||
Gd Lua layer Info: Create vertex 'a'. | ||
Gd Lua layer Info: Create vertex 'b'. | ||
Gd Lua layer Info: Create vertex 'c'. | ||
Gd Lua layer Info: Create vertex 'd'. | ||
Gd Lua layer Info: Create edge '<->' from 'c' to 'd'. | ||
Gd Lua layer Info: Create edge '->' from 'a' to 'b'. | ||
Gd Lua layer Info: Create edge '->' from 'a' to 'c'. | ||
Gd Lua layer Info: Create vertex 'e'. | ||
Gd Lua layer Info: Create edge '--' from 'b' to 'e'. | ||
Gd Lua layer Info: Create edge '--' from 'd' to 'e'. | ||
Gd Lua layer Info: Create vertex 'f'. | ||
Gd Lua layer Info: Create edge '<-' from 'e' to 'f'. | ||
Gd Lua layer Info: Add options to vetex 'a'. | ||
Gd Lua layer Info: Add options to vetex 'a'. | ||
Gd Lua layer Info: Add options to vetex 'f'. | ||
Gd Lua layer Info: Add options to vetex 'f'. | ||
Gd Lua layer Info: Create edge '-!-' from 'a' to 'f'. | ||
============================================================ |