Пример #1
0
        public void RSeqCountWorks()
        {
            CPV  v = new CPV(new object[] { 4, 5, 6 });
            ISeq s = v.rseq();

            Expect(s.count(), EqualTo(3));
            Expect(s.next().count(), EqualTo(2));
            Expect(s.next().next().count(), EqualTo(1));
        }
Пример #2
0
        public void RSeqCountWorks()
        {
            CPV  v = new CPV(new object[] { 4, 5, 6 });
            ISeq s = v.rseq();

            Expect(s.count()).To.Equal(3);
            Expect(s.next().count()).To.Equal(2);
            Expect(s.next().next().count()).To.Equal(1);
        }
        public void RSeqFirstAndRestWork()
        {
            CPV  v = new CPV(new object[] { 4, 5, 6 });
            ISeq s = v.rseq();

            Expect(s.first(), EqualTo(6));
            Expect(s.next().first(), EqualTo(5));
            Expect(s.next().next().first(), EqualTo(4));
            Expect(s.next().next().next(), Null);
        }
Пример #4
0
        public void RseqOnPositiveCountYieldsValidSequence()
        {
            CPV  v = new CPV(new object[] { 1, 2, 3 });
            ISeq s = v.rseq();

            Expect(s.first()).To.Equal(3);
            Expect(s.next().first()).To.Equal(2);
            Expect(s.next().next().first()).To.Equal(1);
            Expect(s.next().next().next()).To.Be.Null();
        }
Пример #5
0
        public void RSeqFirstAndRestWork()
        {
            CPV  v = new CPV(new object[] { 4, 5, 6 });
            ISeq s = v.rseq();

            Expect(s.first()).To.Equal(6);
            Expect(s.next().first()).To.Equal(5);
            Expect(s.next().next().first()).To.Equal(4);
            Expect(s.next().next().next()).To.Be.Null();
        }
        public void RseqOnPositiveCountYieldsValidSequence()
        {
            CPV  v = new CPV(new object[] { 1, 2, 3 });
            ISeq s = v.rseq();

            Expect(s.first(), EqualTo(3));
            Expect(s.next().first(), EqualTo(2));
            Expect(s.next().next().first(), EqualTo(1));
            Expect(s.next().next().next(), Null);
        }
        public void RSeqReduceWithStartIterates()
        {
            IFn fn = DummyFn.CreateForReduce();

            CPV     v   = new CPV(new object[] { 1, 2, 3 });
            IReduce r   = (IReduce)v.rseq();
            object  ret = r.reduce(fn, 20);

            Expect(ret, EqualTo(26));
        }
        public void RSeqWithMetaHasMeta()
        {
            IPersistentMap meta = new DummyMeta();

            CPV  v   = new CPV(new object[] { 4, 5, 6 });
            IObj s   = (IObj)v.rseq();
            IObj obj = s.withMeta(meta);

            Expect(obj.meta(), SameAs(meta));
        }
Пример #9
0
        public void RSeqReduceWithStartIterates()
        {
            IFn fn = DummyFn.CreateForReduce();

            CPV     v   = new CPV(new object[] { 1, 2, 3 });
            IReduce r   = (IReduce)v.rseq();
            object  ret = r.reduce(fn, 20);

            Expect(ret).To.Be.An.Instance.Of <long>();
            Expect((long)ret).To.Equal(26);
        }
        public void RSeqIndexedWorks()
        {
            CPV        v  = new CPV(new object[] { 4, 5, 6 });
            ISeq       s0 = v.rseq();
            IndexedSeq i0 = s0 as IndexedSeq;

            ISeq       s1 = s0.next();
            IndexedSeq i1 = s1 as IndexedSeq;

            Expect(i0.index(), EqualTo(2));
            Expect(i1.index(), EqualTo(1));
        }
Пример #11
0
        public void RSeqWithMetaHasMeta()
        {
            MockRepository mocks = new MockRepository();
            IPersistentMap meta  = mocks.StrictMock <IPersistentMap>();

            mocks.ReplayAll();

            CPV  v   = new CPV(new object[] { 4, 5, 6 });
            IObj s   = (IObj)v.rseq();
            IObj obj = s.withMeta(meta);

            Expect(obj.meta(), SameAs(meta));
            mocks.VerifyAll();
        }
Пример #12
0
        public void RSeqReduceWithNoStartIterates()
        {
            MockRepository mocks = new MockRepository();
            IFn            fn    = mocks.StrictMock <IFn>();

            RMExpect.Call(fn.invoke(3, 2)).Return(5);
            RMExpect.Call(fn.invoke(5, 1)).Return(7);
            mocks.ReplayAll();

            CPV     v   = new CPV(new object[] { 1, 2, 3 });
            IReduce r   = (IReduce)v.rseq();
            object  ret = r.reduce(fn);

            Expect(ret, EqualTo(7));
            mocks.VerifyAll();
        }
        public void RSeqWithMetaHasMeta()
        {
            MockRepository mocks = new MockRepository();
            IPersistentMap meta = mocks.StrictMock<IPersistentMap>();
            mocks.ReplayAll();

            CPV v = new CPV(new object[] { 4, 5, 6 });
            IObj s = (IObj)v.rseq();
            IObj obj = s.withMeta(meta);

            Expect(obj.meta(), SameAs(meta));
            mocks.VerifyAll();
        }
        public void RSeqReduceWithStartIterates()
        {
            MockRepository mocks = new MockRepository();
            IFn fn = mocks.StrictMock<IFn>();
            RMExpect.Call(fn.invoke(20, 3)).Return(10);
            RMExpect.Call(fn.invoke(10, 2)).Return(5);
            RMExpect.Call(fn.invoke(5, 1)).Return(7);
            mocks.ReplayAll();

            CPV v = new CPV(new object[] { 1, 2, 3 });
            IReduce r = (IReduce)v.rseq();
            object ret = r.reduce(fn, 20);

            Expect(ret, EqualTo(7));
            mocks.VerifyAll();
        }
        public void RseqOnPositiveCountYieldsValidSequence()
        {
            CPV v = new CPV(new object[] { 1, 2, 3 });
            ISeq s = v.rseq();

            Expect(s.first(), EqualTo(3));
            Expect(s.rest().first(), EqualTo(2));
            Expect(s.rest().rest().first(), EqualTo(1));
            Expect(s.rest().rest().rest(), Null);
        }
        public void RSeqOnPositiveCountYieldsNotNull()
        {
            CPV v = new CPV(new object[] { 1, 2, 3 });

            Expect(v.rseq(), Not.Null);
        }
        public void RseqOnCount0YieldsNull()
        {
            CPV v = new CPV(new object[0]);

            Expect(v.rseq(), Null);
        }
        public void RSeqIndexedWorks()
        {
            CPV v = new CPV(new object[] { 4, 5, 6 });
            ISeq s0 = v.rseq();
            IndexedSeq i0 = s0 as IndexedSeq;

            ISeq s1 = s0.rest();
            IndexedSeq i1 = s1 as IndexedSeq;

            Expect(i0.index(), EqualTo(0));
            Expect(i1.index(), EqualTo(1));
        }
        public void RSeqFirstAndRestWork()
        {
            CPV v = new CPV(new object[] { 4, 5, 6 });
            ISeq s = v.rseq();

            Expect(s.first(), EqualTo(6));
            Expect(s.rest().first(), EqualTo(5));
            Expect(s.rest().rest().first(), EqualTo(4));
            Expect(s.rest().rest().rest(), Null);
        }
        public void RSeqCountWorks()
        {
            CPV v = new CPV(new object[] { 4, 5, 6 });
            ISeq s = v.rseq();

            Expect(s.count(), EqualTo(3));
            Expect(s.rest().count(), EqualTo(2));
            Expect(s.rest().rest().count(), EqualTo(1));
        }
Пример #21
0
        public void RSeqWithMetaHasMeta()
        {
            IPersistentMap meta = new DummyMeta();

            CPV v = new CPV(new object[] { 4, 5, 6 });
            IObj s = (IObj)v.rseq();
            IObj obj = s.withMeta(meta);

            Expect(obj.meta(), SameAs(meta));
        }
Пример #22
0
        public void RSeqReduceWithStartIterates()
        {
            IFn fn = DummyFn.CreateForReduce();

            CPV v = new CPV(new object[] { 1, 2, 3 });
            IReduce r = (IReduce)v.rseq();
            object ret = r.reduce(fn, 20);

            Expect(ret, EqualTo(26));
        }
        public void RSeqOnPositiveCountYieldsNotNull()
        {
            CPV v = new CPV(new object[] { 1, 2, 3 });

            Expect(v.rseq(), Not.Null);
        }
        public void RseqOnCount0YieldsNull()
        {
            CPV v = new CPV(new object[0]);

            Expect(v.rseq(), Null);
        }