public void ReduceWithStartIterates() { IFn fn = DummyFn.CreateForReduce(); Range r = new Range(2, 5); object ret = r.reduce(fn, 20); Expect(ret, EqualTo(29)); }
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(); }
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)); }
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(); }
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)); }
public void Range_has_correct_count() { Range r = new Range(2, 20); Expect(r.count(), EqualTo(18)); }
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)); }
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)); }
public void CreateOnISeqReturnsCorrectCount() { Range r = new Range(2,5); PersistentVector v = PersistentVector.create(r); Expect(v.count(),EqualTo(r.count())); }
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); }
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)); }
public void Meta_ctor_has_meta() { IPersistentMap meta = new DummyMeta(); Range r = new Range(meta, 2, 5); Expect(r.meta(), EqualTo(meta)); }
public void Setup() { IPersistentMap meta = new DummyMeta(); Range r = new Range(2, 5); _objWithNullMeta = (IObj)r; _obj = _objWithNullMeta.withMeta(meta); _expectedType = typeof(Range); }
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); }
public void Basic_ctor_has_no_meta() { Range r = new Range(2, 5); Expect(r.meta(), Null); }
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 }; }
public void AssocNOutOfRangeLowThrowsException() { Range r = new Range(2, 5); PersistentVector v1 = PersistentVector.create(r); IPersistentVector v2 = v1.assocN(-4, 10); }
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 }; }