public void HashCodeSameAsPersistentVector() { MapEntry me = new MapEntry(1, "abc"); PersistentVector v = PersistentVector.create(1, "abc"); Expect(me.GetHashCode()).To.Equal(v.GetHashCode()); }
public void HashCodeFalseOnDifferentValues() { MapEntry me = new MapEntry(1, "abc"); PersistentVector v = PersistentVector.create(1, "abcd"); Expect(me.GetHashCode()).To.Not.Equal(v.GetHashCode()); }
public void AssocNOutOfRangeHighThrowsException() { Range r = new Range(2, 5); PersistentVector v1 = PersistentVector.create((ISeq)r); v1.assocN(4, 10); }
public void CreateOnISeqReturnsCorrectCount() { ISeq r = LongRange.create(2, 5); PersistentVector v = PersistentVector.create(r); Expect(v.count(), EqualTo(r.count())); }
public void EmptyReturnsEmptyCollection() { PersistentVector v = PersistentVector.create(1, 2, 3); IPersistentCollection e = v.empty(); Expect(e.count(), EqualTo(0)); }
public void AssocNOutOfRangeHighThrowsException() { ISeq r = LongRange.create(2, 5); PersistentVector v1 = PersistentVector.create(r); v1.assocN(4, 10); }
public void AssocNOutOfRangeLowThrowsException() { Range r = new Range(2, 5); PersistentVector v1 = PersistentVector.create(r); v1.assocN(-4, 10); }
public void PopOnSizeOneReturnsEmpty() { PersistentVector v = PersistentVector.create(1); IPersistentStack s = v.pop(); Expect(s.count(), EqualTo(0)); }
public void CreateOnISeqReturnsCorrectCount() { Range r = new Range(2, 5); PersistentVector v = PersistentVector.create((ISeq)r); Expect(v.count(), EqualTo(r.count())); }
public void EqualsWorksFalseOnDifferentValues() { MapEntry me = new MapEntry(1, "abc"); PersistentVector v = PersistentVector.create(1, "abcd"); Expect(me.Equals(v)).To.Be.False(); }
public void EqualsWorksOnPersistentVector() { MapEntry me = new MapEntry(1, "abc"); PersistentVector v = PersistentVector.create(1, "abc"); Expect(me.Equals(v)); }
public static IPersistentVector toAngleAxis(Quaternion q) { float ang; Vector3 axis; q.ToAngleAxis(out ang, out axis); return(PersistentVector.create(ang, axis)); }
public void PopOnSmallReturnsOneLess() { ISeq r = LongRange.create(2, 20); PersistentVector v = PersistentVector.create(r); IPersistentStack s = v.pop(); Expect(v.count()).To.Equal(r.count()); Expect(s.count()).To.Equal(v.count() - 1); }
public void CreateOnISeqHasItems() { ISeq r = LongRange.create(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 CreateOnMultipleItemsWorks() { PersistentVector v = PersistentVector.create(2, 3, 4); Expect(v.count()).To.Equal(3); Expect(v.nth(0)).To.Equal(2); Expect(v.nth(1)).To.Equal(3); Expect(v.nth(2)).To.Equal(4); }
public void CreateOnISeqHasItems() { ISeq r = LongRange.create(2, 5); PersistentVector v = PersistentVector.create(r); Expect((long)v.nth(0)).To.Equal(2); Expect((long)v.nth(1)).To.Equal(3); Expect((long)v.nth(2)).To.Equal(4); }
public void CreateOnMultipleItemsWorks() { PersistentVector v = PersistentVector.create(2, 3, 4); Expect(v.count(), EqualTo(3)); Expect(v.nth(0), EqualTo(2)); Expect(v.nth(1), EqualTo(3)); Expect(v.nth(2), EqualTo(4)); }
public void AssocNAddsAtEndForEmpty() { PersistentVector v1 = PersistentVector.create(); IPersistentVector v2 = v1.assocN(0, "abc"); Expect(v1.count(), EqualTo(0)); Expect(v2.count(), EqualTo(1)); Expect(v2.nth(0), EqualTo("abc")); }
public void CreateOnISeqHasItems() { Range r = new Range(2, 5); PersistentVector v = PersistentVector.create((ISeq)r); Expect(v.nth(0), EqualTo(2)); Expect(v.nth(1), EqualTo(3)); Expect(v.nth(2), EqualTo(4)); }
public void PopOnSmallReturnsOneLess() { Range r = new Range(2, 20); PersistentVector v = PersistentVector.create((ISeq)r); IPersistentStack s = v.pop(); Expect(v.count(), EqualTo(r.count())); Expect(s.count(), EqualTo(v.count() - 1)); }
public void Setup() { IPersistentMap meta = new DummyMeta(); PersistentTreeSet m = PersistentTreeSet.create(RT.seq(PersistentVector.create("a", "b"))); _objWithNullMeta = (IObj)m; _obj = _objWithNullMeta.withMeta(meta); _expectedType = typeof(PersistentTreeSet); }
public void Setup() { IPersistentMap meta = new DummyMeta(); PersistentVector v = PersistentVector.create(2, 3, 4); _testNoChange = false; _objWithNullMeta = (IObj)v; _obj = _objWithNullMeta.withMeta(meta); _expectedType = typeof(PersistentVector); }
public void CreateOnISeqWithManyItemsWorks() { // Want to bust out of the first tail, so need to insert more than 32 elements. Range r = new Range(2, 1000); PersistentVector v = PersistentVector.create((ISeq)r); Expect(v.count(), EqualTo(r.count())); for (int i = 0; i < v.count(); ++i) { Expect(v.nth(i), EqualTo(i + 2)); } }
public void ConsOnNon2IPVFails() { Dictionary <int, string> d = new Dictionary <int, string>(); d[1] = "a"; d[2] = "b"; IPersistentMap m = PersistentArrayMap.create(d); IPersistentVector v = PersistentVector.create(2, "c", 3, "d"); IPersistentMap c = m.cons(v); }
public void EmptyCopiesMeta() { IPersistentMap meta = new DummyMeta(); PersistentVector v1 = PersistentVector.create(1, 2, 3); IPersistentCollection e1 = v1.empty(); PersistentVector v2 = (PersistentVector)v1.withMeta(meta); IPersistentCollection e2 = v2.empty(); Expect(((IObj)e1).meta()).To.Be.Null(); Expect(Object.ReferenceEquals(((IObj)e2).meta(), meta)); }
public void CreateOnISeqWithManyItemsWorks() { // Want to bust out of the first tail, so need to insert more than 32 elements. ISeq r = LongRange.create(2, 1000); PersistentVector v = PersistentVector.create(r); Expect(v.count()).To.Equal(r.count()); for (int i = 0; i < v.count(); ++i) { Expect((long)v.nth(i)).To.Equal(i + 2L); } }
public void Setup() { _mocks = new MockRepository(); IPersistentMap meta = _mocks.StrictMock <IPersistentMap>(); _mocks.ReplayAll(); PersistentVector v = PersistentVector.create(2, 3, 4); _objWithNullMeta = (IObj)v; _obj = _objWithNullMeta.withMeta(meta); _expectedType = typeof(PersistentVector); }
public void EmptyCopiesMeta() { IPersistentMap meta = new DummyMeta(); PersistentVector v1 = PersistentVector.create(1, 2, 3); IPersistentCollection e1 = v1.empty(); PersistentVector v2 = (PersistentVector)v1.withMeta(meta); IPersistentCollection e2 = v2.empty(); Expect(((IObj)e1).meta(), Null); Expect(((IObj)e2).meta(), SameAs(meta)); }
public void PopOnBigWorks() { Range r = new Range(0, 100000); PersistentVector v = PersistentVector.create((ISeq)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 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. ISeq r = LongRange.create(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)); } }