SunSpiderTests.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. using System;
  2. using System.Net;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using Jint.Runtime;
  6. using Xunit;
  7. using Xunit.Extensions;
  8. namespace Jint.Tests.CommonScripts
  9. {
  10. public class SunSpiderTests
  11. {
  12. private Engine RunTest(string source)
  13. {
  14. var engine = new Engine()
  15. .SetValue("log", new Action<object>(Console.WriteLine))
  16. .SetValue("assert", new Action<bool>(Assert.True))
  17. ;
  18. try
  19. {
  20. engine.Execute(source);
  21. }
  22. catch (JavaScriptException je)
  23. {
  24. throw new Exception(je.ToString());
  25. }
  26. return engine;
  27. }
  28. [Theory]
  29. [InlineData("3d-cube", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/3d-cube.js")]
  30. public void ThreeDCube(string name, string url)
  31. {
  32. var content = new WebClient().DownloadString(url);
  33. RunTest(content);
  34. }
  35. [Theory]
  36. [InlineData("3d-morph", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/3d-morph.js")]
  37. public void ThreeDMorph(string name, string url)
  38. {
  39. var content = new WebClient().DownloadString(url);
  40. RunTest(content);
  41. }
  42. [Theory]
  43. [InlineData("3d-raytrace", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/3d-raytrace.js")]
  44. public void ThreeDRaytrace(string name, string url)
  45. {
  46. var content = new WebClient().DownloadString(url);
  47. RunTest(content);
  48. }
  49. [Theory]
  50. [InlineData("access-binary-trees", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/access-binary-trees.js")]
  51. public void AccessBinaryTrees(string name, string url)
  52. {
  53. var content = new WebClient().DownloadString(url);
  54. RunTest(content);
  55. }
  56. [Theory]
  57. [InlineData("access-fannkuch", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/access-fannkuch.js")]
  58. public void AccessFannkych(string name, string url)
  59. {
  60. var content = new WebClient().DownloadString(url);
  61. RunTest(content);
  62. }
  63. [Theory]
  64. [InlineData("access-nbody", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/access-nbody.js")]
  65. public void AccessNBody(string name, string url)
  66. {
  67. var content = new WebClient().DownloadString(url);
  68. RunTest(content);
  69. }
  70. [Theory]
  71. [InlineData("access-nsieve", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/access-nsieve.js")]
  72. public void AccessNSieve(string name, string url)
  73. {
  74. var content = new WebClient().DownloadString(url);
  75. RunTest(content);
  76. }
  77. [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")]
  78. public void Bitops3BitBitsInByte(string name, string url)
  79. {
  80. var content = new WebClient().DownloadString(url);
  81. RunTest(content);
  82. }
  83. [Theory]
  84. [InlineData("bitops-bits-in-byte", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/bitops-bits-in-byte.js")]
  85. public void BitopsBitsInByte(string name, string url)
  86. {
  87. var content = new WebClient().DownloadString(url);
  88. RunTest(content);
  89. }
  90. [Theory]
  91. [InlineData("bitops-bitwise-and", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/bitops-bitwise-and.js")]
  92. public void BitopsBitwiseAnd(string name, string url)
  93. {
  94. var content = new WebClient().DownloadString(url);
  95. RunTest(content);
  96. }
  97. [Theory]
  98. [InlineData("bitops-nsieve-bits", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/bitops-nsieve-bits.js")]
  99. public void BitopsNSieveBits(string name, string url)
  100. {
  101. var content = new WebClient().DownloadString(url);
  102. RunTest(content);
  103. }
  104. [Theory]
  105. [InlineData("controlflow-recursive", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/controlflow-recursive.js")]
  106. public void ControlFlowRecursive(string name, string url)
  107. {
  108. var t = new Thread(() =>
  109. {
  110. var content = new WebClient().DownloadString(url);
  111. RunTest(content);
  112. }, 1000000000);
  113. t.Start();
  114. t.Join();
  115. }
  116. [Theory]
  117. [InlineData("crypto-aes", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/crypto-aes.js")]
  118. public void CryptoAES(string name, string url)
  119. {
  120. var content = new WebClient().DownloadString(url);
  121. RunTest(content);
  122. }
  123. [Theory]
  124. [InlineData("crypto-md5", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/crypto-md5.js")]
  125. public void CryptoMD5(string name, string url)
  126. {
  127. var content = new WebClient().DownloadString(url);
  128. RunTest(content);
  129. }
  130. [InlineData("crypto-sha1", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/crypto-sha1.js")]
  131. public void CryptoSha1(string name, string url)
  132. {
  133. var content = new WebClient().DownloadString(url);
  134. RunTest(content);
  135. }
  136. [Theory]
  137. [InlineData("date-format-tofte", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/date-format-tofte.js")]
  138. public void DateFormatTofte(string name, string url)
  139. {
  140. var content = new WebClient().DownloadString(url);
  141. RunTest(content);
  142. }
  143. [Theory]
  144. [InlineData("date-format-xparb", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/date-format-xparb.js")]
  145. public void DateFormatXParb(string name, string url)
  146. {
  147. var content = new WebClient().DownloadString(url);
  148. RunTest(content);
  149. }
  150. [InlineData("math-cordic", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/math-cordic.js")]
  151. public void MathCordic(string name, string url)
  152. {
  153. var content = new WebClient().DownloadString(url);
  154. RunTest(content);
  155. }
  156. [Theory]
  157. [InlineData("math-partial-sums", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/math-partial-sums.js")]
  158. public void MathPartialSums(string name, string url)
  159. {
  160. var content = new WebClient().DownloadString(url);
  161. RunTest(content);
  162. }
  163. [Theory]
  164. [InlineData("math-spectral-norm", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/math-spectral-norm.js")]
  165. public void MathSpectralNorm(string name, string url)
  166. {
  167. var content = new WebClient().DownloadString(url);
  168. RunTest(content);
  169. }
  170. [Theory]
  171. [InlineData("regexp-dna", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/regexp-dna.js")]
  172. public void RegexpDna(string name, string url)
  173. {
  174. var content = new WebClient().DownloadString(url);
  175. RunTest(content);
  176. }
  177. [Theory]
  178. [InlineData("string-base64", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/string-base64.js")]
  179. public void StringBase64(string name, string url)
  180. {
  181. var content = new WebClient().DownloadString(url);
  182. RunTest(content);
  183. }
  184. [InlineData("string-fasta", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/string-fasta.js")]
  185. public void StringFasta(string name, string url)
  186. {
  187. var content = new WebClient().DownloadString(url);
  188. RunTest(content);
  189. }
  190. [Theory]
  191. [InlineData("string-tagcloud", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/string-tagcloud.js")]
  192. public void StringTagCloud(string name, string url)
  193. {
  194. var content = new WebClient().DownloadString(url);
  195. RunTest(content);
  196. }
  197. [Theory]
  198. [InlineData("string-unpack-code", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/string-unpack-code.js")]
  199. public void StringUnpackCode(string name, string url)
  200. {
  201. var content = new WebClient().DownloadString(url);
  202. RunTest(content);
  203. }
  204. [Theory]
  205. [InlineData("string-validate-input", "https://raw.github.com/WebKit/webkit/master/PerformanceTests/SunSpider/tests/sunspider-1.0.1/string-validate-input.js")]
  206. public void StringValidateInput(string name, string url)
  207. {
  208. var content = new WebClient().DownloadString(url);
  209. RunTest(content);
  210. }
  211. }
  212. }