@Test
    public void formattersArePerState() {
        SimpleCodeWriter writer = new SimpleCodeWriter();
        // X is uppercase in all states unless overridden.
        writer.putFormatter('X', (value, indent) -> value.toString().toUpperCase(Locale.ENGLISH));
        writer.writeInline("$X", "salutations");

        writer.pushState();
        // Make X lowercase in this state.
        writer.putFormatter('X', (value, indent) -> value.toString().toLowerCase(Locale.ENGLISH));
        // Add Y but only to this state.
        writer.putFormatter('Y', (value, indent) -> value.toString());
        writer.writeInline(" $X $Y", "AND", "gReEtInGs");
        writer.popState();

        // Ensure that X is restored to writing uppercase.
        writer.writeInline("$X", ", friend");

        assertThat(writer.toString(), equalTo("SALUTATIONS and gReEtInGs, FRIEND\n"));
    }
\n"
                                + " * Foo \"foo!\"\n"
                                + " *\n"
                                + " * \"baz\"!\n"
                                + " * Yap!\n"
                                + " *     This is indented, in flow of parent.\n"
                                + " *     Yap!\n"
                                + " *     Yap?\n"
                                + " *     # Has a prefix\n"
                                + " *     # Yes\n"
                                + "
smithy-utils/src/test/java/software/amazon/smithy/utils/SimpleCodeWriterTest.java