Exemple #1
0
        /// <summary>
        /// Return a Dafny class (list of lines) with tests for the given Dafny file
        /// </summary>
        public static IEnumerable <string> GetTestClassForProgram(string sourceFile)
        {
            var source  = new StreamReader(sourceFile).ReadToEnd();
            var program = Utils.Parse(source, sourceFile);

            if (program == null)
            {
                yield break;
            }
            var dafnyInfo = new DafnyInfo(program);
            var rawName   = sourceFile.Split("/").Last().Split(".").First();

            yield return($"include \"{sourceFile}\"");

            yield return($"module {rawName}UnitTests {{");

            foreach (var module in dafnyInfo.ToImport)
            {
                yield return($"import {module}");
            }

            foreach (var method in GetTestMethodsForProgram(program, dafnyInfo))
            {
                yield return(method.ToString());
            }

            yield return("}");
        }
Exemple #2
0
            private bool insideAClass; // method is inside a class (not static)

            internal DafnyInfoExtractor(DafnyInfo info)
            {
                this.info    = info;
                insideAClass = false;
                path         = new List <string>();
            }