Implements an immutable cons cell.
상속: clojure.lang.ASeq
예제 #1
0
        public void CountOfTwoItems()
        {
            Cons c1 = new Cons("abc", null);
            Cons c2 = new Cons("def", c1);

            Expect(c2.count(), EqualTo(2));
        }
예제 #2
0
 public void EmptyIsNull()
 {
     // Test of ASeq
     Cons c = new Cons("abc", null);
     IPersistentCollection empty = c.empty();
     Expect(empty, SameAs(PersistentList.EMPTY));
 }
예제 #3
0
        public void ASeqICollCopyToCopiesToIndexPositive()
        {
            ICollection ic = new Cons(1, new Cons(2, new Cons(3, null)));
            int[] arr = new int[4];
            ic.CopyTo(arr, 1);

            Expect(arr[0], EqualTo(0));
            Expect(arr[1], EqualTo(1));
            Expect(arr[2], EqualTo(2));
            Expect(arr[3], EqualTo(3));
        }
예제 #4
0
 public void NoMetaCtorHasNoMeta()
 {
     Cons c = new Cons("abc",null);
     Expect(c.meta(),Null);
 }
예제 #5
0
 public void SeqIteratorMovedToEmptyHasNoCurrent()
 {
     Cons c = new Cons(1, new Cons(2, null));
     SeqEnumerator s = new SeqEnumerator(c);
     
     s.MoveNext();
     s.MoveNext();
     s.MoveNext();
     
     // Have to assign to access
     object o = s.Current;
 }
예제 #6
0
 public void EmptyIsNull()
 {
     // Test of ASeq
     Cons c = new Cons("abc", null);
     Expect(c.empty(), Null);
 }
예제 #7
0
        public void Setup()
        {
            IPersistentMap meta = PersistentHashMap.create("a", 1, "b", 2);

            Cons c1 = new Cons("abc", null);
            Cons c2 = new Cons(meta,"def", c1);
            _obj = c2;
            _objWithNullMeta = c1;
            _expectedType = typeof(Cons);
        }
예제 #8
0
        public void CountOfOneItem()
        {
            Cons c = new Cons("abc", null);

            Expect(c.count(), EqualTo(1));
        }
예제 #9
0
        public void Cons_ISeq_conses()
        {
            Cons c1 = new Cons("def", null);
            Cons c2 = new Cons("abc", c1);

            VerifyISeqCons(c2, "ghi", new object[] { "abc", "def" });
        }
예제 #10
0
        public void Cons_ISeq_with_meta_has_correct_values()
        {
            IPersistentMap meta = new DummyMeta();

            Cons c1 = new Cons("def", null);
            Cons c2 = new Cons(meta,"abc", c1);

            VerifyISeqContents(c2, new object[] { "abc", "def" });
        }
예제 #11
0
 public void ASeqICollCopyToFailsOnMultidimArray()
 {
     ICollection ic = new Cons(1, new Cons(2, new Cons(3, null)));
     Array arr = Array.CreateInstance(typeof(int), 4, 4);
     ic.CopyTo(arr, 0);
 }
예제 #12
0
 public void ASeqICollCopyToFailsOnInsufficientSpace2()
 {
     ICollection ic = new Cons(1, new Cons(2, new Cons(3, null)));
     Array arr = new object[10];
     ic.CopyTo(arr, 8);
 }
예제 #13
0
 public void ASeqICollCopyToFailsOnNullArray()
 {
     ICollection ic = new Cons(1, null);
     ic.CopyTo(null, 0);
 }
예제 #14
0
        // Some aspects of ASeq have been tested above.  
        // Here are the remaining bits

        private Cons CreateComplicatedCons()
        {
            Cons c1 = new Cons(1, null);
            Cons c2 = new Cons(2, c1);
            Cons c3 = new Cons("abc", null);
            Cons c4 = new Cons(c3, c2);
            Cons c5 = new Cons("def", c4);

            return c5;
        }
예제 #15
0
        public void Cons_ISeq_with_meta_has_correct_values()
        {
            MockRepository mocks = new MockRepository();
            IPersistentMap meta = mocks.StrictMock<IPersistentMap>();
            mocks.ReplayAll();

            Cons c1 = new Cons("def", null);
            Cons c2 = new Cons(meta,"abc", c1);

            VerifyISeqContents(c2, new object[] { "abc", "def" });
            mocks.VerifyAll();
        }
예제 #16
0
        public void SeqIteratorResetAtEndWorks()
        {
            Cons c = new Cons(1, new Cons(2, null));
            SeqEnumerator s = new SeqEnumerator(c);

            s.MoveNext();
            s.MoveNext();
            s.MoveNext();
            s.Reset();

            Expect(s.MoveNext());
            Expect(s.Current, EqualTo(1));
            Expect(s.MoveNext());
            Expect(s.Current, EqualTo(2));
            Expect(s.Current, EqualTo(2));
            Expect(s.MoveNext(), False);
        }
예제 #17
0
 public void ASeqICollCopyToFailsOnNegativeIndex()
 {
     ICollection ic = new Cons(1, new Cons(2, new Cons(3, null)));
     Array arr = new object[10];
     ic.CopyTo(arr, -1);
 }
예제 #18
0
        public void Cons_ISeq_has_correct_values()
        {
            Cons c1 = new Cons("def", null);
            Cons c2 = new Cons("abc", c1);

            VerifyISeqContents(c2, new object[] { "abc", "def" });
        }
예제 #19
0
        public void ASeqICollCountWorks()
        {
            ICollection ic = new Cons(1, new Cons(2, new Cons(3, null)));

            Expect(ic.Count, EqualTo(3));
        }
예제 #20
0
 public void MetaCtorHasMeta()
 {
     IPersistentMap meta = new DummyMeta();
     Cons c = new Cons(meta, "abc", null);
     Expect(c.meta(), SameAs(meta));
 }
예제 #21
0
        public void SeqReturnsSelf()
        {
            Cons c1 = new Cons("abc", null);

            Expect(c1.seq(), SameAs(c1));
        }
예제 #22
0
        public void Setup()
        {
            IPersistentMap meta = new DummyMeta();

            Cons c1 = new Cons("abc", null);
            Cons c2 = new Cons(meta,"def", c1);
            _obj = c2;
            _objWithNullMeta = c1;
            _expectedType = typeof(Cons);
        }
예제 #23
0
        public void IPC_Cons_works()
        {
            Cons c1 = new Cons("abc", null);
            IPersistentCollection ipc1 = c1 as IPersistentCollection;

            IPersistentCollection ipc2 = ipc1.cons("def");
            ISeq s = ipc2.seq();

            Expect(s.first(), EqualTo("def"));
            Expect(s.next(), SameAs(c1));
        }
예제 #24
0
 public void ASeqICollIsSynchronized()
 {
     ICollection ic = new Cons(1, new Cons(2, new Cons(3, null)));
     Expect(ic.IsSynchronized);
 }
예제 #25
0
        public void MetaCtorHasMeta()
        {
            MockRepository mocks = new MockRepository();
            IPersistentMap meta = mocks.StrictMock<IPersistentMap>();
            mocks.ReplayAll();

            Cons c = new Cons(meta, "abc", null);

            Expect(c.meta(), SameAs(meta));
            mocks.VerifyAll();
        }
예제 #26
0
 public void ASeqICollImplementsSyncRoot()
 {
     ICollection ic = new Cons(1, new Cons(2, new Cons(3, null)));
     Object o = ic.SyncRoot;
     Expect(o, SameAs(ic));
 }
예제 #27
0
        public void ASeqIEnumWorks()
        {
            ICollection ic = new Cons(1, new Cons(2, new Cons(3, null)));
            IEnumerator e = ic.GetEnumerator();

            Expect(e.MoveNext());
            Expect(e.Current, EqualTo(1));
            Expect(e.MoveNext());
            Expect(e.Current, EqualTo(2));
            Expect(e.MoveNext());
            Expect(e.Current, EqualTo(3));
            Expect(e.MoveNext(),False); 
        }
예제 #28
0
 /// <summary>
 /// Notify all watchers.
 /// </summary>
 public void notifyWatches()
 {
     IPersistentMap ws = _watchers;
      if (ws.count() > 0)
      {
          ISeq args = new Cons(this, null);
          for (ISeq s = RT.seq(ws); s != null; s = s.rest())
          {
              IMapEntry me = (IMapEntry)s.first();
              object[] a = (object[])me.val();
              Agent agent = (Agent)me.key();
              try
              {
                  agent.dispatch((IFn)a[0], args, (Boolean)a[1]);
              }
              catch (Exception)
              {
                  // eat dispatching exceptions and continue
              }
          }
      }
 }
예제 #29
0
 public void ASeqICollHasDoesntImplementSyncRoot()
 {
     ICollection ic = new Cons(1, new Cons(2, new Cons(3, null)));
     Object o = ic.SyncRoot;
 }