public void CollapsesPreviousWhiteSpace() { var factory = new Factory(); // "Hello {{~test}}" var document = factory.Document( factory.Text("Hello"), factory.WhiteSpace(1), factory.Expression( factory.MetaCode("{{", T.OpenTag), factory.MetaCode("~", T.Tilde), factory.Span(SpanKind.Expression, factory.Symbol("this", T.Identifier)), factory.MetaCode("}}", T.CloseTag))); factory = new Factory(); // "Hello{{~test}}" var expected = factory.Document( factory.Text("Hello"), factory.WhiteSpace(1, collapsed: true), factory.Expression( factory.MetaCode("{{", T.OpenTag), factory.MetaCode("~", T.Tilde), factory.Span(SpanKind.Expression, factory.Symbol("this", T.Identifier)), factory.MetaCode("}}", T.CloseTag))); var visitor = new WhiteSpaceCollapsingParserVisitor(); visitor.VisitBlock(document); var builder = new StringBuilder(); var comparer = new EquivalanceComparer(builder, 0); Assert.True(comparer.Equals(expected, document), builder.ToString()); }