Skip to content

Commit

Permalink
Fix Quad.equals not checking terms
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Aug 31, 2020
1 parent d7b05c5 commit b295f8e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Quad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export class Quad implements RDF.BaseQuad {
}

public equals(other: RDF.Term | null | undefined): boolean {
return !!other && other.termType === 'Quad';
return !!other && other.termType === 'Quad' &&
this.subject.equals(other.subject) &&
this.predicate.equals(other.predicate) &&
this.object.equals(other.object) &&
this.graph.equals(other.graph);
}
}
28 changes: 28 additions & 0 deletions test/DataFactory-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,34 @@ describe('DataFactory', () => {
factory.namedNode('ex:o'),
factory.namedNode('ex:g'),
))).toEqual(true);

expect(term.equals(factory.quad(
factory.namedNode('ex:s-'),
factory.namedNode('ex:p'),
factory.namedNode('ex:o'),
factory.namedNode('ex:g'),
))).toEqual(false);

expect(term.equals(factory.quad(
factory.namedNode('ex:s'),
factory.namedNode('ex:p-'),
factory.namedNode('ex:o'),
factory.namedNode('ex:g'),
))).toEqual(false);

expect(term.equals(factory.quad(
factory.namedNode('ex:s'),
factory.namedNode('ex:p'),
factory.namedNode('ex:o-'),
factory.namedNode('ex:g'),
))).toEqual(false);

expect(term.equals(factory.quad(
factory.namedNode('ex:s'),
factory.namedNode('ex:p'),
factory.namedNode('ex:o'),
factory.namedNode('ex:g-'),
))).toEqual(false);
});

it('should handle equals for a nested quad', () => {
Expand Down

0 comments on commit b295f8e

Please sign in to comment.