public void ReturnEmptyCharWhenNoMoreSource()
        {
            var source = new SourceProgram(string.Empty);

            char next = source.Inspect();

            Assert.AreEqual('\0', next);
        }
        public void ReadCurrentCharShouldReturnNextCharAndAdvance()
        {
            var source = new SourceProgram("12");

            var next = source.ReadCurrentCharacter();
            Assert.AreEqual('1', next);

            next = source.ReadCurrentCharacter();
            Assert.AreEqual('2', next);
        }
        public void AdvanceShouldRemoveCharacter()
        {
            var source = new SourceProgram("Begin");

            for (int i = 0; i < 5; i++)
            {
                source.Advance();
            }

            Assert.AreEqual('\0',source.Inspect());
        }
        public void AllowCreationWithEmptySource()
        {
            var source = new SourceProgram(string.Empty);

            Assert.IsNotNull(source);
        }
        public void AdvanceOnEmptyShouldFail()
        {
            var source = new SourceProgram(string.Empty);

            Assert.Throws<InvalidOperationException>(() => source.Advance());
        }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MicroScanner"/> class.
 /// </summary>
 /// <param name="program">The program.</param>
 public MicroScanner(string program)
 {
     this.program       = program;
     this.sourceProgram = new SourceProgram(this.program);
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MicroScanner"/> class.
 /// </summary>
 /// <param name="program">The program.</param>
 public MicroScanner(string program)
 {
     this.program = program;
     this.sourceProgram = new SourceProgram(this.program);
 }