% !TeX program = xelatex
\documentclass{article}

\usepackage{fontspec}

\XeTeXinterchartokenstate = 1

\newXeTeXintercharclass \enDashCharacterClass
\newXeTeXintercharclass \digitsCharacterClass

\XeTeXcharclass `– \enDashCharacterClass
%\XeTeXcharclass `-- \enDashCharacterClass

\XeTeXcharclass `0 \digitsCharacterClass
\XeTeXcharclass `1 \digitsCharacterClass
\XeTeXcharclass `2 \digitsCharacterClass
\XeTeXcharclass `3 \digitsCharacterClass
\XeTeXcharclass `4 \digitsCharacterClass
\XeTeXcharclass `5 \digitsCharacterClass
\XeTeXcharclass `6 \digitsCharacterClass
\XeTeXcharclass `7 \digitsCharacterClass
\XeTeXcharclass `8 \digitsCharacterClass
\XeTeXcharclass `9 \digitsCharacterClass

% adding dots for testing only
\XeTeXinterchartoks \digitsCharacterClass \enDashCharacterClass {.\kern0.05em.}
\XeTeXinterchartoks \enDashCharacterClass \digitsCharacterClass {.\kern0.05em.}

\begin{document}
\textbf{works}

test – test

0 – 0

0–1–2–3–4–5–6–7–8–9–0

\textbf{doesn't work}

test -- test

0 -- 0

0--1--2--3--4--5--6--7--8--9--0
\end{document}