コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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());
        }