Beispiel #1
0
        public void TestPrivatePools()
        {
            SymbolPool p1  = new SymbolPool();
            SymbolPool p2  = new SymbolPool(3);
            SymbolPool p3  = new SymbolPool(0);
            Symbol     a   = GSymbol.Get("a");
            Symbol     b   = GSymbol.Get("b");
            Symbol     c   = GSymbol.Get("c");
            Symbol     s1a = p1.Get("a");
            Symbol     s1b = p1.Get("b");
            Symbol     s1c = p1.Get("c");
            Symbol     s2a = p2.Get("a");
            Symbol     s3a = p3.Get("a");
            Symbol     s3b = p3.Get("b");

            Assert.That(s1a.Id == 1 && p1.GetById(1) == s1a);
            Assert.That(s1b.Id == 2 && p1.GetById(2) == s1b);
            Assert.That(s1c.Id == 3 && p1.GetById(3) == s1c);
            Assert.That(s2a.Id == 3 && p2.GetById(3) == s2a);
            Assert.That(s3b.Id == 1 && p3.GetById(1) == s3b);
            Assert.That(s3a.Id == 0 && p3.GetById(0) == s3a);
            Assert.AreEqual(GSymbol.Empty, p1.GetById(0));
            Assert.AreEqual(s1c, p1.GetIfExists("c"));
            Assert.AreEqual(3, p1.TotalCount);
            Assert.AreEqual(null, p2.GetIfExists("c"));
            Assert.AreEqual(c, p2.GetGlobalOrCreateHere("c"));
            Assert.AreEqual(p2, p2.GetGlobalOrCreateHere("$!unique^&*").Pool);
        }
Beispiel #2
0
 static GSymbol()
 {
     Pool  = new SymbolPool(0, false, 0);
     Empty = Pool.Get("");
     Debug.Assert(Empty.Id == 0 && Empty.Name == "");
     Debug.Assert(((Symbol)Empty).Pool == Pool);
 }