You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2021/10/11 18:07:15 UTC

[tinkerpop] 03/05: TINKERPOP-2615 Added null tests around cyclic/simplePath CTR

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 724dbbfff08a0e828ece87207d96c20344e4734f
Author: Stephen Mallette <st...@amazon.com>
AuthorDate: Mon Oct 11 13:30:24 2021 -0400

    TINKERPOP-2615 Added null tests around cyclic/simplePath CTR
---
 .../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs |  2 ++
 .../gremlin-javascript/test/cucumber/gremlin.js    |  5 ++++-
 gremlin-python/src/main/python/radish/gremlin.py   |  2 ++
 gremlin-test/features/filter/CyclicPath.feature    | 22 ++++++++++++++++++++++
 gremlin-test/features/filter/SimplePath.feature    | 16 ++++++++++++++++
 5 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
index d618e44..ae83922 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
@@ -131,6 +131,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
                {"g_VX1X_outXcreatedX_inXcreatedX_cyclicPath", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Out("created").In("created").CyclicPath()}}, 
                {"g_VX1X_outXcreatedX_inXcreatedX_cyclicPath_path", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Out("created").In("created").CyclicPath().Path()}}, 
                {"g_VX1X_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_cyclicPath_fromXaX_toXbX_path", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).As("a").Out("created").As("b").In("created").As("c").CyclicPath().From("a").To("b").Path()}}, 
+               {"g_injectX0X_V_both_coalesceXhasXname_markoX_both_constantX0XX_cyclicPath_path", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject(0).V().Both().Coalesce<object>(__.Has("name","marko").Both(),__.Constant<object>(0)).CyclicPath().Path()}}, 
                {"g_V_out_in_valuesXnameX_fold_dedupXlocalX_unfold", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Out().In().Values<object>("name").Fold().Dedup(Scope.Local).Unfold<object>()}}, 
                {"g_V_out_asXxX_in_asXyX_selectXx_yX_byXnameX_fold_dedupXlocal_x_yX_unfold", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Out().As("x").In().As("y").Select<object>("x","y").By("name").Fold().Dedup(Scope.Local,"x","y").Unfold<object>()}}, 
                {"g_V_both_dedup_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Both().Dedup().Values<object>("name")}}, 
@@ -281,6 +282,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
                {"g_VX1X_outXcreatedX_inXcreatedX_simplePath", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Out("created").In("created").SimplePath()}}, 
                {"g_V_repeatXboth_simplePathX_timesX3X_path", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Repeat(__.Both().SimplePath()).Times(3).Path()}}, 
                {"g_V_asXaX_out_asXbX_out_asXcX_simplePath_byXlabelX_fromXbX_toXcX_path_byXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().As("a").Out().As("b").Out().As("c").SimplePath().By(T.Label).From("b").To("c").Path().By("name")}}, 
+               {"g_injectX0X_V_both_coalesceXhasXname_markoX_both_constantX0XX_simplePath_path", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject(0).V().Both().Coalesce<object>(__.Has("name","marko").Both(),__.Constant<object>(0)).SimplePath().Path()}}, 
                {"g_V_valuesXnameX_order_tailXglobal_2X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("name").Order().Tail<object>(Scope.Global,2)}}, 
                {"g_V_valuesXnameX_order_tailX2X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("name").Order().Tail<object>(2)}}, 
                {"g_V_valuesXnameX_order_tail", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("name").Order().Tail<object>()}}, 
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
index 1031f8a..3a20541 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
@@ -120,6 +120,7 @@ const gremlins = {
     g_VX1X_outXcreatedX_inXcreatedX_cyclicPath: [function({g, vid1}) { return g.V(vid1).out("created").in_("created").cyclicPath() }], 
     g_VX1X_outXcreatedX_inXcreatedX_cyclicPath_path: [function({g, vid1}) { return g.V(vid1).out("created").in_("created").cyclicPath().path() }], 
     g_VX1X_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_cyclicPath_fromXaX_toXbX_path: [function({g, vid1}) { return g.V(vid1).as("a").out("created").as("b").in_("created").as("c").cyclicPath().from_("a").to("b").path() }], 
+    g_injectX0X_V_both_coalesceXhasXname_markoX_both_constantX0XX_cyclicPath_path: [function({g}) { return g.inject(0).V().both().coalesce(__.has("name","marko").both(),__.constant(0)).cyclicPath().path() }], 
     g_V_out_in_valuesXnameX_fold_dedupXlocalX_unfold: [function({g}) { return g.V().out().in_().values("name").fold().dedup(Scope.local).unfold() }], 
     g_V_out_asXxX_in_asXyX_selectXx_yX_byXnameX_fold_dedupXlocal_x_yX_unfold: [function({g}) { return g.V().out().as("x").in_().as("y").select("x","y").by("name").fold().dedup(Scope.local,"x","y").unfold() }], 
     g_V_both_dedup_name: [function({g}) { return g.V().both().dedup().values("name") }], 
@@ -270,6 +271,7 @@ const gremlins = {
     g_VX1X_outXcreatedX_inXcreatedX_simplePath: [function({g, vid1}) { return g.V(vid1).out("created").in_("created").simplePath() }], 
     g_V_repeatXboth_simplePathX_timesX3X_path: [function({g}) { return g.V().repeat(__.both().simplePath()).times(3).path() }], 
     g_V_asXaX_out_asXbX_out_asXcX_simplePath_byXlabelX_fromXbX_toXcX_path_byXnameX: [function({g}) { return g.V().as("a").out().as("b").out().as("c").simplePath().by(T.label).from_("b").to("c").path().by("name") }], 
+    g_injectX0X_V_both_coalesceXhasXname_markoX_both_constantX0XX_simplePath_path: [function({g}) { return g.inject(0).V().both().coalesce(__.has("name","marko").both(),__.constant(0)).simplePath().path() }], 
     g_V_valuesXnameX_order_tailXglobal_2X: [function({g}) { return g.V().values("name").order().tail(Scope.global,2) }], 
     g_V_valuesXnameX_order_tailX2X: [function({g}) { return g.V().values("name").order().tail(2) }], 
     g_V_valuesXnameX_order_tail: [function({g}) { return g.V().values("name").order().tail() }], 
@@ -359,9 +361,10 @@ const gremlins = {
     g_V_repeatXoutX_timesX8X_count: [function({g}) { return g.V().repeat(__.out()).times(8).count() }], 
     g_V_repeatXoutX_timesX5X_asXaX_outXwrittenByX_asXbX_selectXa_bX_count: [function({g}) { return g.V().repeat(__.out()).times(5).as("a").out("writtenBy").as("b").select("a","b").count() }], 
     g_V_repeatXoutX_timesX3X_count: [function({g}) { return g.V().repeat(__.out()).times(3).count() }], 
-    g_V_elementMap: [function({g}) { return g.V().elementMap() }, function({g}) { return g.V().elementMap("name","age",null) }], 
+    g_V_elementMap: [function({g}) { return g.V().elementMap() }], 
     g_V_elementMapXname_ageX: [function({g}) { return g.V().elementMap("name","age") }], 
     g_EX11X_elementMap: [function({g, eid11}) { return g.E(eid11).elementMap() }], 
+    g_V_elementMapXname_age_nullX: [function({g}) { return g.V().elementMap("name","age",null) }], 
     g_V_asXaX_flatMapXselectXaXX: [function({g}) { return g.V().as("a").flatMap(__.select("a")) }], 
     g_V_fold: [function({g}) { return g.V().fold() }], 
     g_V_fold_unfold: [function({g}) { return g.V().fold().unfold() }], 
diff --git a/gremlin-python/src/main/python/radish/gremlin.py b/gremlin-python/src/main/python/radish/gremlin.py
index ff493aa..5372cb8 100644
--- a/gremlin-python/src/main/python/radish/gremlin.py
+++ b/gremlin-python/src/main/python/radish/gremlin.py
@@ -105,6 +105,7 @@ world.gremlins = {
     'g_VX1X_outXcreatedX_inXcreatedX_cyclicPath': [(lambda g, vid1=None:g.V(vid1).out('created').in_('created').cyclicPath())], 
     'g_VX1X_outXcreatedX_inXcreatedX_cyclicPath_path': [(lambda g, vid1=None:g.V(vid1).out('created').in_('created').cyclicPath().path())], 
     'g_VX1X_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_cyclicPath_fromXaX_toXbX_path': [(lambda g, vid1=None:g.V(vid1).as_('a').out('created').as_('b').in_('created').as_('c').cyclicPath().from_('a').to('b').path())], 
+    'g_injectX0X_V_both_coalesceXhasXname_markoX_both_constantX0XX_cyclicPath_path': [(lambda g:g.inject(0).V().both().coalesce(__.has('name','marko').both(),__.constant(0)).cyclicPath().path())], 
     'g_V_out_in_valuesXnameX_fold_dedupXlocalX_unfold': [(lambda g:g.V().out().in_().name.fold().dedup(Scope.local).unfold())], 
     'g_V_out_asXxX_in_asXyX_selectXx_yX_byXnameX_fold_dedupXlocal_x_yX_unfold': [(lambda g:g.V().out().as_('x').in_().as_('y').select('x','y').by('name').fold().dedup(Scope.local,'x','y').unfold())], 
     'g_V_both_dedup_name': [(lambda g:g.V().both().dedup().name)], 
@@ -255,6 +256,7 @@ world.gremlins = {
     'g_VX1X_outXcreatedX_inXcreatedX_simplePath': [(lambda g, vid1=None:g.V(vid1).out('created').in_('created').simplePath())], 
     'g_V_repeatXboth_simplePathX_timesX3X_path': [(lambda g:g.V().repeat(__.both().simplePath()).times(3).path())], 
     'g_V_asXaX_out_asXbX_out_asXcX_simplePath_byXlabelX_fromXbX_toXcX_path_byXnameX': [(lambda g:g.V().as_('a').out().as_('b').out().as_('c').simplePath().by(T.label).from_('b').to('c').path().by('name'))], 
+    'g_injectX0X_V_both_coalesceXhasXname_markoX_both_constantX0XX_simplePath_path': [(lambda g:g.inject(0).V().both().coalesce(__.has('name','marko').both(),__.constant(0)).simplePath().path())], 
     'g_V_valuesXnameX_order_tailXglobal_2X': [(lambda g:g.V().name.order().tail(Scope.global_,2))], 
     'g_V_valuesXnameX_order_tailX2X': [(lambda g:g.V().name.order().tail(2))], 
     'g_V_valuesXnameX_order_tail': [(lambda g:g.V().name.order().tail())], 
diff --git a/gremlin-test/features/filter/CyclicPath.feature b/gremlin-test/features/filter/CyclicPath.feature
index b49bf3b..497f3b5 100644
--- a/gremlin-test/features/filter/CyclicPath.feature
+++ b/gremlin-test/features/filter/CyclicPath.feature
@@ -50,3 +50,25 @@ Feature: Step - cyclicPath()
       """
     When iterated to list
     Then the result should be empty
+
+  Scenario: g_injectX0X_V_both_coalesceXhasXname_markoX_both_constantX0XX_cyclicPath_path
+    Given the modern graph
+    And the traversal of
+      """
+      g.inject(0).V().both().coalesce(has('name','marko').both(),constant(0)).cyclicPath().path()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | result |
+      | p[d[0].i,v[marko],v[lop],d[0].i] |
+      | p[d[0].i,v[marko],v[vadas],d[0].i] |
+      | p[d[0].i,v[marko],v[josh],d[0].i] |
+      | p[d[0].i,v[vadas],v[marko],v[vadas]] |
+      | p[d[0].i,v[lop],v[marko],v[lop]] |
+      | p[d[0].i,v[lop],v[josh],d[0].i] |
+      | p[d[0].i,v[lop],v[peter],d[0].i] |
+      | p[d[0].i,v[josh],v[ripple],d[0].i] |
+      | p[d[0].i,v[josh],v[lop],d[0].i] |
+      | p[d[0].i,v[josh],v[marko],v[josh]] |
+      | p[d[0].i,v[ripple],v[josh],d[0].i] |
+      | p[d[0].i,v[peter],v[lop],d[0].i] |
\ No newline at end of file
diff --git a/gremlin-test/features/filter/SimplePath.feature b/gremlin-test/features/filter/SimplePath.feature
index 97a1b9b..244637b 100644
--- a/gremlin-test/features/filter/SimplePath.feature
+++ b/gremlin-test/features/filter/SimplePath.feature
@@ -69,3 +69,19 @@ Feature: Step - simplePath()
       | result |
       | p[marko,josh,ripple] |
       | p[marko,josh,lop]    |
+
+  Scenario: g_injectX0X_V_both_coalesceXhasXname_markoX_both_constantX0XX_simplePath_path
+    Given the modern graph
+    And the traversal of
+      """
+      g.inject(0).V().both().coalesce(has('name','marko').both(),constant(0)).simplePath().path()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | result |
+      | p[d[0].i,v[vadas],v[marko],v[lop]] |
+      | p[d[0].i,v[vadas],v[marko],v[josh]] |
+      | p[d[0].i,v[lop],v[marko],v[vadas]] |
+      | p[d[0].i,v[lop],v[marko],v[josh]] |
+      | p[d[0].i,v[josh],v[marko],v[lop]] |
+      | p[d[0].i,v[josh],v[marko],v[vadas]] |