コード例 #1
0
        static void Main(string[] args)
        {
            var assemblyPath      = typeof(Program).Assembly.Location;
            var assemblyDirectory = Path.Get(assemblyPath);

            _testPath  = assemblyDirectory.Parent().Parent().Parent().Parent().Combine("Jint.Tests.Ecma");
            _suitePath = _testPath;
            if (!_suitePath.Exists)
            {
                _suitePath.CreateDirectory();
            }

            _classTemplate  = File.ReadAllText("ClassTemplate.txt");
            _methodTemplate = File.ReadAllText("MethodTemplate.txt");

            foreach (var url in suites)
            {
                var     content    = new WebClient().DownloadString(url);
                dynamic suite      = JsonConvert.DeserializeObject(content);
                var     collection = suite.testsCollection;
                var     tests      = collection.tests;

                Console.Write(".");

                foreach (var test in tests)
                {
                    byte[] data          = Convert.FromBase64String((string)test.code);
                    string decodedString = Encoding.UTF8.GetString(data);

                    RenderTest(
                        decodedString,
                        (string)test.commentary,
                        (string)test.description,
                        (string)test.path,
                        test.negative != null
                        );
                }
            }

            foreach (var category in categorizedTests.Keys)
            {
                var file = _testPath.Combine("Ecma").Combine(category + ".cs");

                var methods = new StringBuilder();
                foreach (var test in categorizedTests[category])
                {
                    methods.Append(test.Test);
                    methods.AppendLine();
                }

                var fileContent = _classTemplate;
                fileContent = fileContent.Replace("$$Methods$$", methods.ToString());
                fileContent = fileContent.Replace("$$ClassName$$", GetClassName(category));

                File.WriteAllText(file.FullPath, fileContent);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Rohansi/jint
        static void Main(string[] args)
        {

            var assemblyPath = typeof(Program).Assembly.Location;
            var assemblyDirectory = Path.Get(assemblyPath);
            _testPath = assemblyDirectory.Parent().Parent().Parent().Parent().Combine("Jint.Tests.Ecma");
            _suitePath = _testPath;
            if (!_suitePath.Exists)
            {
                _suitePath.CreateDirectory();
            }

            _classTemplate = File.ReadAllText("ClassTemplate.txt");
            _methodTemplate = File.ReadAllText("MethodTemplate.txt");

            foreach(var url in suites) {
                var content = new WebClient().DownloadString(url);
                dynamic suite = JsonConvert.DeserializeObject(content);
                var collection = suite.testsCollection;
                var tests = collection.tests;

                Console.Write(".");

                foreach (var test in tests)
                {
                    byte[] data = Convert.FromBase64String((string)test.code);
                    string decodedString = Encoding.UTF8.GetString(data);

                    RenderTest(
                        decodedString,
                        (string)test.commentary,
                        (string)test.description,
                        (string)test.path,
                        test.negative != null
                        );
                }
            }

            foreach (var category in categorizedTests.Keys)
            {
                var file = _testPath.Combine("Ecma").Combine(category + ".cs");

                var methods = new StringBuilder();
                foreach (var test in categorizedTests[category])
                {
                    methods.Append(test.Test);
                    methods.AppendLine();
                }

                var fileContent = _classTemplate;
                fileContent = fileContent.Replace("$$Methods$$", methods.ToString());
                fileContent = fileContent.Replace("$$ClassName$$", GetClassName(category));

                File.WriteAllText(file.FullPath, fileContent);
            }
        }