\documentclass[a4paper]{article}
\usepackage{german}
\usepackage[utf8]{inputenc}

\usepackage{pgfplots}
\usepackage{pgfplots.assert}

\usetikzlibrary{intersections}
\usepgflibrary{fillbetween}

\begin{document}

\makeatletter

\pgfkeys{
	/TEST/prefix path/.initial=,
}

\def\DRAW#1{%
	\begin{tikzpicture}
		\draw[help lines] (-1,-1) grid (2,1);

		\pgfsetstrokecolor{red}
		\pgfkeysvalueof{/TEST/prefix path}%
		\pgfsetpathandBB#1
		\pgfusepath{stroke}
	\end{tikzpicture}%
}%

\long\def\TEST#1#2#3{%
	\message{REVERSING #1:^^J}
	{
	\def\inputValue{%
		#2%
	}

	#1:

	\DRAW\inputValue
	%
%\tracingmacros=2 \tracingcommands=2
	\message{INPUT : \meaning\inputValue^^J}%
	%
	\pgf@reverse@path{\inputValue}%
	%
	\message{OUTPUT: \meaning\pgfretval^^J}%
	\def\expected{%
		#3%
	}%
	\pgfplotsassertequalstok{\meaning\expected}{\meaning\pgfretval}{expected value was wrong for case #1}
	%
	$\to$\hskip1cm
	\DRAW\pgfretval
	}
}%


\TEST{1}{%
		\pgfsyssoftpath@movetotoken {0.0pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {40.0pt}{20.0pt}%
}{%
		\pgfsyssoftpath@movetotoken {40.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {0.0pt}{0.0pt}%
}


\TEST{2}{%
		\pgfsyssoftpath@movetotoken {0.0pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {40.0pt}{20.0pt}%
		\pgfsyssoftpath@closepathtoken {0.0pt}{0.0pt}%
}{%
		\pgfsyssoftpath@movetotoken {40.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {0.0pt}{0.0pt}%
		\pgfsyssoftpath@closepathtoken {40.0pt}{20.0pt}%
}


\pgfkeys{
	/TEST/prefix path=\pgfsyssoftpath@movetotoken{-10.0pt}{0.0pt}%
}
\TEST{3}{%
		\pgfsyssoftpath@linetotoken {0.0pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {40.0pt}{20.0pt}%
}{%
		\pgfsyssoftpath@linetotoken {40.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {0.0pt}{0.0pt}%
}

% FIXME : THIS MIGHT BE AN ILLEGAL STATE: does not start with
% moveto...
\TEST{4}{%
		\pgfsyssoftpath@linetotoken {0.0pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {40.0pt}{20.0pt}%
		\pgfsyssoftpath@closepathtoken {0.0pt}{0.0pt}%
}{%
		\pgfsyssoftpath@movetotoken {40.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {0.0pt}{0.0pt}%
		\pgfsyssoftpath@closepathtoken {40.0pt}{20.0pt}%
}

\TEST{5}{%
		\pgfsyssoftpath@movetotoken {0.0pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@movetotoken {40.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {60.0pt}{0.0pt}%
}{%
		\pgfsyssoftpath@movetotoken {60.0pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {40.0pt}{20.0pt}%
		\pgfsyssoftpath@movetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@linetotoken {0.0pt}{0.0pt}%
}

%\tracingmacros=2 \tracingcommands=2
\TEST{6}{%
		\pgfsyssoftpath@movetotoken {0.0pt}{0.0pt}%
		\pgfsyssoftpath@curvetosupportatoken {0.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetosupportbtoken {10.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetosupportatoken {20.0pt}{40.0pt}%
		\pgfsyssoftpath@curvetosupportbtoken {30.0pt}{40.0pt}%
		\pgfsyssoftpath@curvetotoken {40.0pt}{40.0pt}%
		\pgfsyssoftpath@linetotoken {60.0pt}{0.0pt}%
}{%
		\pgfsyssoftpath@movetotoken {60.0pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {40.0pt}{40.0pt}%
		\pgfsyssoftpath@curvetosupportatoken {30.0pt}{40.0pt}%
		\pgfsyssoftpath@curvetosupportbtoken {20.0pt}{40.0pt}%
		\pgfsyssoftpath@curvetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetosupportatoken {10.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetosupportbtoken {0.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetotoken {0.0pt}{0.0pt}%
}

\TEST{7}{%
		\pgfsyssoftpath@movetotoken {0.0pt}{0.0pt}%
		\pgfsyssoftpath@curvetosupportatoken {0.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetosupportbtoken {10.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetosupportatoken {20.0pt}{40.0pt}%
		\pgfsyssoftpath@curvetosupportbtoken {30.0pt}{40.0pt}%
		\pgfsyssoftpath@curvetotoken {40.0pt}{40.0pt}%
		\pgfsyssoftpath@linetotoken {60.0pt}{0.0pt}%
		\pgfsyssoftpath@closepathtoken {0pt}{0pt}%
}{%
		\pgfsyssoftpath@movetotoken {60.0pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {40.0pt}{40.0pt}%
		\pgfsyssoftpath@curvetosupportatoken {30.0pt}{40.0pt}%
		\pgfsyssoftpath@curvetosupportbtoken {20.0pt}{40.0pt}%
		\pgfsyssoftpath@curvetotoken {20.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetosupportatoken {10.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetosupportbtoken {0.0pt}{20.0pt}%
		\pgfsyssoftpath@curvetotoken {0.0pt}{0.0pt}%
		\pgfsyssoftpath@closepathtoken {60.0pt}{0.0pt}%
}
% FIXME: test + impl for curveto and rect!
\end{document}

