\input regression-test.tex
\documentclass{article}
\usepackage{tikzphysics}
\newdimen\actual
\newdimen\error
\newcommand{\assertcoord}[5]{%
 \pgfextractx{\actual}{\pgfpointanchor{#1}{#2}}\error=\actual\advance\error by-#3\relax
 \ifdim\error<0pt\error=-\error\fi
 \ifdim\error<.04pt\TYPE{PASS: #5 x}\else\TYPE{FAIL: #5 x got \the\actual}\fi
 \pgfextracty{\actual}{\pgfpointanchor{#1}{#2}}\error=\actual\advance\error by-#4\relax
 \ifdim\error<0pt\error=-\error\fi
 \ifdim\error<.04pt\TYPE{PASS: #5 y}\else\TYPE{FAIL: #5 y got \the\actual}\fi}
\begin{document}\START
\setbox0=\hbox{\begin{tikzpicture}
\node[fluid tank,outer sep=0pt,fluid width=4cm,fluid height=2cm,fluid left level=.8,fluid right level=.4] (T) {};
\assertcoord{T}{surface-25}{-1cm}{.4cm}{tilted tank quarter}
\assertcoord{T}{surface-50}{0cm}{.2cm}{tilted tank midpoint}
\assertcoord{T}{surface}{0cm}{.2cm}{named tank surface remains midpoint}
\assertcoord{T}{bottom-left-50}{-1.96cm}{-.98cm}{rounded tank corner}
\node[meniscus,outer sep=0pt,fluid width=2cm,fluid height=4cm,fluid level=.6,fluid bend=.2] (M) {};
\assertcoord{M}{surface-50}{0cm}{-.2cm}{concave midpoint}
\node[meniscus,outer sep=0pt,fluid width=2cm,fluid height=4cm,fluid level=.6,fluid bend=-.2] (V) {};
\assertcoord{V}{surface-50}{0cm}{1cm}{convex midpoint}
\node[rotating fluid,outer sep=0pt,fluid width=4cm,fluid height=4cm,fluid level=.4,fluid bend=.3] (R) {};
\assertcoord{R}{surface-25}{-1cm}{-.1cm}{parabola quarter}
\assertcoord{R}{surface-50}{0cm}{-.4cm}{parabola vertex}
\node[fluid cylinder,outer sep=0pt,fluid width=2cm,fluid height=4cm,fluid level=.5] (C) {};
\assertcoord{C}{left-surface}{-1cm}{0cm}{cylinder left contact}
\assertcoord{C}{right-surface}{1cm}{0cm}{cylinder right contact}
\assertcoord{C}{surface-50}{0cm}{0cm}{cylinder diameter midpoint}
\assertcoord{C}{surface-rim-25}{0cm}{.25cm}{cylinder surface ellipse}
\assertcoord{C}{top-25}{0cm}{2cm}{cylinder top ellipse}
\node[pressure element,outer sep=0pt,fluid width=2cm,fluid height=1cm] (P) {};
\assertcoord{P}{inlet-50}{-.85cm}{0cm}{projected inlet centre}
\assertcoord{P}{outlet-50}{.85cm}{0cm}{projected outlet centre}
\node[flow tube,outer sep=0pt,fluid width=4cm,fluid height=2cm,fluid bend=.45] (F) {};
\assertcoord{F}{inlet-50}{-2cm}{0cm}{flow inlet midpoint}
\assertcoord{F}{outlet-50}{2cm}{.45cm}{flow outlet midpoint}
\assertcoord{F}{bottom-50}{0cm}{-.8875cm}{flow lower cubic midpoint}
\assertcoord{F}{top-50}{0cm}{.6625cm}{flow upper cubic midpoint}
\assertcoord{F}{axis-50}{0cm}{-.1125cm}{flow axis midpoint}
\node[liquid ring,outer sep=0pt,fluid width=4cm,fluid tube width=.5cm,fluid angle=0,fluid sweep=90] (L) {};
\assertcoord{L}{outer-25}{0cm}{2cm}{liquid outer quarter}
\assertcoord{L}{inner-50}{-1.5cm}{0cm}{liquid inner half}
\assertcoord{L}{liquid-100}{0cm}{1.75cm}{liquid sector end}
\assertcoord{L}{start-50}{1.75cm}{0cm}{liquid radial midpoint}
\node[u tube,outer sep=0pt,fluid width=2cm,fluid height=4cm,fluid tube width=.3cm,fluid left level=.75,fluid right level=.55] (U) {};
\assertcoord{U}{left-surface-50}{-.85cm}{1cm}{U left liquid midpoint}
\assertcoord{U}{right-surface-50}{.85cm}{.2cm}{U right liquid midpoint}
\assertcoord{U}{surface}{-.85cm}{1cm}{U primary surface on left arm}
\assertcoord{U}{outer-0}{-1cm}{2cm}{U outer starts left lip}
\assertcoord{U}{outer-50}{0cm}{-2cm}{U outer bend bottom}
\assertcoord{U}{outer-100}{1cm}{2cm}{U outer ends right lip}
\assertcoord{U}{inner-50}{0cm}{-1.7cm}{U inner bend bottom}
\node[block,minimum width=4cm,minimum height=2cm] (B) {};
\assertcoord{B}{top-25}{1cm}{1cm}{block top direction}
\assertcoord{B}{left-25}{-2cm}{.5cm}{block left direction}
\node[disk,minimum size=2cm] (D) {$M$};
\assertcoord{D}{rim-0}{1cm}{0cm}{labelled disk rim start}
\assertcoord{D}{rim-25}{0cm}{1cm}{labelled disk rim quarter}
\assertcoord{D}{rim-50}{-1cm}{0cm}{labelled disk rim half}
\node[pulley,minimum size=2cm] (Q) {};
\draw[rope] (-2,-2) to[over pulley=Q] (2,-2);
\TYPE{PASS: private pulley shape retains native tangent routing}
\node[fluid tank,rotate=90,scale=2,fluid width=4cm,fluid height=2cm,fluid left level=.8,fluid right level=.4] (X) at (3,0) {};
\assertcoord{X}{surface-25}{2.2cm}{-2cm}{rotated scaled percentage anchor}
\node[disk,minimum size=4cm] (Later) {};
\assertcoord{D}{rim-25}{0cm}{1cm}{circle geometry remains instance local}
\node[rectangle] (Ordinary) {};
\makeatletter
\ifcsname pgf@anchor@rectangle@top-50\endcsname\TYPE{FAIL: native rectangle polluted}\else\TYPE{PASS: native rectangle unchanged}\fi
\ifcsname pgf@anchor@circle@rim-50\endcsname\TYPE{FAIL: native circle polluted}\else\TYPE{PASS: native circle unchanged}\fi
\makeatother
\node[fluid tank,show anchors,physics debug/anchor list={surface,surface-50}] (Same) {};
\ifnum\value{tikzphysics@debug@markercount}=1
 \TYPE{PASS: equivalent named and percentage anchors share a marker}
\else\TYPE{FAIL: duplicate midpoint marker}\fi
\node[fluid tank,show anchors,physics debug/anchor list={bottom-left-0,bottom-left-50,bottom-left-100}] (Distinct) {};
\ifnum\value{tikzphysics@debug@markercount}=3
 \TYPE{PASS: distinct nearby corner points retain separate markers}
\else\TYPE{FAIL: corner points collapsed}\fi
\end{tikzpicture}}
\pgfdeclarelayer{customback}\pgfdeclarelayer{customfront}
\pgfsetlayers{customback,main,customfront}
\setbox0=\hbox{\begin{tikzpicture}
\node[disk,show anchors,show keys,physics debug/anchor list={center},physics debug/anchor families={rim},physics debug/anchor samples={0,25,50,75,100}] {};
\begin{pgfonlayer}{customback}\draw (0,0)--(1,0);\end{pgfonlayer}
\end{tikzpicture}}
\TYPE{PASS: debug foreground preserves custom picture layers}
\END\end{document}
