Beispiel #1
0
        public void TestConstants(string s)
        {
            var fs = FiniteString.Constant(s);
            var f  = Function(() => fs);

            Assert.IsTrue(f.Assert(x => x == s));
        }
Beispiel #2
0
 public void TestSuffixOfRandom()
 {
     RandomStrings(s =>
     {
         var f  = Function <FiniteString, bool>(fs => FiniteString.Constant(s).EndsWith(fs));
         var ex = f.Find((fs, b) => b).Value.ToString();
         Assert.IsTrue(s.EndsWith(ex));
     });
 }
Beispiel #3
0
        /// <summary>
        /// Convert an input to the Zen string type.
        /// </summary>
        /// <param name="s">The string.</param>
        /// <returns></returns>
        private static Zen <TZen> ConvertStringConstant <TZen>(string s)
        {
            var type = typeof(TZen);

            if (type == ReflectionUtilities.StringType)
            {
                return((Zen <TZen>)(object) Language.String(s));
            }

            if (type == ReflectionUtilities.FiniteStringType)
            {
                return((Zen <TZen>)(object) FiniteString.Constant(s));
            }

            throw new ZenException($"Invalid implicit conversion from string to type: {type}");
        }