コード例 #1
0
ファイル: source_span.cs プロジェクト: Lokad/Parsing
        public void merge_with()
        {
            const int a = 0;
            const int b = 1;
            const int c = 2;
            const int d = 3;
            const int e = 54;

            var ae = new SourceSpan(new SourceLocation(a, 1, 1), e - a);
            var ac = new SourceSpan(new SourceLocation(a, 1, 1), c - a);
            var ce = new SourceSpan(new SourceLocation(c, 2, 1), e - c);
            var bd = new SourceSpan(new SourceLocation(b, 1, 2), d - b);
            var ad = new SourceSpan(new SourceLocation(a, 1, 1), d - a);
            var be = new SourceSpan(new SourceLocation(b, 1, 2), e - b);

            Assert.AreEqual(ae, ae.MergeWith(ae));
            Assert.AreEqual(ae, ae.MergeWith(ac));
            Assert.AreEqual(ae, ae.MergeWith(ce));
            Assert.AreEqual(ae, ae.MergeWith(bd));
            Assert.AreEqual(ae, ae.MergeWith(ad));
            Assert.AreEqual(ae, ae.MergeWith(be));

            Assert.AreEqual(ae, ac.MergeWith(ae));
            Assert.AreEqual(ac, ac.MergeWith(ac));
            Assert.AreEqual(ae, ac.MergeWith(ce));
            Assert.AreEqual(ad, ac.MergeWith(bd));
            Assert.AreEqual(ad, ac.MergeWith(ad));
            Assert.AreEqual(ae, ac.MergeWith(be));

            Assert.AreEqual(ae, ce.MergeWith(ae));
            Assert.AreEqual(ae, ce.MergeWith(ac));
            Assert.AreEqual(ce, ce.MergeWith(ce));
            Assert.AreEqual(be, ce.MergeWith(bd));
            Assert.AreEqual(ae, ce.MergeWith(ad));
            Assert.AreEqual(be, ce.MergeWith(be));

            Assert.AreEqual(ae, bd.MergeWith(ae));
            Assert.AreEqual(ad, bd.MergeWith(ac));
            Assert.AreEqual(be, bd.MergeWith(ce));
            Assert.AreEqual(bd, bd.MergeWith(bd));
            Assert.AreEqual(ad, bd.MergeWith(ad));
            Assert.AreEqual(be, bd.MergeWith(be));

            Assert.AreEqual(ae, ad.MergeWith(ae));
            Assert.AreEqual(ad, ad.MergeWith(ac));
            Assert.AreEqual(ae, ad.MergeWith(ce));
            Assert.AreEqual(ad, ad.MergeWith(bd));
            Assert.AreEqual(ad, ad.MergeWith(ad));
            Assert.AreEqual(ae, ad.MergeWith(be));

            Assert.AreEqual(ae, be.MergeWith(ae));
            Assert.AreEqual(ae, be.MergeWith(ac));
            Assert.AreEqual(be, be.MergeWith(ce));
            Assert.AreEqual(be, be.MergeWith(bd));
            Assert.AreEqual(ae, be.MergeWith(ad));
            Assert.AreEqual(be, be.MergeWith(be));
        }