Cole-Greer commented on code in PR #2422:
URL: https://github.com/apache/tinkerpop/pull/2422#discussion_r1446432483


##########
gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/element-comparison-test.js:
##########
@@ -0,0 +1,261 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+const chai = require('chai')
+const { expect } = require('chai');
+const { VertexProperty, Property, Vertex, Edge, Path } = 
require('../../lib/structure/graph');
+const { deepMembersById, compareElements, opt } = 
require('../cucumber/element-comparison');
+const deepEqual = require('deep-eql');
+
+chai.use(function (chai, chaiUtils) {
+  chai.Assertion.overwriteMethod('members', function (_super) {
+    return deepMembersById;
+  });
+});
+
+describe('primitives', function () {
+    it('should pass', function () {
+        expect(deepEqual(1, 1, opt)).to.be.true;
+        expect(deepEqual(false, false, opt)).to.be.true;
+        expect(deepEqual(null, null, opt)).to.be.true;
+    });
+
+    it('should fail', function () {
+        expect(deepEqual(1, 2, opt)).to.be.false;
+        expect(deepEqual(true, false, opt)).to.be.false;
+        expect(deepEqual(0, "0", opt)).to.be.false;
+        expect(deepEqual(0, false, opt)).to.be.false;
+        expect(deepEqual(0, null, opt)).to.be.false;
+        expect(deepEqual(false, null, opt)).to.be.false;
+    });
+});
+
+describe('elements', function () {
+    const v1 = new Vertex(1, "dog", undefined);
+    const v2 = new Vertex(1, "cat", undefined);
+    const v3 = new Vertex(2, "cat", undefined);
+
+    const e1 = new Edge(2, v1, "chases", v3, undefined);
+    const e2 = new Edge(3, v1, "chases", v3, undefined);
+    const e3 = new Edge(3, v2, "chases", v3, undefined);
+
+    const vp1 = new VertexProperty(3, "size", "small", undefined);
+    const vp2 = new VertexProperty(3, "size", "large", undefined);
+    const vp3 = new VertexProperty(4, "size", "large", undefined);
+
+    it('should pass with same id, different values', function () {
+        expect(deepEqual(v1, v2, opt)).to.be.true;
+        expect(deepEqual(v3, e1, opt)).to.be.true;

Review Comment:
   This might be swinging the comparison from too strict to too loose. It might 
be better if the comparison is only true if both elements are the same type and 
have the same ID. I'm not sure when someone might end up with an edge and a 
vertex with the same ID but I don't think they should be considered equal.



##########
gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/element-comparison-test.js:
##########
@@ -0,0 +1,261 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+const chai = require('chai')
+const { expect } = require('chai');
+const { VertexProperty, Property, Vertex, Edge, Path } = 
require('../../lib/structure/graph');
+const { deepMembersById, compareElements, opt } = 
require('../cucumber/element-comparison');
+const deepEqual = require('deep-eql');
+
+chai.use(function (chai, chaiUtils) {
+  chai.Assertion.overwriteMethod('members', function (_super) {
+    return deepMembersById;
+  });
+});
+
+describe('primitives', function () {
+    it('should pass', function () {
+        expect(deepEqual(1, 1, opt)).to.be.true;
+        expect(deepEqual(false, false, opt)).to.be.true;
+        expect(deepEqual(null, null, opt)).to.be.true;
+    });
+
+    it('should fail', function () {
+        expect(deepEqual(1, 2, opt)).to.be.false;
+        expect(deepEqual(true, false, opt)).to.be.false;
+        expect(deepEqual(0, "0", opt)).to.be.false;
+        expect(deepEqual(0, false, opt)).to.be.false;
+        expect(deepEqual(0, null, opt)).to.be.false;
+        expect(deepEqual(false, null, opt)).to.be.false;
+    });
+});
+
+describe('elements', function () {
+    const v1 = new Vertex(1, "dog", undefined);
+    const v2 = new Vertex(1, "cat", undefined);
+    const v3 = new Vertex(2, "cat", undefined);
+
+    const e1 = new Edge(2, v1, "chases", v3, undefined);
+    const e2 = new Edge(3, v1, "chases", v3, undefined);
+    const e3 = new Edge(3, v2, "chases", v3, undefined);
+
+    const vp1 = new VertexProperty(3, "size", "small", undefined);
+    const vp2 = new VertexProperty(3, "size", "large", undefined);
+    const vp3 = new VertexProperty(4, "size", "large", undefined);
+
+    it('should pass with same id, different values', function () {
+        expect(deepEqual(v1, v2, opt)).to.be.true;
+        expect(deepEqual(v3, e1, opt)).to.be.true;
+        expect(deepEqual(e2, e3, opt)).to.be.true;
+        expect(deepEqual(e3, vp1, opt)).to.be.true;
+        expect(deepEqual(vp1, vp2, opt)).to.be.true;
+    });
+
+    it('should fail with different id, same values', function () {
+        expect(deepEqual(v2, v3, opt)).to.be.false;
+        expect(deepEqual(e1, e2, opt)).to.be.false;
+        expect(deepEqual(vp2, vp3, opt)).to.be.false;
+    });
+});
+
+describe('property', function () {
+    const p1 = new Property("a", "1");
+    const p2 = new Property("a", "1");
+    const p3 = new Property("a", 1);
+    const p4 = new Property(1, 1);
+    const p5 = new Property(1, "a");
+
+    it('should pass only properties that match exactly', function () {
+        expect(deepEqual(p1, p2, opt)).to.be.true;
+        expect(deepEqual(p1, p3, opt)).to.be.false;
+        expect(deepEqual(p1, p4, opt)).to.be.false;
+        expect(deepEqual(p3, p5, opt)).to.be.false;
+        expect(deepEqual(p3, p5, opt)).to.be.false;

Review Comment:
   Appears to be a duplicate test
   ```suggestion
   
   ```



-- 
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: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to