Example #1
0
        static void Main(string[] args)
        {
            {
                var sb = new TextChainAutoBreak();
                //random phrase from Hamlet by William Shakespeare
                sb += "Hor. And then it started, like a guilty thing";
                sb += "Vpon a fearfull Summons. I haue heard,";
                sb += "The Cocke that is the Trumpet to the day,";

                Console.Write(sb);
            }
            {
                var sb = new TextChainBrainfuck();

                sb--;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 3;
                sb >>= 22;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb  += 2;
                sb >>= 2;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 33;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 4;
                sb  += 3;
                sb >>= 3;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 7;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 3;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 7;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 3;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb  += 2;
                sb >>= 2;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 3;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 3;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 3;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 2;
                sb  += 3;
                sb >>= 2;
                sb++;
                sb  &= 2;
                sb >>= 2;
                sb++;
                sb   = !sb;
                sb >>= 1;
                sb   = ~sb;
                sb++;
                sb >>= 1;
                sb++;
                sb   = !sb;
                sb <<= 1;
                sb   = ~sb;
                sb <<= 1;
                sb--;
                sb   = ~sb;
                sb >>= 2;
                sb   = !sb;
                sb >>= 1;
                sb   = ~sb;
                sb <<= 1;
                sb++;
                sb <<= 1;
                sb  += 3;
                sb   = !sb;
                sb <<= 1;
                sb   = ~sb;
                sb <<= 2;
                sb++;
                sb   = ~sb;
                sb >>= 3;
                sb   = !sb;
                sb >>= 1;
                sb   = ~sb;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb = !sb;
                sb++;
                sb   = !sb;
                sb <<= 1;
                sb  += 16;
                sb >>= 1;
                sb--;
                sb   = ~sb;
                sb <<= 1;
                sb  += 10;
                sb  *= 1;
                sb <<= 1;
                sb   = ~sb;

                var text = sb.GetStringBuilder().ToString();
                Console.WriteLine(text);

                using (var sw = new System.IO.StringWriter())
                {
                    var engine = new BrainfuckRunner.Library.BfEngine()
                    {
                        Output = sw
                    };
                    engine.ExecuteScript(text);
                    var result = sw.GetStringBuilder().ToString();
                    Console.WriteLine(result);
                }
            }

            {
                var sb = new TextChainAutoIndent();
                sb += "namespace TestConsole";
                sb += "{";
                sb.Indent();
                sb += "class Program";
                sb += "{";
                sb.Indent();
                sb += "static void Main(string[] args)";
                sb += "{";
                sb += "}";
                sb.Unindent();
                sb += "}";
                sb.Unindent();
                sb += "}";

                var sb2 = new TextChainAutoBreak();
                sb2 += "Program:";
                Console.WriteLine(sb2 + sb);
            }
        }
Example #2
0
        public void StringBuilderProvider1()
        {
            {
                var text = new TextChain();
                text += "1";
                text += "2";
                text += "3";
                Assert.Equal("123", text);
            }
            {
                var text = new TextChainAutoBreak();
                text += "1";
                text += "2";
                text += "3";
                Assert.Equal("1" + Environment.NewLine + "2" + Environment.NewLine + "3" + Environment.NewLine, text);
            }
            {
                var text = new TextChainAutoIndent();
                text.IndentText = " ";
                text.Indent();
                text += "1";
                text.Indent();
                text += "2";
                for (var i = 0; i < 3; i++)
                {
                    text.Unindent();
                }
                text += "3";
                Assert.Equal(" 1" + Environment.NewLine + "  2" + Environment.NewLine + "3" + Environment.NewLine, text);
            }
            {
                var sb = new TextChainBrainfuck();

                sb--;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 3;
                sb >>= 22;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb  += 2;
                sb >>= 2;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 33;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 4;
                sb  += 3;
                sb >>= 3;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 7;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 3;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 7;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 3;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb  += 2;
                sb >>= 2;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 3;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 3;
                sb  += 2;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 3;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 1;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb >>= 2;
                sb  += 3;
                sb >>= 2;
                sb  += 3;
                sb >>= 2;
                sb++;
                sb  &= 2;
                sb >>= 2;
                sb++;
                sb   = !sb;
                sb >>= 1;
                sb   = ~sb;
                sb++;
                sb >>= 1;
                sb++;
                sb   = !sb;
                sb <<= 1;
                sb   = ~sb;
                sb <<= 1;
                sb--;
                sb   = ~sb;
                sb >>= 2;
                sb   = !sb;
                sb >>= 1;
                sb   = ~sb;
                sb <<= 1;
                sb++;
                sb <<= 1;
                sb  += 3;
                sb   = !sb;
                sb <<= 1;
                sb   = ~sb;
                sb <<= 2;
                sb++;
                sb   = ~sb;
                sb >>= 3;
                sb   = !sb;
                sb >>= 1;
                sb   = ~sb;
                sb  += 3;
                sb >>= 1;
                sb++;
                sb = !sb;
                sb++;
                sb   = !sb;
                sb <<= 1;
                sb  += 16;
                sb >>= 1;
                sb--;
                sb   = ~sb;
                sb <<= 1;
                sb  += 10;
                sb  *= 1;
                sb <<= 1;
                sb   = ~sb;

                var text = sb.GetStringBuilder().ToString();

                using (var sw = new System.IO.StringWriter())
                {
                    var engine = new BrainfuckRunner.Library.BfEngine()
                    {
                        Output = sw
                    };
                    engine.ExecuteScript(text);
                    var result = sw.GetStringBuilder().ToString();

                    Assert.Equal(text, result);
                }
            }
        }