public void Test_3_5_6_Numbers_G() { // Float Scanner lexer = this.GetLexer("123.45e"); object obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(FloatEToken)); FloatEToken token = (FloatEToken)obj; Assert.IsFalse(token.IsValid); Assert.AreEqual("Invalid float. No digits found after exponent.", token.ScanError); Assert.AreEqual(0, token.StartPosition.Position); Assert.AreEqual(7, token.StopPosition.Position); }
public void Test_3_5_6_Numbers_F() { // Float Scanner lexer = this.GetLexer("123.45"); object obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(FloatDToken)); // FloatD is actually more precise to represent the float than FloatE FloatDToken tokenD = (FloatDToken)obj; Assert.IsTrue(tokenD.IsValid); Assert.IsNull(tokenD.ScanError); Assert.AreEqual(0, tokenD.StartPosition.Position); Assert.AreEqual(5, tokenD.StopPosition.Position); Assert.AreEqual(123.45, tokenD.Value); // Should be the last one obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(EofToken)); lexer = this.GetLexer("123.0e3"); obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(FloatEToken)); FloatEToken token = (FloatEToken)obj; Assert.IsTrue(token.IsValid); Assert.IsNull(token.ScanError); Assert.AreEqual(0, token.StartPosition.Position); Assert.AreEqual(6, token.StopPosition.Position); Assert.AreEqual(123000.0, token.Value); // Should be the last one obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(EofToken)); lexer = this.GetLexer("123.0q3"); obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(FloatDToken)); tokenD = (FloatDToken)obj; Assert.IsTrue(tokenD.IsValid); Assert.IsNull(tokenD.ScanError); Assert.AreEqual(0, tokenD.StartPosition.Position); Assert.AreEqual(6, tokenD.StopPosition.Position); Assert.AreEqual(123000.0, tokenD.Value); // Should be the last one obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(EofToken)); lexer = this.GetLexer("123.0d3"); obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(FloatDToken)); tokenD = (FloatDToken)obj; Assert.IsTrue(tokenD.IsValid); Assert.IsNull(tokenD.ScanError); Assert.AreEqual(0, tokenD.StartPosition.Position); Assert.AreEqual(6, tokenD.StopPosition.Position); Assert.AreEqual(123000.0, tokenD.Value); // Should be the last one obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(EofToken)); lexer = this.GetLexer("123.0e-2"); obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(FloatEToken)); token = (FloatEToken)obj; Assert.IsTrue(token.IsValid); Assert.IsNull(token.ScanError); Assert.AreEqual(0, token.StartPosition.Position); Assert.AreEqual(7, token.StopPosition.Position); Assert.AreEqual(1.23F, token.Value); // Should be the last one obj = lexer.GetToken(); Assert.IsInstanceOfType(obj, typeof(EofToken)); }