Browse Source

Fixing unit tests for Math

Sebastien Ros 12 years ago
parent
commit
f3ebce98de

+ 4 - 2
Jint.Repl/Program.cs

@@ -8,8 +8,10 @@ namespace Jint.Repl
     {
     {
         static void Main(string[] args)
         static void Main(string[] args)
         {
         {
-            var engine = new Engine();
- 
+            var engine = new Engine(cfg => cfg
+                .WithDelegate("log", new Action<object>(Console.WriteLine))
+            );
+
             while (true)
             while (true)
             {
             {
                 Console.ForegroundColor = ConsoleColor.Green;
                 Console.ForegroundColor = ConsoleColor.Green;

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.1.1.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_1_1 : EcmaTest
     public class Test_15_8_1_1 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.1.2.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_1_2 : EcmaTest
     public class Test_15_8_1_2 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.1.3.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_1_3 : EcmaTest
     public class Test_15_8_1_3 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.1.4.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_1_4 : EcmaTest
     public class Test_15_8_1_4 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.1.5.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_1_5 : EcmaTest
     public class Test_15_8_1_5 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.1.6.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_1_6 : EcmaTest
     public class Test_15_8_1_6 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.1.7.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_1_7 : EcmaTest
     public class Test_15_8_1_7 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.1.8.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_1_8 : EcmaTest
     public class Test_15_8_1_8 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.1.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_1 : EcmaTest
     public class Test_15_8_2_1 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.10.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_10 : EcmaTest
     public class Test_15_8_2_10 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.11.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_11 : EcmaTest
     public class Test_15_8_2_11 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.12.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_12 : EcmaTest
     public class Test_15_8_2_12 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.13.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_13 : EcmaTest
     public class Test_15_8_2_13 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.14.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_14 : EcmaTest
     public class Test_15_8_2_14 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.15.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_15 : EcmaTest
     public class Test_15_8_2_15 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.16.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_16 : EcmaTest
     public class Test_15_8_2_16 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.17.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_17 : EcmaTest
     public class Test_15_8_2_17 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.18.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_18 : EcmaTest
     public class Test_15_8_2_18 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.2.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_2 : EcmaTest
     public class Test_15_8_2_2 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.3.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_3 : EcmaTest
     public class Test_15_8_2_3 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.4.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_4 : EcmaTest
     public class Test_15_8_2_4 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.5.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_5 : EcmaTest
     public class Test_15_8_2_5 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.6.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_6 : EcmaTest
     public class Test_15_8_2_6 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.7.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_7 : EcmaTest
     public class Test_15_8_2_7 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.8.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_8 : EcmaTest
     public class Test_15_8_2_8 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 1 - 0
Jint.Tests.Ecma/Ecma/15.8.2.9.cs

@@ -2,6 +2,7 @@ using Xunit;
 
 
 namespace Jint.Tests.Ecma
 namespace Jint.Tests.Ecma
 {
 {
+    [Trait("Category", "Pass")]
     public class Test_15_8_2_9 : EcmaTest
     public class Test_15_8_2_9 : EcmaTest
     {
     {
         [Fact]
         [Fact]

+ 300 - 7
Jint/Native/Math/MathInstance.cs

@@ -1,4 +1,5 @@
 using System;
 using System;
+using Jint.Native.Number;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Runtime;
 using Jint.Runtime;
 using Jint.Runtime.Interop;
 using Jint.Runtime.Interop;
@@ -41,9 +42,9 @@ namespace Jint.Native.Math
             FastAddProperty("exp", new ClrFunctionInstance<object, double>(Engine, Exp), true, false, true);
             FastAddProperty("exp", new ClrFunctionInstance<object, double>(Engine, Exp), true, false, true);
             FastAddProperty("floor", new ClrFunctionInstance<object, double>(Engine, Floor), true, false, true);
             FastAddProperty("floor", new ClrFunctionInstance<object, double>(Engine, Floor), true, false, true);
             FastAddProperty("log", new ClrFunctionInstance<object, double>(Engine, Log), true, false, true);
             FastAddProperty("log", new ClrFunctionInstance<object, double>(Engine, Log), true, false, true);
-            FastAddProperty("max", new ClrFunctionInstance<object, double>(Engine, Max), true, false, true);
-            FastAddProperty("min", new ClrFunctionInstance<object, double>(Engine, Min), true, false, true);
-            FastAddProperty("pow", new ClrFunctionInstance<object, double>(Engine, Pow), true, false, true);
+            FastAddProperty("max", new ClrFunctionInstance<object, double>(Engine, Max, 2), true, false, true);
+            FastAddProperty("min", new ClrFunctionInstance<object, double>(Engine, Min, 2), true, false, true);
+            FastAddProperty("pow", new ClrFunctionInstance<object, double>(Engine, Pow, 2), true, false, true);
             FastAddProperty("random", new ClrFunctionInstance<object, double>(Engine, Random), true, false, true);
             FastAddProperty("random", new ClrFunctionInstance<object, double>(Engine, Random), true, false, true);
             FastAddProperty("round", new ClrFunctionInstance<object, double>(Engine, Round), true, false, true);
             FastAddProperty("round", new ClrFunctionInstance<object, double>(Engine, Round), true, false, true);
             FastAddProperty("sin", new ClrFunctionInstance<object, double>(Engine, Sin), true, false, true);
             FastAddProperty("sin", new ClrFunctionInstance<object, double>(Engine, Sin), true, false, true);
@@ -87,9 +88,150 @@ namespace Jint.Native.Math
 
 
         private static double Atan2(object thisObject, object[] arguments)
         private static double Atan2(object thisObject, object[] arguments)
         {
         {
-            var x = TypeConverter.ToNumber(arguments[0]);
-            var y = TypeConverter.ToNumber(arguments[1]);
-            return System.Math.Atan2(x, y);
+            var y = TypeConverter.ToNumber(arguments[0]);
+            var x = TypeConverter.ToNumber(arguments[1]);
+
+            // If either x or y is NaN, the result is NaN.
+            if (double.IsNaN(x) || double.IsNaN(y))
+            {
+                return double.NaN;
+            }
+
+            if (y > 0 && x == 0)
+            {
+                return System.Math.PI/2;
+            }
+            
+            if (NumberInstance.IsPositiveZero(y))
+            {
+                // If y is +0 and x>0, the result is +0.
+                if (x > 0)
+                {
+                    return +0;
+                }
+
+                // If y is +0 and x is +0, the result is +0.
+                if (NumberInstance.IsPositiveZero(x))
+                {
+                    return +0;
+                }
+
+                // If y is +0 and x is −0, the result is an implementation-dependent approximation to +π.
+                if (NumberInstance.IsNegativeZero(x))
+                {
+                    return System.Math.PI;
+                }
+                
+                // If y is +0 and x<0, the result is an implementation-dependent approximation to +π.
+                if (x < 0)
+                {
+                    return System.Math.PI;
+                }
+            }
+
+            if (NumberInstance.IsNegativeZero(y))
+            {
+                // If y is −0 and x>0, the result is −0.
+                if (x > 0)
+                {
+                    return -0;
+                }
+
+                // If y is −0 and x is +0, the result is −0.
+                if (NumberInstance.IsPositiveZero(x))
+                {
+                    return -0;
+                }
+
+                // If y is −0 and x is −0, the result is an implementation-dependent approximation to −π.
+                if (NumberInstance.IsNegativeZero(x))
+                {
+                    return -System.Math.PI;
+                }
+
+                // If y is −0 and x<0, the result is an implementation-dependent approximation to −π.
+                if (x < 0)
+                {
+                    return -System.Math.PI;
+                }
+            }
+
+            // If y<0 and x is +0, the result is an implementation-dependent approximation to −π/2.
+            // If y<0 and x is −0, the result is an implementation-dependent approximation to −π/2.
+            if (y < 0 && x == 0)
+            {
+                return -System.Math.PI/2;
+            }
+
+            // If y>0 and y is finite and x is +∞, the result is +0.
+            if (y > 0 && !double.IsInfinity(y))
+            {
+                if (double.IsPositiveInfinity(x))
+                {
+                    return +0;
+                }
+
+                // If y>0 and y is finite and x is −∞, the result if an implementation-dependent approximation to +π.
+                if (double.IsNegativeInfinity(x))
+                {
+                    return System.Math.PI;
+                }
+            }
+
+
+            // If y<0 and y is finite and x is +∞, the result is −0.
+            // If y<0 and y is finite and x is −∞, the result is an implementation-dependent approximation to −π.
+            if (y < 0 && !double.IsInfinity(y))
+            {
+                if (double.IsPositiveInfinity(x))
+                {
+                    return -0;
+                }
+
+                // If y>0 and y is finite and x is −∞, the result if an implementation-dependent approximation to +π.
+                if (double.IsNegativeInfinity(x))
+                {
+                    return -System.Math.PI;
+                }
+            }
+            
+            // If y is +∞ and x is finite, the result is an implementation-dependent approximation to +π/2.
+            if (double.IsPositiveInfinity(y) && !double.IsInfinity(x))
+            {
+                return System.Math.PI/2;
+            }
+
+            // If y is −∞ and x is finite, the result is an implementation-dependent approximation to −π/2.
+            if (double.IsNegativeInfinity(y) && !double.IsInfinity(x))
+            {
+                return -System.Math.PI / 2;
+            }
+
+            // If y is +∞ and x is +∞, the result is an implementation-dependent approximation to +π/4.
+            if (double.IsPositiveInfinity(y) && double.IsPositiveInfinity(x))
+            {
+                return System.Math.PI/4;
+            }
+            
+            // If y is +∞ and x is −∞, the result is an implementation-dependent approximation to +3π/4.
+            if (double.IsPositiveInfinity(y) && double.IsNegativeInfinity(x))
+            {
+                return 3 * System.Math.PI / 4;
+            }
+            
+            // If y is −∞ and x is +∞, the result is an implementation-dependent approximation to −π/4.
+            if (double.IsNegativeInfinity(y) && double.IsPositiveInfinity(x))
+            {
+                return -System.Math.PI / 4;
+            }
+            
+            // If y is −∞ and x is −∞, the result is an implementation-dependent approximation to −3π/4.
+            if (double.IsNegativeInfinity(y) && double.IsNegativeInfinity(x))
+            {
+                return - 3 * System.Math.PI / 4;
+            }
+            
+            return System.Math.Atan2(y, x);
         }
         }
 
 
         private static double Ceil(object thisObject, object[] arguments)
         private static double Ceil(object thisObject, object[] arguments)
@@ -124,6 +266,11 @@ namespace Jint.Native.Math
 
 
         private static double Max(object thisObject, object[] arguments)
         private static double Max(object thisObject, object[] arguments)
         {
         {
+            if (arguments.Length == 0)
+            {
+                return Double.NegativeInfinity;
+            }
+
             double max = TypeConverter.ToNumber(arguments[0]);
             double max = TypeConverter.ToNumber(arguments[0]);
             for (int i = 0; i < arguments.Length; i++)
             for (int i = 0; i < arguments.Length; i++)
             {
             {
@@ -134,6 +281,11 @@ namespace Jint.Native.Math
 
 
         private static double Min(object thisObject, object[] arguments)
         private static double Min(object thisObject, object[] arguments)
         {
         {
+            if (arguments.Length == 0)
+            {
+                return Double.PositiveInfinity;
+            }
+            
             double min = TypeConverter.ToNumber(arguments[0]);
             double min = TypeConverter.ToNumber(arguments[0]);
             for (int i = 0; i < arguments.Length; i++)
             for (int i = 0; i < arguments.Length; i++)
             {
             {
@@ -146,6 +298,141 @@ namespace Jint.Native.Math
         {
         {
             var x = TypeConverter.ToNumber(arguments[0]);
             var x = TypeConverter.ToNumber(arguments[0]);
             var y = TypeConverter.ToNumber(arguments[1]);
             var y = TypeConverter.ToNumber(arguments[1]);
+
+            if (double.IsNaN(y))
+            {
+                return double.NaN;
+            }
+
+            if (y == 0)
+            {
+                return 1;
+            }
+
+            if (double.IsNaN(x) && y != 0)
+            {
+                return double.NaN;
+            }
+
+            if (System.Math.Abs(x) > 1)
+            {
+                if (double.IsPositiveInfinity(y))
+                {
+                    return double.PositiveInfinity;
+                }
+
+                if (double.IsNegativeInfinity(y))
+                {
+                    return +0;
+                }
+            }
+
+            if (System.Math.Abs(x) == 1)
+            {
+                if (double.IsInfinity(y))
+                {
+                    return double.NaN;
+                }
+            }
+
+            if (System.Math.Abs(x) < 1)
+            {
+                if (double.IsPositiveInfinity(y))
+                {
+                    return 0;
+                }
+
+                if (double.IsNegativeInfinity(y))
+                {
+                    return double.PositiveInfinity;
+                }
+            }
+
+            if (double.IsPositiveInfinity(x))
+            {
+                if (y > 0)
+                {
+                    return double.PositiveInfinity;
+                }
+
+                if (y < 0)
+                {
+                    return +0;
+                }
+            }
+
+            if (double.IsNegativeInfinity(x))
+            {
+                if (y > 0)
+                {
+                    if (System.Math.Abs(y % 2) == 1)
+                    {
+                        return double.NegativeInfinity;
+                    }
+
+                    return double.PositiveInfinity;
+                }
+
+                if (y < 0)
+                {
+                    if (System.Math.Abs(y % 2) == 1)
+                    {
+                        return -0;
+                    }
+
+                    return +0;
+                }
+            }
+
+            if (NumberInstance.IsPositiveZero(x))
+            {
+                // If x is +0 and y>0, the result is +0.
+                if (y > 0)
+                {
+                    return 0;
+                }
+
+                // If x is +0 and y<0, the result is +∞.
+                if (y < 0)
+                {
+                    return double.PositiveInfinity;
+                }
+            }
+
+
+            if (NumberInstance.IsNegativeZero(x))
+            {
+                if (y > 0)
+                {
+                    // If x is −0 and y>0 and y is an odd integer, the result is −0.
+                    if (System.Math.Abs(y % 2) == 1)
+                    {
+                        return -0;
+                    }
+
+                    // If x is −0 and y>0 and y is not an odd integer, the result is +0.
+                    return +0;
+                }
+
+                if (y < 0)
+                {
+                    // If x is −0 and y<0 and y is an odd integer, the result is −∞.
+                    if (System.Math.Abs(y % 2) == 1)
+                    {
+                        return double.NegativeInfinity;
+                    }
+
+                    // If x is −0 and y<0 and y is not an odd integer, the result is +∞.
+                    return double.PositiveInfinity;
+                }
+            }
+
+            // If x<0 and x is finite and y is finite and y is not an integer, the result is NaN.
+            if (x < 0 && !double.IsInfinity(x) && !double.IsInfinity(y) && (int) y != y)
+            {
+                return double.NaN;
+            }
+
             return System.Math.Pow(x, y);
             return System.Math.Pow(x, y);
         }
         }
 
 
@@ -157,7 +444,13 @@ namespace Jint.Native.Math
         private static double Round(object thisObject, object[] arguments)
         private static double Round(object thisObject, object[] arguments)
         {
         {
             var x = TypeConverter.ToNumber(arguments[0]);
             var x = TypeConverter.ToNumber(arguments[0]);
-            return System.Math.Round(x);
+            var round = System.Math.Round(x);
+            if (round == x - 0.5)
+            {
+                return round + 1;
+            }
+
+            return round;
         }
         }
 
 
         private static double Sin(object thisObject, object[] arguments)
         private static double Sin(object thisObject, object[] arguments)

+ 7 - 1
Jint/Native/Number/NumberInstance.cs

@@ -35,7 +35,13 @@ namespace Jint.Native.Number
 
 
         public static bool IsNegativeZero(double x)
         public static bool IsNegativeZero(double x)
         {
         {
-            return BitConverter.DoubleToInt64Bits(x) == NegativeZeroBits;
+            return x == 0 && BitConverter.DoubleToInt64Bits(x) == NegativeZeroBits;
         }
         }
+
+        public static bool IsPositiveZero(double x)
+        {
+            return x == 0 && BitConverter.DoubleToInt64Bits(x) != NegativeZeroBits;
+        }
+
     }
     }
 }
 }