예제 #1
0
 public void TestJumpTableOptimizationBranches()
 {
     for (char i = '\0'; i <= 128; i++)
     {
         if (SimpleTokenizer.AllowedSingleCharacters.AsSpan().Contains(i))
         {
             continue;
         }
         Assert.Throws <InvalidTokenParsingException>(() => SimpleTokenizer.ParseCharacterToken(i, null));
     }
 }
예제 #2
0
        public void VerifyAllSingleCharTokensParseCorrectly()
        {
            var tokenizer = new Compiler.Tokenizer.SimpleTokenizer();
            var singleCharTokenClasses = typeof(ISingleCharToken).Assembly.GetTypes().Where(x => !x.IsInterface).Where(x => x.GetInterfaces().Contains(typeof(ISingleCharToken)));

            foreach (var tokenClass in singleCharTokenClasses)
            {
                var  tokenCharValueField = tokenClass.GetField("CharValue", BindingFlags.Public | BindingFlags.Static);
                char c = (char)tokenCharValueField.GetValue(null);

                Assert.IsType(tokenClass, SimpleTokenizer.ParseCharacterToken(c, null));
            }
        }
예제 #3
0
        public void TestTokenizerInvalidSingleCharTokenFails()
        {
            var tokenizer = new Compiler.Tokenizer.SimpleTokenizer();

            Assert.Throws <InvalidTokenParsingException>(() => SimpleTokenizer.ParseCharacterToken('c', null));
        }