Пример #1
0
        public void PrintlnTest()
        {
            var g    = new Global();
            var data = new object[] {
                1, 1M, 10.55, "string"
            };

            foreach (var obj in data)
            {
                using var iop = new IoProxy();
                g.println(obj);
                Assert.Equal(obj + Environment.NewLine, iop.ReadAllFromStdOut());
            }

            {
                using var iop = new IoProxy();
                var tuple = (1, 2, 3, "xxx");
                g.println(tuple);
                Assert.Equal(string.Join(" ", tuple) + Environment.NewLine, iop.ReadAllFromStdOut());
            }

            {
                using var iop = new IoProxy();
                var tuple = (1, 2, 3, "xxx");
                g.Env.Add("OFS", ":");
                g.println(tuple);
                Assert.Equal(string.Join(":", tuple) + Environment.NewLine, iop.ReadAllFromStdOut());
            }
        }
Пример #2
0
        public void StringPrintTest()
        {
            var g = new Global();

            using var iop = new IoProxy();
            g.print("abc");
            Assert.Equal("abc", iop.ReadAllFromStdOut());
        }
Пример #3
0
        public void PrintCollectionTest()
        {
            var gv     = new Global();
            var data   = new[] { "a", "b", "c" };
            var expect = string.Join(Environment.NewLine, data) + Environment.NewLine;

            using var iop = new IoProxy();
            gv.print(data);

            Assert.Equal(expect, iop.ReadAllFromStdOut());
        }
Пример #4
0
        public void PrintTest()
        {
            var gv = new Global();

            var data = new object[] {
                1, 1M, 10.55
            };

            foreach (var obj in data)
            {
                using var iop = new IoProxy();
                gv.print(obj);
                Assert.Equal(obj.ToString(), iop.ReadAllFromStdOut());
            }
        }
Пример #5
0
        public void TuplePrintTest()
        {
            var gv     = new Global();
            var data   = (1, 3, "xx");
            var expect = string.Join(" ", data);

            {
                using var iop = new IoProxy();
                gv.print(data);

                Assert.Equal(expect, iop.ReadAllFromStdOut());
            }
            {
                using var iop = new IoProxy();

                gv.Env.Add("OFS", ":");
                gv.print(data);
                expect = string.Join(":", data);
                Assert.Equal(expect, iop.ReadAllFromStdOut());
            }
        }