Browse Source

Merge pull request #261 from qnnnnez/master

add unit test for https://github.com/sebastienros/jint/pull/250
Sébastien Ros 9 years ago
parent
commit
75cce95e95
2 changed files with 30 additions and 0 deletions
  1. 10 0
      Jint.Tests/Runtime/Domain/A.cs
  2. 20 0
      Jint.Tests/Runtime/InteropTests.cs

+ 10 - 0
Jint.Tests/Runtime/Domain/A.cs

@@ -94,5 +94,15 @@ namespace Jint.Tests.Runtime.Domain
         {
         {
             return String.Join(",", values);
             return String.Join(",", values);
         }
         }
+
+        public int Call17(Func<int, int> callback)
+        {
+            return callback(17);
+        }
+
+        public void Call18(Action<int> callback)
+        {
+            callback(18);
+        }
     }
     }
 }
 }

+ 20 - 0
Jint.Tests/Runtime/InteropTests.cs

@@ -1358,5 +1358,25 @@ namespace Jint.Tests.Runtime
             Assert.Equal(Nested.ClassWithStaticFields.Readonly, "Readonly");
             Assert.Equal(Nested.ClassWithStaticFields.Readonly, "Readonly");
         }
         }
 
 
+        [Fact]
+        public void ShouldExecuteFunctionWithValueTypeParameterCorrectly()
+        {
+            _engine.SetValue("a", new A());
+            // Func<int, int>
+            RunTest(@"
+                assert(a.Call17(function(value){ return value; }) === 17);
+            ");
+        }
+
+        [Fact]
+        public void ShouldExecuteActionWithValueTypeParameterCorrectly()
+        {
+            _engine.SetValue("a", new A());
+            // Action<int>
+            RunTest(@"
+                a.Call18(function(value){ assert(value === 18); });
+            ");
+        }
+
     }
     }
 }
 }