@Test
    public void flattensStatesOfOtherWhenCopying() {
        CodeWriter a = new CodeWriter();
        a.pushState();
        a.putFormatter('A', (value, indent) -> value.toString().toUpperCase(Locale.ENGLISH));
        a.putContext("a", 1);
        a.putContext("b", "B");
        a.pushState();
        a.putContext("b", 2); // override "b"
        a.putFormatter('B', (value, indent) -> value.toString().toLowerCase(Locale.ENGLISH));

        CodeWriter b = new CodeWriter();
        b.putContext("c", 3);
        b.copySettingsFrom(a);
        b.writeInline("${1A} ${2B} ${a:L} ${b:L} ${c:L}", "Hello", "Goodbye");

        assertThat(b.toString(), equalTo("HELLO goodbye 1 2 3\n"));
        assertThat(a.toString(), equalTo("\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/CodeWriterTest.java