mikepersonick commented on a change in pull request #1553:
URL: https://github.com/apache/tinkerpop/pull/1553#discussion_r790775363
##########
File path:
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/CompareTest.java
##########
@@ -95,7 +87,96 @@
{Compare.gte, new B(), new C(), true},
{Compare.lte, new B(), new D(), true},
{Compare.lte, new C(), new C(), true},
- {Compare.lte, new D(), new D(), true}
+ {Compare.lte, new D(), new D(), true},
+
+ // type promotion
+ {Compare.eq, 1, 1.0d, true},
+ {Compare.neq, 1, 1.0d, false},
+ {Compare.lt, 1, 1.0d, false},
+ {Compare.lte, 1, 1.0d, true},
+ {Compare.gt, 1, 1.0d, false},
+ {Compare.gte, 1, 1.0d, true},
+
+ // Incomparable types produce ERROR
+ {Compare.gt, 23, "23", GremlinTypeErrorException.class},
+ {Compare.gte, 23, "23", GremlinTypeErrorException.class},
+ {Compare.lt, 23, "23", GremlinTypeErrorException.class},
+ {Compare.lte, 23, "23", GremlinTypeErrorException.class},
+ {Compare.lte, new CompareTest.A(), new CompareTest.B(),
GremlinTypeErrorException.class},
+ {Compare.lte, new CompareTest.B(), new CompareTest.A(),
GremlinTypeErrorException.class},
+ {Compare.lte, new CompareTest.C(), new CompareTest.D(),
GremlinTypeErrorException.class},
+ {Compare.gte, new Object(), new Object(),
GremlinTypeErrorException.class},
+ {Compare.gte, new Object(), new Object(),
GremlinTypeErrorException.class},
+ {Compare.gte, new Object(), new Object(),
GremlinTypeErrorException.class},
+
+ /*
+ * NaN has pretty much the same comparability behavior against
any argument (including itself):
+ * P.eq(NaN, any) = FALSE
+ * P.neq(NaN, any) = TRUE
+ * P.lt/lte/gt/gte(NaN, any) = ERROR -> FALSE
+ */
+ {Compare.eq, NaN, NaN, false},
+ {Compare.neq, NaN, NaN, true},
+ {Compare.gt, NaN, NaN, GremlinTypeErrorException.class},
+ {Compare.gte, NaN, NaN, GremlinTypeErrorException.class},
+ {Compare.lt, NaN, NaN, GremlinTypeErrorException.class},
+ {Compare.lte, NaN, NaN, GremlinTypeErrorException.class},
+
+ {Compare.eq, NaN, 0, false},
+ {Compare.neq, NaN, 0, true},
+ {Compare.gt, NaN, 0, GremlinTypeErrorException.class},
+ {Compare.gte, NaN, 0, GremlinTypeErrorException.class},
+ {Compare.lt, NaN, 0, GremlinTypeErrorException.class},
+ {Compare.lte, NaN, 0, GremlinTypeErrorException.class},
+
+ {Compare.eq, NaN, "foo", false},
+ {Compare.neq, NaN, "foo", true},
+ {Compare.gt, NaN, "foo", GremlinTypeErrorException.class},
+ {Compare.gte, NaN, "foo", GremlinTypeErrorException.class},
+ {Compare.lt, NaN, "foo", GremlinTypeErrorException.class},
+ {Compare.lte, NaN, "foo", GremlinTypeErrorException.class},
+
+ /*
+ * We consider null to be in its own type space, and thus not
comparable (lt/lte/gt/gte) with
+ * anything other than null:
+ *
+ * P.eq(null, any non-null) = FALSE
+ * P.neq(null, any non-null) = TRUE
+ * P.lt/lte/gt/gte(null, any non-null) = ERROR -> FALSE
+ */
+ {Compare.eq, null, null, true},
+ {Compare.neq, null, null, false},
+ {Compare.gt, null, null, false},
+ {Compare.gte, null, null, true},
+ {Compare.lt, null, null, false},
+ {Compare.lte, null, null, true},
+
+ {Compare.eq, "foo", null, false},
+ {Compare.neq, "foo", null, true},
+ {Compare.gt, "foo", null, GremlinTypeErrorException.class},
+ {Compare.gte, "foo", null, GremlinTypeErrorException.class},
+ {Compare.lt, "foo", null, GremlinTypeErrorException.class},
+ {Compare.lte, "foo", null, GremlinTypeErrorException.class},
+
+ {Compare.eq, null, 1, false},
+ {Compare.eq, 1, null, false},
+ {Compare.neq, null, 1, true},
+ {Compare.neq, 1, null, true},
+ {Compare.gt, null, 1, GremlinTypeErrorException.class},
+ {Compare.gt, 1, null, GremlinTypeErrorException.class},
+ {Compare.gte, null, 1, GremlinTypeErrorException.class},
+ {Compare.gte, 1, null, GremlinTypeErrorException.class},
+ {Compare.lt, null, 1, GremlinTypeErrorException.class},
+ {Compare.lt, 1, null, GremlinTypeErrorException.class},
+ {Compare.lte, null, 1, GremlinTypeErrorException.class},
+ {Compare.lte, 1, null, GremlinTypeErrorException.class},
+
+ {Compare.eq, NaN, null, false},
+ {Compare.neq, NaN, null, true},
+ {Compare.gt, NaN, null, GremlinTypeErrorException.class},
+ {Compare.gte, NaN, null, GremlinTypeErrorException.class},
+ {Compare.lt, NaN, null, GremlinTypeErrorException.class},
+ {Compare.lte, NaN, null, GremlinTypeErrorException.class},
}));
Review comment:
p.not is tested in the Xor connective test below, but I will be adding
significant additional test coverage so I will add some more not testing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]