Browse Source

Adding SunSpider tests

Sebastien Ros 12 years ago
parent
commit
a408be737e

+ 1 - 1
Jint.Benchmark/Program.cs

@@ -36,7 +36,7 @@ namespace Jint.Benchmark
             bool runJint = true;
             bool runJint = true;
             bool runJurassic = true;
             bool runJurassic = true;
 
 
-            const int iterations = 100;
+            const int iterations = 1;
             const bool reuseEngine = false;
             const bool reuseEngine = false;
 
 
             var watch = new Stopwatch();
             var watch = new Stopwatch();

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

@@ -51,6 +51,7 @@
     <Compile Include="Parser\JavascriptParserTests.cs" />
     <Compile Include="Parser\JavascriptParserTests.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Runtime\EngineTests.cs" />
     <Compile Include="Runtime\EngineTests.cs" />
+    <Compile Include="Runtime\SunSpiderTests.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Parser\Scripts\jQuery.js" />
     <EmbeddedResource Include="Parser\Scripts\jQuery.js" />

+ 21 - 0
Jint.Tests/Runtime/EngineTests.cs

@@ -220,6 +220,27 @@ namespace Jint.Tests.Runtime
             ");
             ");
         }
         }
 
 
+        [Fact]
+        public void ArrayFunctionInitializesLength()
+        {
+            RunTest(@"
+                assert(Array(3).length == 3);
+                assert(Array('3').length == 1);
+            ");
+        }
+
+        [Fact]
+        public void ArrayIndexerIsAssigned()
+        {
+            RunTest(@"
+                var n = 8;
+                var o = Array(n);
+                for (var i = 0; i < n; i++) o[i] = i;
+                assert(o[0] == 0);
+                assert(o[7] == 7);
+            ");
+        }
+
         [Fact]
         [Fact]
         public void ArrayPopShouldDecrementLength()
         public void ArrayPopShouldDecrementLength()
         {
         {

+ 226 - 0
Jint.Tests/Runtime/SunSpiderTests.cs

@@ -0,0 +1,226 @@
+using System;
+using System.Net;
+using Xunit;
+using Xunit.Extensions;
+
+namespace Jint.Tests.Runtime
+{
+    public class SunSpiderTests
+    {
+        private Engine RunTest(string source)
+        {
+            var engine = new Engine(cfg => cfg
+                .WithDelegate("log", new Action<object>(Console.WriteLine))
+                .WithDelegate("assert", new Action<bool>(Assert.True))
+            );
+
+            engine.Execute(source);
+
+            return engine;
+        }
+
+        [Theory]
+        [InlineData("3d-cube", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/3d-cube.js")]
+        public void ThreeDCube(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("3d-morph", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/3d-morph.js")]
+        public void ThreeDMorph(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("3d-raytrace", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/3d-raytrace.js")]
+        public void ThreeDRaytrace(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("access-binary-trees", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/access-binary-trees.js")]
+        public void AccessBinaryTrees(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("access-fannkuch", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/access-fannkuch.js")]
+        public void AccessFannkych(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("access-nbody", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/access-nbody.js")]
+        public void AccessNBody(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("access-nsieve", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/access-nsieve.js")]
+        public void AccessNSieve(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [InlineData("bitops-3bit-bits-in-byte", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/bitops-3bit-bits-in-byte.js")]
+        public void Bitops3BitBitsInByte(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("bitops-bits-in-byte", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/bitops-bits-in-byte.js")]
+        public void BitopsBitsInByte(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("bitops-bitwise-and", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/bitops-bitwise-and.js")]
+        public void BitopsBitwiseAnd(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("bitops-nsieve-bits", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/bitops-nsieve-bits.js")]
+        public void BitopsNSieveBits(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("controlflow-recursive", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/controlflow-recursive.js")]
+        public void ControlFlowRecursive(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("crypto-aes", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/crypto-aes.js")]
+        public void CryptoAES(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("crypto-md5", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/crypto-md5.js")]
+        public void CryptoMD5(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [InlineData("crypto-sha1", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/crypto-sha1.js")]
+        public void CryptoSha1(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("date-format-tofte", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/date-format-tofte.js")]
+        public void DateFormatTofte(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("date-format-xparb", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/date-format-xparb.js")]
+        public void DateFormatXParb(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [InlineData("math-cordic", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/math-cordic.js")]
+        public void MathCordic(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("math-partial-sums", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/math-partial-sums.js")]
+        public void MathPartialSums(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("math-spectral-norm", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/math-spectral-norm.js")]
+        public void MathSpectralNorm(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("regexp-dna", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/regexp-dna.js")]
+        public void RegexpDna(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("string-base64", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/string-base64.js")]
+        public void StringBase64(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [InlineData("string-fasta", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/string-fasta.js")]
+        public void StringFasta(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("string-tagcloud", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/string-tagcloud.js")]
+        public void StringTagCloud(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("string-unpack-code", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/string-unpack-code.js")]
+        public void StringUnpackCode(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+
+        [Theory]
+        [InlineData("string-validate-input", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/string-validate-input.js")]
+        public void StringValidateInput(string name, string url)
+        {
+            var content = new WebClient().DownloadString(url);
+            Assert.DoesNotThrow(() => RunTest(content));
+        }
+    }
+}