Represents a (contiguous) range of integers.
상속: clojure.lang.ASeq, IReduce, Streamable, Counted
예제 #1
0
        public void ReduceWithStartIterates()
        {
            IFn fn = DummyFn.CreateForReduce();

            Range r = new Range(2, 5);
            object ret = r.reduce(fn, 20);

            Expect(ret, EqualTo(29));
        }
예제 #2
0
        public void Meta_ctor_has_meta()
        {
            MockRepository mocks = new MockRepository();
            IPersistentMap meta = mocks.StrictMock<IPersistentMap>();
            mocks.ReplayAll();

            Range r = new Range(meta, 2, 5);

            Expect(r.meta(), EqualTo(meta));

            mocks.VerifyAll();
        }
예제 #3
0
        public void AssocNChangesForBig()
        {
            Range r = new Range(2, 100000);
            PersistentVector v1 = PersistentVector.create(r);
            IPersistentVector v2 = v1;

            for (int i = 0; i < 110000; i++)
                v2 = v2.assocN(i, i + 20);

            for ( int i=0; i<v1.count(); ++i )
                Expect(v1.nth(i),EqualTo(i+2));

            for (int i = 0; i < v2.count(); ++i)
                Expect(v2.nth(i), EqualTo(i + 20));
        }
예제 #4
0
        public void ReduceWithNoStartIterates()
        {
            MockRepository mocks = new MockRepository();
            IFn fn = mocks.StrictMock<IFn>();
            RMExpect.Call(fn.invoke(2, 3)).Return(5);
            RMExpect.Call(fn.invoke(5, 4)).Return(7);
            mocks.ReplayAll();

            Range r = new Range(2, 5);
            object ret = r.reduce(fn);

            Expect(ret, EqualTo(7));

            mocks.VerifyAll();
        }
예제 #5
0
        public void AssocNAddsAtEndForSmall()
        {
            Range r = new Range(2, 5);
            PersistentVector v1 = PersistentVector.create(r);
            IPersistentVector v2 = v1.assocN(3, 10);

            Expect(v1.nth(0), EqualTo(2));
            Expect(v1.nth(1), EqualTo(3));
            Expect(v1.nth(2), EqualTo(4));
            Expect(v1.count(), EqualTo(3));
            Expect(v2.nth(0), EqualTo(2));
            Expect(v2.nth(1), EqualTo(3));
            Expect(v2.nth(2), EqualTo(4));
            Expect(v2.nth(3), EqualTo(10));
            Expect(v2.count(), EqualTo(4));
        }
예제 #6
0
        public void Range_has_correct_count()
        {
            Range r = new Range(2, 20);

            Expect(r.count(), EqualTo(18));
        }
예제 #7
0
        public void PopOnBigWorks()
        {
            Range r = new Range(0, 100000);
            PersistentVector v = PersistentVector.create(r);
            IPersistentStack s = v;
            for (int i = 16; i < 100000; i++)
                s = s.pop();

            Expect(v.count(), EqualTo(r.count()));
            Expect(s.count(), EqualTo(16));
        }
예제 #8
0
        public void PopOnSmallReturnsOneLess()
        {
            Range r = new Range(2, 20);
            PersistentVector v = PersistentVector.create(r);
            IPersistentStack s = v.pop();

            Expect(v.count(),EqualTo(r.count()));
            Expect(s.count(),EqualTo(v.count()-1));
        }
예제 #9
0
        public void CreateOnISeqReturnsCorrectCount()
        {
            Range r = new Range(2,5);
            PersistentVector v = PersistentVector.create(r);

            Expect(v.count(),EqualTo(r.count()));
        }
예제 #10
0
        public void CreateOnISeqWithManyManyItemsWorks()
        {
            // Want to bust out of the first tail, so need to insert more than 32 elements.
            // Let's get out of the second level, too.

            Range r = new Range(2, 100000);
            PersistentVector v = PersistentVector.create(r);

            Expect(v.count(), EqualTo(r.count()));
            for (int i = 0; i < v.count(); ++i)
                Expect(v.nth(i), EqualTo(i + 2));
        }
 public void AssocNOutOfRangeHighThrowsException()
 {
     Range r = new Range(2, 5);
     PersistentVector v1 = PersistentVector.create(r);
     v1.assocN(4, 10);
 }
예제 #12
0
        public void CreateOnISeqHasItems()
        {
            Range r = new Range(2, 5);
            PersistentVector v = PersistentVector.create(r);

            Expect(v.nth(0), EqualTo(2));
            Expect(v.nth(1), EqualTo(3));
            Expect(v.nth(2), EqualTo(4));
        }
예제 #13
0
 public void Meta_ctor_has_meta()
 {
     IPersistentMap meta = new DummyMeta();
     Range r = new Range(meta, 2, 5);
     Expect(r.meta(), EqualTo(meta));
 }
예제 #14
0
        public void Setup()
        {
            IPersistentMap meta = new DummyMeta();

            Range r = new Range(2, 5);

            _objWithNullMeta = (IObj)r;
            _obj = _objWithNullMeta.withMeta(meta);
            _expectedType = typeof(Range);
        }
예제 #15
0
        public void Setup()
        {
            _mocks = new MockRepository();
            IPersistentMap meta = _mocks.StrictMock<IPersistentMap>();
            _mocks.ReplayAll();

            Range r = new Range(2, 5);

            _objWithNullMeta = (IObj)r;
            _obj = _objWithNullMeta.withMeta(meta);
            _expectedType = typeof(Range);
        }
예제 #16
0
 public void Basic_ctor_has_no_meta()
 {
     Range r = new Range(2, 5);
     Expect(r.meta(), Null);
 }
예제 #17
0
        public void Setup()
        {
            IPersistentMap meta = PersistentHashMap.create("a", 1, "b", 2);

            _r = new Range(2, 5);
            _rWithMeta = new Range(meta, 2, 5);
            _values = new object[] { 2, 3, 4 };
        }
예제 #18
0
 public void AssocNOutOfRangeLowThrowsException()
 {
     Range r = new Range(2, 5);
     PersistentVector v1 = PersistentVector.create(r);
     IPersistentVector v2 = v1.assocN(-4, 10);
 }
예제 #19
0
        public void Setup()
        {
            IPersistentMap meta = PersistentHashMap.create("a", 1, "b", 2);

            _r = (Range)Range.create(2L, 5L);
            _rWithMeta = (Range)_r.withMeta(meta);
            _values = new object[] { 2, 3, 4 };
        }