%D \module
%D   [       file=spac-imp-tests,
%D        version=2023.06.10,
%D          title=\CONTEXT\ Spacing Macros,
%D       subtitle=Test Passes,
%D         author=Hans Hagen & Mikael Sundqvist,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D There are a few passes prededined. Here we have some tests passes, at
%D some point we will no longer preload them.

% \writestatus{loading}{ConTeXt Spacing Macros / Test Passes}

\unprotect

% for old times sake

\startsetups align:pass:granular
    \granularparpasses
\stopsetups

\startsetups align:pass:decent
    \decentparpasses
\stopsetups

\startsetups align:pass:quality
    \qualityparpasses
\stopsetups

\startsetups align:pass:mathbook
    \mathbookparpasses
\stopsetups

% the test set:

% \startsetups align:pass:test1
%     \pretolerance 100
%     \tolerance    200
%     \parpasses      2
%         classes                \indecentparpassclasses
%         tolerance            400
%       next
%         classes                \indecentparpassclasses
%         tolerance            400
%         adjustspacing          3
%         adjustspacingstep      1
%         adjustspacingshrink   15
%         adjustspacingstretch  30
%       % emergencystretch       0.25\bodyfontsize
%         emergencyfactor      250
%     \relax
%     \linebreakpasses\plusone
% \stopsetups

\startsetups align:pass:test1
    \pretolerance 100
    \tolerance    200
    \parpasses    1
      % classes              \ifnum\fitnessdemerits=\plusnine\almostdecentparpassclasses\else\indecentparpassclasses\fi
        classes              \indecentparpassclasses
        tolerance            300
        adjustspacing          3
        adjustspacingstep      1
        adjustspacingshrink   15
        adjustspacingstretch  30
      % emergencystretch       0.25\bodyfontsize
        emergencyfactor      250
    \relax
\stopsetups

% This one works quite well About 300 hits, almost all but a handful caught by the
% the first one.

\startsetups align:pass:test2
    \pretolerance 100
    \tolerance    200
    \parpasses      3
        classes                \indecentparpassclasses
        threshold              0.025pt
        tolerance            250
        extrahyphenpenalty    50
      next
        threshold              0.025pt
        tolerance            300
        adjustspacing          3
        adjustspacingstep      1
        adjustspacingshrink   10
        adjustspacingstretch  15
      next
        threshold              0.025pt
        tolerance            350
        adjustspacing          3
        adjustspacingstep      1
        adjustspacingshrink   20
        adjustspacingstretch  40
      % emergencystretch       0.25\bodyfontsize
        emergencyfactor      250
    \relax
\stopsetups

% This one works quite well. About 500 hits, all but about 10 caught by the the
% first one

\startsetups align:pass:test3
    \pretolerance  50
    \tolerance    100
    \parpasses      2
        classes                \indecentparpassclasses
        threshold              0.025pt
        tolerance            200
        extrahyphenpenalty    50
      next
        threshold              0.025pt
        tolerance            200
        extrahyphenpenalty    25
        adjustspacing          3
        adjustspacingstep      1
        adjustspacingshrink   20
        adjustspacingstretch  40
      % emergencystretch       0.25\bodyfontsize
        emergencyfactor      250
    \relax
\stopsetups

% We increase expansion stepwise Here most (about 300) end up in the fourth run,
% only a handful in the first ones No overfull hboxes present, many large changes.

\startsetups align:pass:test4
    \pretolerance 100
    \tolerance    200
    \parpasses      4
        classes               \indecentparpassclasses
        threshold             0.025pt
        adjustspacing         3
        adjustspacingstep     1
        adjustspacingshrink   5
        adjustspacingstretch 10
      next
        classes               \indecentparpassclasses
        threshold             0.025pt
        adjustspacing         3
        adjustspacingstep     1
        adjustspacingshrink  10
        adjustspacingstretch 20
      next
        classes               \indecentparpassclasses
        threshold             0.025pt
        adjustspacing         3
        adjustspacingstep     1
        adjustspacingshrink  20
        adjustspacingstretch 40
      next
        classes               \indecentparpassclasses
        threshold             0.025pt
        adjustspacing         3
        adjustspacingstep     1
        adjustspacingshrink  40
        adjustspacingstretch 80
    \relax
\stopsetups

% Start with low tolerance and hopefully no hyphens. increase tolerance and
% decrease extrahyphenpenalty. Last one has a larger threshold, so only kicks in for
% lines that stick out "much" 31-1-4-0 (but two slightly overfull hboxes)

\startsetups align:pass:test5
    \pretolerance  50
    \tolerance    100
    \parpasses      4
        threshold             0.025pt
        tolerance           200
        extrahyphenpenalty  100
      next
        threshold             0.025pt
        tolerance           400
        extrahyphenpenalty   50
      next
        threshold             0.025pt
        tolerance           500
        extrahyphenpenalty   25
      % emergencystretch      0.25\bodyfontsize
        emergencyfactor     250
      next
        threshold             1pt
        tolerance          1000
        extrahyphenpenalty    0
      % emergencystretch      0.5\bodyfontsize
        emergencyfactor     500
    \relax
\stopsetups

% another temporary test

% \permanent\protected\def\optional#1#2%
%   {\optionalboundary#1\wordboundary#2\wordboundary\optionalboundary\zerocount}

\startsetups align:pass:optional1
    \pretolerance  75
    \tolerance    150
    \parpasses      3
        classes             \indecentparpassclasses
        linebreakoptional   0
        tolerance         150
    next
     %  callback          \parpasscallback{experiment}
        classes             \indecentparpassclasses
        tolerance         200
        linebreakoptional   0
      % emergencystretch  .25\bodyfontsize
        emergencyfactor   250
    next
      % threshold           0.025pt
        classes            \indecentparpassclasses
        tolerance         200
        linebreakoptional   0
      % emergencystretch    0.5\bodyfontsize
        emergencyfactor   500
    \relax
\stopsetups

\protect \endinput
