コード例 #1
0
		public void InputMatchesFirstParserAndSecondParser_SecondParserShorter_Success()
		{
			IScanner letter = new StringScanner("abc");
			DifferenceParser parser = new DifferenceParser(Ops.Sequence(this._letterOrDigit, this._letterOrDigit),
																this._letterOrDigit);
			Assert.IsTrue(parser.Parse(letter).Success);
		}
コード例 #2
0
		public void InputMatchesFirstParserAndSecondParser_SecondParserLonger_Fail()
		{
			IScanner letter = new StringScanner("abc");
			DifferenceParser parser = new DifferenceParser(this._letterOrDigit,
											Ops.Sequence(this._letterOrDigit, this._letterOrDigit));

			Assert.IsFalse(parser.Parse(letter).Success);
		}
コード例 #3
0
		public void InputDoesNotMatchFirstParserButMatchesSecondParser_Actions_None()
		{
			IScanner symbol = new StringScanner("+");
			DifferenceParser parser = new DifferenceParser(this._letterOrDigit, this._symbol);
			parser.Act += OnDifferenceParserSuccess;
			parser.Parse(symbol);
			Assert.IsFalse(_differenceParserSuccess);
			Assert.IsFalse(_letterOrDigitParserSuccess);
			Assert.IsFalse(_symbolParserSuccess); // should never call since first parser doesn't match
		}
コード例 #4
0
		public void InputDoesNotMatchFirstParserButMatchesSecondParser_ScanPosition_NoChange()
		{
			IScanner symbol = new StringScanner("+hello");
			DifferenceParser parser = new DifferenceParser(this._letterOrDigit, this._symbol);
			parser.Parse(symbol);
			Assert.AreEqual(0, symbol.Offset);
		}
コード例 #5
0
		public void InputDoesNotMatchFirstParserButMatchesSecondParser_Fail()
		{
			IScanner symbol = new StringScanner("+");
			DifferenceParser parser = new DifferenceParser(this._letterOrDigit, this._symbol);
			parser.Act += OnDifferenceParserSuccess;
			Assert.IsFalse(parser.Parse(symbol).Success);
		}