예제 #1
0
파일: Main.cs 프로젝트: mschlaipfer/dafny
        /// <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("}");
        }
예제 #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>();
            }