Exemplo n.º 1
0
 public void TestAddSameWithCharProducesSameStringInstance()
 {
     var st = new StringTable();
     var s1 = st.Add(' ');
     var s2 = st.Add(' ');
     Assert.Same(s1, s2);
 }
Exemplo n.º 2
0
 public void TestSharedAddSameWithCharProducesSameStringInstance()
 {
     // Regression test for a bug where single-char strings were not being
     // found in the shared table.
     var s1 = new StringTable().Add(' ');
     var s2 = new StringTable().Add(' ');
     Assert.Same(s1, s2);
 }
Exemplo n.º 3
0
 public void TestSharedAddSameWithStringBuilderProducesSameStringInstance()
 {
     var sb1 = new StringBuilder("foo");
     var sb2 = new StringBuilder("foo");
     var s1 = new StringTable().Add(sb1);
     var s2 = new StringTable().Add(sb2);
     Assert.Same(s1, s2);
 }
Exemplo n.º 4
0
 public void TestAddDifferentWithStringBuilderProducesDifferentStringInstance()
 {
     var st = new StringTable();
     var sb1 = new StringBuilder("foo");
     var sb2 = new StringBuilder("bar");
     var s1 = st.Add(sb1);
     var s2 = st.Add(sb2);
     Assert.NotEqual((object)s1, (object)s2);
 }
Exemplo n.º 5
0
 public SlidingTextWindow(SourceText text)
 {
     _text = text;
     _basis = 0;
     _offset = 0;
     _textEnd = text.Length;
     _strings = StringTable.GetInstance();
     _characterWindow = s_windowPool.Allocate();
     _lexemeStart = 0;
 }
 public SlidingTextWindow(SourceText text)
 {
     this.text = text;
     this.basis = 0;
     this.offset = 0;
     this.textEnd = text.Length;
     this.strings = StringTable.GetInstance();
     this.characterWindow = windowPool.Allocate();
     this.lexemeStart = 0;
 }
Exemplo n.º 7
0
        public void TestAddSameWithVariousInputsProducesSameStringInstance()
        {
            var st = new StringTable();

            var s1 = st.Add(new StringBuilder(" "));
            var s2 = st.Add(' ');
            Assert.Same(s1, s2);

            var s3 = st.Add(" ");
            Assert.Same(s2, s3);

            var s4 = st.Add(new char[1] { ' ' }, 0, 1);
            Assert.Same(s3, s4);

            var s5 = st.Add("ABC DEF", 3, 1);
            Assert.Same(s4, s5);
        }
 protected LexerBaseCache(StringTable strings)
 {
     this.strings = strings;
 }
 internal LexerBaseCache()
 {
     this.strings = new StringTable();
 }
Exemplo n.º 10
0
        // implement Poolable object pattern
        #region "Poolable"

        private TextKeyedCache(ObjectPool <TextKeyedCache <T> > pool)
        {
            _pool    = pool;
            _strings = new StringTable();
        }
Exemplo n.º 11
0
        // implement Poolable object pattern
        #region "Poolable"

        private TextKeyedCache(ObjectPool <TextKeyedCache <T> > pool)
        {
            this.pool    = pool;
            this.strings = new StringTable();
        }