fix: node.equals should allow null and undefined (#41143)

This commit is contained in:
Tomasz Pluskiewicz
2019-12-19 22:20:35 -08:00
committed by Daniel Rosenwasser
parent 89e6ce1829
commit 4634f03735
2 changed files with 20 additions and 10 deletions
+5 -5
View File
@@ -40,7 +40,7 @@ export interface NamedNode {
* @param other The term to compare with.
* @return True if and only if other has termType "NamedNode" and the same `value`.
*/
equals(other: Term): boolean;
equals(other: Term | null | undefined): boolean;
}
/**
@@ -63,7 +63,7 @@ export interface BlankNode {
* @param other The term to compare with.
* @return True if and only if other has termType "BlankNode" and the same `value`.
*/
equals(other: Term): boolean;
equals(other: Term | null | undefined): boolean;
}
/**
@@ -94,7 +94,7 @@ export interface Literal {
* @return True if and only if other has termType "Literal"
* and the same `value`, `language`, and `datatype`.
*/
equals(other: Term): boolean;
equals(other: Term | null | undefined): boolean;
}
/**
@@ -114,7 +114,7 @@ export interface Variable {
* @param other The term to compare with.
* @return True if and only if other has termType "Variable" and the same `value`.
*/
equals(other: Term): boolean;
equals(other: Term | null | undefined): boolean;
}
/**
@@ -135,7 +135,7 @@ export interface DefaultGraph {
* @param other The term to compare with.
* @return True if and only if other has termType "DefaultGraph".
*/
equals(other: Term): boolean;
equals(other: Term | null | undefined): boolean;
}
/**
+15 -5
View File
@@ -14,29 +14,39 @@ function test_terms() {
const namedNode: NamedNode = <any> {};
const termType1: string = namedNode.termType;
const value1: string = namedNode.value;
namedNode.equals(someTerm);
let namedNodeEqual: boolean = namedNode.equals(someTerm);
namedNodeEqual = namedNode.equals(null);
namedNodeEqual = namedNode.equals(undefined);
const blankNode: BlankNode = <any> {};
const termType2: string = blankNode.termType;
const value2: string = blankNode.value;
blankNode.equals(someTerm);
let blankNodeEqual: boolean = blankNode.equals(someTerm);
blankNodeEqual = blankNode.equals(null);
blankNodeEqual = blankNode.equals(undefined);
const literal: Literal = <any> {};
const termType3: string = literal.termType;
const value3: string = literal.value;
const language3: string = literal.language;
const datatype3: NamedNode = literal.datatype;
literal.equals(someTerm);
let literalEqual: boolean = literal.equals(someTerm);
literalEqual = literal.equals(null);
literalEqual = literal.equals(undefined);
const variable: Variable = <any> {};
const termType4: string = variable.termType;
const value4: string = variable.value;
variable.equals(someTerm);
let variableEqual = variable.equals(someTerm);
variableEqual = variable.equals(null);
variableEqual = variable.equals(undefined);
const defaultGraph: DefaultGraph = <any> {};
const termType5: string = defaultGraph.termType;
const value5: string = defaultGraph.value;
defaultGraph.equals(someTerm);
let defaultGraphEqual: boolean = defaultGraph.equals(someTerm);
defaultGraphEqual = defaultGraph.equals(null);
defaultGraphEqual = defaultGraph.equals(undefined);
}
function test_quads() {