From 4634f037354dbbb719604c4e70dd02a44559e9f9 Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Fri, 20 Dec 2019 07:20:36 +0100 Subject: [PATCH] fix: node.equals should allow null and undefined (#41143) --- types/rdf-js/index.d.ts | 10 +++++----- types/rdf-js/rdf-js-tests.ts | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/types/rdf-js/index.d.ts b/types/rdf-js/index.d.ts index 84091c5a73..6951c02b4f 100644 --- a/types/rdf-js/index.d.ts +++ b/types/rdf-js/index.d.ts @@ -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; } /** diff --git a/types/rdf-js/rdf-js-tests.ts b/types/rdf-js/rdf-js-tests.ts index f6cc1d7ca0..ea2428dcf8 100644 --- a/types/rdf-js/rdf-js-tests.ts +++ b/types/rdf-js/rdf-js-tests.ts @@ -14,29 +14,39 @@ function test_terms() { const namedNode: NamedNode = {}; 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 = {}; 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 = {}; 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 = {}; 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 = {}; 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() {