You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by jo...@apache.org on 2018/09/12 09:18:13 UTC

tinkerpop git commit: TINKERPOP-1972 Fix test harness, extract child type in generic params array

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1972 [created] 2a2e47ebd


TINKERPOP-1972 Fix test harness, extract child type in generic params array


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2a2e47eb
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2a2e47eb
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2a2e47eb

Branch: refs/heads/TINKERPOP-1972
Commit: 2a2e47ebdb5342c30ebee2e9a0cca138e07fc58c
Parents: c029eef
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Sep 12 11:17:54 2018 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Sep 12 11:17:54 2018 +0200

----------------------------------------------------------------------
 .../Gherkin/GherkinTestRunner.cs                |  6 +++---
 .../TraversalEvaluation/TraversalParser.cs      | 21 ++++++++++++++++++--
 2 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2a2e47eb/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
index 3802da5..27bbc42 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
@@ -38,10 +38,10 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
     public class GherkinTestRunner
     {
         private static readonly IDictionary<string, IgnoreReason> IgnoredScenarios =
-            new Dictionary<string, IgnoreReason>()
+            new Dictionary<string, IgnoreReason>
             {
-                { "g_injectX1X_chooseXisX1X__constantX10Xfold__foldX", IgnoreReason.NoReason },
-                { "g_injectX2X_chooseXisX1X__constantX10Xfold__foldX", IgnoreReason.NoReason }
+                // Add here the name of scenarios to ignore and the reason, e.g.
+                // { "g_injectX2X_chooseXisX1X__constantX10Xfold__foldX", IgnoreReason.NoReason }
             };
         
         private static class Keywords

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2a2e47eb/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
index e3f6a3f..419ce8d 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -245,6 +245,14 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
                         // if we have the type of value we have the type of E2. 
                         genericParameterTypes.Add(info.ParameterType.Name, tokenParameter.GetParameterType());
                     }
+                    else if (IsParamsArray(info) && info.ParameterType.GetElementType().IsGenericParameter)
+                    {
+                        // Its a method where the type parameter comes from an params Array
+                        // e.g., Inject<S>(params S[] value)
+                        genericParameterTypes.Add(info.ParameterType.GetElementType().Name,
+                            tokenParameter.GetParameterType());
+                    }
+
                     if (info.ParameterType != tokenParameter.GetParameterType() && IsNumeric(info.ParameterType) &&
                         IsNumeric(tokenParameter.GetParameterType()))
                     {
@@ -252,6 +260,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
                         value = Convert.ChangeType(value, info.ParameterType);
                     }
                 }
+
                 if (IsParamsArray(info))
                 {
                     // For `params type[] value` we should provide an empty array
@@ -264,11 +273,19 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
                     {
                         // An array with the parameter values
                         // No more method parameters after this one
-                        var arr = Array.CreateInstance(info.ParameterType.GetElementType(), token.Parameters.Count - i);
+                        var elementType = info.ParameterType.GetElementType();
+
+                        if (elementType.IsGenericParameter)
+                        {
+                            // The Array element type is generic, so we use type of the value to specify it
+                            elementType = value.GetType();
+                        }
+
+                        var arr = Array.CreateInstance(elementType, token.Parameters.Count - i);
                         arr.SetValue(value, 0);
                         for (var j = 1; j < token.Parameters.Count - i; j++)
                         {
-                            arr.SetValue(token.Parameters[i + j].GetValue(), j);   
+                            arr.SetValue(token.Parameters[i + j].GetValue(), j);
                         }
                         value = arr;
                     }