public void TestIntegers() { const string source = "1337 0x1337 25"; LexemeCollection <LoreToken> actual = null; Assert.DoesNotThrow(() => actual = Support.GrabLexer(source).Tokenize()); Assert.That(actual?.All(tk => tk.Token == LoreToken.IntLiteral) ?? false); Assert.That(actual?.Any(tk => tk.Value == "1337") ?? false); Assert.That(actual?.Any(tk => tk.Value == "4919") ?? false); Assert.That(actual?.Any(tk => tk.Value == "25") ?? false); }
public void TestIdentifiers() { const string source = "these are four identifiers"; LexemeCollection <LoreToken> actual = null; Assert.DoesNotThrow(() => actual = Support.GrabLexer(source).Tokenize()); Assert.That(actual?.All(tk => tk.Token == LoreToken.Identifier) ?? false); Assert.That(actual?.Any(tk => tk.Value == "these") ?? false); Assert.That(actual?.Any(tk => tk.Value == "are") ?? false); Assert.That(actual?.Any(tk => tk.Value == "four") ?? false); Assert.That(actual?.Any(tk => tk.Value == "identifiers") ?? false); }
public void TestFloats() { var source = ".10 13.37 73.31 1."; LexemeCollection <LoreToken> actual = null; Assert.DoesNotThrow(() => actual = Support.GrabLexer(source).Tokenize()); Assert.That(actual?.All(tk => tk.Token == LoreToken.FloatLiteral) ?? false); Assert.That(actual?.Any(tk => tk.Value == "13.37") ?? false); Assert.That(actual?.Any(tk => tk.Value == "73.31") ?? false); Assert.That(actual?.Any(tk => tk.Value == "0.10") ?? false); Assert.That(actual?.Any(tk => tk.Value == "1.0") ?? false); source = "0. 1..something"; Assert.DoesNotThrow(() => actual = Support.GrabLexer(source).Tokenize()); }