Example #1
0
#pragma warning restore IDE0022 // Use expression body for methods

        static char Next(string vars, char next)
        {
            var e    = ExprExtractor.GetExpression(vars).Single();
            var uniq = new UniqVariable(e);

            return(uniq.Next(next));
        }
Example #2
0
        public void State()
        {
            var uniq = new UniqVariable(ExprExtractor.GetExpression("c").Single());

            Assert.AreEqual('b', uniq.Next('b'));
            Assert.AreEqual('a', uniq.Next('b'));
            Assert.AreEqual('d', uniq.Next('b'));
        }
Example #3
0
        public Evaluation(string input)
        {
            var expression = ExprExtractor.GetExpression(input);

            var calc = new Calculator(expression);

            calc.Evaluate();

            Results = calc.Results;
            Error   = calc.Error;
        }
Example #4
0
        public void Errors()
        {
            var abcxyz = "abcdefghijklmnopqrstuvwxyz";

            Assert.ThrowsException <InvalidOperationException>(() => Next(abcxyz.ToUpper(), 'A'));
            Assert.ThrowsException <InvalidOperationException>(() => Next(abcxyz, 'a'));

            var bcxyz = abcxyz.Substring(1);
            var uniq  = new UniqVariable(ExprExtractor.GetExpression(bcxyz + abcxyz.ToUpper()).Single());

            Assert.AreEqual('a', uniq.Next('a'));
            Assert.ThrowsException <InvalidOperationException>(() => uniq.Next('a'));

            uniq = new UniqVariable(ExprExtractor.GetExpression(bcxyz).Single());
            Assert.AreEqual('a', uniq.Next('b'));
            Assert.ThrowsException <InvalidOperationException>(() => uniq.Next('a'));
        }
Example #5
0
 static void IsSame(string input) => Assert.AreEqual(input, string.Join(Environment.NewLine, ExprExtractor.GetExpression(input)));
Example #6
0
 static Expression Parse(string input) => ExprExtractor.GetExpression(splitLines.Replace(input, Environment.NewLine)).Single();