Esempio n. 1
0
        /// <summary>
        /// Pretty prints the path condition of the execution node.
        /// </summary>
        /// <param name="host">Host of the Pex Path Component</param>
        /// <param name="node">The execution node to map</param>
        /// <returns>The pretty printed path condition string</returns>
        private Task <string> PrettyPrintPathCondition(TermEmitter emitter, IMethodBodyWriter mbw, SafeStringWriter ssw, IExecutionNode node)
        {
            MessageBox.Show("PrettyPrintPathCondition()");
            var task = Task.Factory.StartNew(() =>
            {
                string output = "";
                try
                {
                    if (node.GetPathCondition().Conjuncts.Count != 0)
                    {
                        if (emitter.TryEvaluate(node.GetPathCondition().Conjuncts, 2000, mbw)) // TODO Perf leak
                        {
                            for (int i = 0; i < node.GetPathCondition().Conjuncts.Count - 1; i++)
                            {
                                mbw.ShortCircuitAnd();
                            }

                            mbw.Statement();
                            var safeString = ssw.ToString();
                            output         = safeString.Remove(ssw.Length - 3);
                        }
                    }
                }
                catch (Exception) { }
                return(output);
            });

            return(task);
        }
Esempio n. 2
0
        /// <summary>
        /// Pretty prints the path condition of the given execution node.
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private string PrettyPrintPathCondition(IExecutionNode node)
        {
            string output = "";

            try
            {
                if (node.GetPathCondition().Conjuncts.Count != 0)
                {
                    TermEmitter       termEmitter      = new TermEmitter(pathComponent.GetService <TermManager>());
                    SafeStringWriter  safeStringWriter = new SafeStringWriter();
                    IMethodBodyWriter methodBodyWriter = pathComponent.GetService <IPexTestManager>().Language.CreateBodyWriter(safeStringWriter, VisibilityContext.Private, 2000);
                    if (termEmitter.TryEvaluate(node.GetPathCondition().Conjuncts, 2000, methodBodyWriter))
                    {
                        for (int i = 0; i < node.GetPathCondition().Conjuncts.Count - 1; i++)
                        {
                            methodBodyWriter.ShortCircuitAnd();
                        }

                        methodBodyWriter.Statement();

                        output = safeStringWriter.ToString().Remove(safeStringWriter.ToString().Count() - 3);
                    }
                }
            }
            catch (Exception e)
            {
                // TODO : Exception handling?
            }
            return(output);
        }