### MORX-14: Rearrangement Loop

The font for this test case has an AAT Extended Glyph Metamorphosis Table with a single Rearrangement Subtable. Its finite-state machine contains two states (0 and 1) with the following transitions:

- For glyph A:

- in state 0, the machine loops back to state 0. This transition carries both the MarkFirst and MarkLast flags. No rearrangement action is performed.
- in state 1, the machine loops back to state 1. This transition carries no flags. No rearrangement action is performed.

- For glyphs B, C, and D:

- in state 0, the machine loops back to state 0. This transition carries the MarkLast flag. No rearrangement action is performed.
- in state 1, the machine loops back to state 1. This transition carries the DontAdvance flag, and executes a rearrangement of type 2 (xD ⇒ Dx).

- For glyph E:

- in state 0, the machine makes a transition to state 1. This transition carries both the DontAdvance and MarkLast flags. No rearrangement action is performed.
- in state 1, the machine loops back to state 1. This transition carries the DontAdvance flag, and it executes a rearrangement of type 2 (xD ⇒ Dx).

- For any other glyphs and “end of text”, the machine performs no action.

If your rendering system correctly implements Apple Advanced Typography, the finite-state machine should loop multiple times through state 1, repeatedly rearranging the marked glyphs in every iteration.

- For the input string ABCDE, your implementation should change the marked glyph sequence as follows: A → AB → ABC → ABCD → ABCDE → EABCD → DEABC → CDEAB → BCDEA.
- For the input string ABBBCCCDDDBCDCE, your implementation should change the marked glyph changes as follows: A → AB → ABB → [...] → ABBBCCCDDDBCDCE → EABBBCCCDDDBCDC → CEABBBCCCDDDBCD → DCEABBBCCCDDDBC → CDCEABBBCCCDDDB → BCDCEABBBCCCDDD → DBCDCEABBBCCCDD → [...] → BCCCDDDBCDCEABB → BBCCCDDDBCDCEAB → BBBCCCDDDBCDCEA. However, since this is a rather degenerated corner case, we only expect that the implementation does not crash or hang.

| ABCDE | ABBBCCCDDDBCDCE
--- | --- | ---
Expected |  | Shouldn’t crash or hang
Observed |  |
Conformance |  |