Browse Source

Scaffolding project vs. hand written classes

Maybe scaffold what can be a complete by hand
Sebastien Ros 12 years ago
parent
commit
2dab8046d6

+ 1 - 1
.gitignore

@@ -1,7 +1,7 @@
 ## Ignore Visual Studio temporary files, build results, and
 ## files generated by popular Visual Studio add-ons.
 
-Jint.Tests/suite/
+Jint.Tests/Scripts/
 
 # User-specific files
 *.suo

+ 6 - 0
Jint.Tests.Scaffolding/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+</configuration>

+ 62 - 0
Jint.Tests.Scaffolding/Jint.Tests.Scaffolding.csproj

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{3F0178B0-6E36-4AE3-B791-25E3BBF04B03}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Jint.Tests.Scaffolding</RootNamespace>
+    <AssemblyName>Jint.Tests.Scaffolding</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Fluent.IO">
+      <HintPath>..\packages\FluentPath.1.0.0\lib\Net4\Fluent.IO.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <None Include="packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 54 - 0
Jint.Tests.Scaffolding/Program.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+using Fluent.IO;
+
+namespace Jint.Tests.Scaffolding
+{
+    class Program
+    {
+        private const string SpecsUrl = "http://www.ecma-international.org/ecma-262/5.1/";
+        private static string _specs;
+        private static Path _testPath ;
+        private static Path _suitePath;
+
+        static void Main(string[] args)
+        {
+            // load the local specification cache
+            if (Path.Get("specs.html").Exists)
+            {
+                _specs = Path.Get("specs.html").Read();
+            }
+            else
+            {
+                _specs = new WebClient().DownloadString(SpecsUrl);
+                System.IO.File.WriteAllText("specs.html", _specs);
+            }
+
+            var assemblyPath = typeof(Program).Assembly.Location;
+            var assemblyDirectory = Path.Get(assemblyPath);
+            _testPath = assemblyDirectory.Parent().Parent().Parent().Parent().Combine("Jint.Tests");
+            _suitePath = _testPath.Combine("Test262", "suite");
+
+            ProcessFolder(_suitePath);
+        }
+
+        static void ProcessFolder(Path path)
+        {
+            if (path.Files().Any())
+            {
+                // files are present, we need to create a test class
+
+            }
+        }
+
+        static void ProcessFile(Path file)
+        {
+            
+        }
+    }
+}

+ 36 - 0
Jint.Tests.Scaffolding/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Jint.Tests.Scaffolding")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Jint.Tests.Scaffolding")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("0728e3c4-71d0-4850-9296-d98f32987b19")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 4 - 0
Jint.Tests.Scaffolding/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="FluentPath" version="1.0.0" targetFramework="net45" />
+</packages>

+ 3 - 1
Jint.Tests/Jint.Tests.csproj

@@ -48,10 +48,12 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Test262.cs" />
+    <Compile Include="Test262\06 - Source Text\SourceText.cs" />
+    <Compile Include="Test262\TestBase.cs" />
     <Compile Include="Parser\JavascriptParserTests.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Runtime\EngineTests.cs" />
+    <Compile Include="Test262\07 - Lexical Conventions\WhiteSpace.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Parser\Scripts\jQuery.js" />

+ 26 - 0
Jint.Tests/Test262/06 - Source Text/SourceText.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+using Xunit.Extensions;
+
+namespace Jint.Tests.Test262
+{
+    public class SourceText : TestBase
+    {
+        public SourceText()
+            : base("ch06")
+        {
+        }
+
+        [Theory]
+        [Trait("Description", @"Test for handling of supplementary characters")]
+        [InlineData("6.1.js")]
+        public void TestForHandlingSupplimentaryCharacters(string file)
+        {
+            Run(file);
+        }
+    }
+}

+ 31 - 0
Jint.Tests/Test262/07 - Lexical Conventions/WhiteSpace.cs

@@ -0,0 +1,31 @@
+using Xunit;
+using Xunit.Extensions;
+
+namespace Jint.Tests.Test262
+{
+    public class WhiteSpace : TestBase
+    {
+        public WhiteSpace() : base("ch07", "7.2")
+        {
+        }
+        
+        [Theory]
+        [Trait("Name", @"HORIZONTAL TAB (U+0009) between any two tokens is allowed")]
+        [InlineData("S7.2_A1.1_T1.js")]
+        [InlineData("S7.2_A1.1_T2.js")]
+        public void HorizontalTabU0009BetweenAnyTwoTokensIsAllowed(string file)
+        {
+            Run(file);
+        }
+
+
+        [Theory]
+        [Trait("Name", @"VERTICAL TAB (U+000B) between any two tokens is allowed")]
+        [InlineData("S7.2_A1.2_T1.js")]
+        [InlineData("S7.2_A1.2_T2.js")]
+        public void VerticalTabU000BBetweenAnyTwoTokensIsAllowed(string file)
+        {
+            Run(file);
+        }
+    }
+}

+ 7 - 12
Jint.Tests/Test262.cs → Jint.Tests/Test262/TestBase.cs

@@ -7,16 +7,17 @@ using Xunit.Extensions;
 
 namespace Jint.Tests
 {
-    public class Test262
+    public class TestBase
     {
         private string _basePath;
 
-        public Test262()
+        public TestBase(params string[] segments)
         {
-            _basePath = @"C:\Users\sebros\Documents\My Projects\Jint\Jint.Tests\suite\"; // typeof (Test262).Assembly.Location;
+            _basePath = @"C:\Users\sebros\Documents\My Projects\Jint\Jint.Tests\Scripts\Test262\suite\";
+            _basePath = Path.Combine(_basePath, Path.Combine(segments));
         }
 
-        private void Run(string filename)
+        public void Run(string filename)
         {
             var assembly = Assembly.GetExecutingAssembly();
             var scriptPath = Path.Combine(_basePath, filename);
@@ -26,7 +27,7 @@ namespace Jint.Tests
 
         private Action<string> ERROR = s => { throw new Exception(s); };
 
-        private void RunTest(string source)
+        public void RunTest(string source)
         {
             var engine = new Engine(cfg => cfg
                 .WithDelegate("$ERROR", ERROR)
@@ -35,12 +36,6 @@ namespace Jint.Tests
             engine.Execute(source);
         }
 
-        [Theory]
-        [Trait("Description", "Test for handling of supplementary characters")]
-        [InlineData("ch06/6.1.js")]
-        public void TestForHandlingSupplimentaryCharacters(string file)
-        {
-            Run(file);
-        }
+       
     }
 }

+ 6 - 0
Jint.sln

@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jint.Benchmark", "Jint.Benc
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jint", "Jint\Jint.csproj", "{A2707CFD-E37D-4B88-8FC2-238D4C1DFD01}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jint.Tests.Scaffolding", "Jint.Tests.Scaffolding\Jint.Tests.Scaffolding.csproj", "{3F0178B0-6E36-4AE3-B791-25E3BBF04B03}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -25,6 +27,10 @@ Global
 		{A2707CFD-E37D-4B88-8FC2-238D4C1DFD01}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{A2707CFD-E37D-4B88-8FC2-238D4C1DFD01}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{A2707CFD-E37D-4B88-8FC2-238D4C1DFD01}.Release|Any CPU.Build.0 = Release|Any CPU
+		{3F0178B0-6E36-4AE3-B791-25E3BBF04B03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{3F0178B0-6E36-4AE3-B791-25E3BBF04B03}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3F0178B0-6E36-4AE3-B791-25E3BBF04B03}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{3F0178B0-6E36-4AE3-B791-25E3BBF04B03}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE