@@ -751,6 +751,112 @@ describe('GenericsContext', () => {
751751 ) ,
752752 ) . toBeUndefined ( ) ;
753753 } ) ;
754+
755+ it ( 'should return union of matches if left is a union type and right is not' , ( ) => {
756+ expectOutputProperties (
757+ genericsContext . mergeRanges (
758+ objectLoader . createCompactedResource ( {
759+ '@type' : 'ParameterRangeUnion' ,
760+ parameterRangeElements : [
761+ 'xsd:integer' ,
762+ 'xsd:boolean' ,
763+ 'xsd:integer' ,
764+ ] ,
765+ } ) ,
766+ objectLoader . createCompactedResource ( 'xsd:integer' ) ,
767+ ) ,
768+ objectLoader . createCompactedResource ( {
769+ '@type' : 'ParameterRangeUnion' ,
770+ parameterRangeElements : [
771+ 'xsd:integer' ,
772+ 'xsd:integer' ,
773+ ] ,
774+ } ) ,
775+ ) ;
776+ } ) ;
777+
778+ it ( 'should return union of matches for one match if left is a union type and right is not' , ( ) => {
779+ expect (
780+ genericsContext . mergeRanges (
781+ objectLoader . createCompactedResource ( {
782+ '@type' : 'ParameterRangeUnion' ,
783+ parameterRangeElements : [
784+ 'xsd:integer' ,
785+ 'xsd:boolean' ,
786+ 'xsd:boolean' ,
787+ ] ,
788+ } ) ,
789+ objectLoader . createCompactedResource ( 'xsd:integer' ) ,
790+ ) ! . term ,
791+ ) . toEqualRdfTerm ( objectLoader . createCompactedResource ( 'xsd:integer' ) ! . term ) ;
792+ } ) ;
793+
794+ it ( 'should not merge if union of matches of left does not match right' , ( ) => {
795+ expect ( genericsContext . mergeRanges (
796+ objectLoader . createCompactedResource ( {
797+ '@type' : 'ParameterRangeUnion' ,
798+ parameterRangeElements : [
799+ 'xsd:boolean' ,
800+ 'xsd:boolean' ,
801+ 'xsd:boolean' ,
802+ ] ,
803+ } ) ,
804+ objectLoader . createCompactedResource ( 'xsd:integer' ) ,
805+ ) ) . toBeUndefined ( ) ;
806+ } ) ;
807+
808+ it ( 'should return union of matches if right is a union type and left is not' , ( ) => {
809+ expectOutputProperties (
810+ genericsContext . mergeRanges (
811+ objectLoader . createCompactedResource ( 'xsd:integer' ) ,
812+ objectLoader . createCompactedResource ( {
813+ '@type' : 'ParameterRangeUnion' ,
814+ parameterRangeElements : [
815+ 'xsd:integer' ,
816+ 'xsd:boolean' ,
817+ 'xsd:integer' ,
818+ ] ,
819+ } ) ,
820+ ) ,
821+ objectLoader . createCompactedResource ( {
822+ '@type' : 'ParameterRangeUnion' ,
823+ parameterRangeElements : [
824+ 'xsd:integer' ,
825+ 'xsd:integer' ,
826+ ] ,
827+ } ) ,
828+ ) ;
829+ } ) ;
830+
831+ it ( 'should return union of matches for one match if right is a union type and left is not' , ( ) => {
832+ expect (
833+ genericsContext . mergeRanges (
834+ objectLoader . createCompactedResource ( 'xsd:integer' ) ,
835+ objectLoader . createCompactedResource ( {
836+ '@type' : 'ParameterRangeUnion' ,
837+ parameterRangeElements : [
838+ 'xsd:integer' ,
839+ 'xsd:boolean' ,
840+ 'xsd:boolean' ,
841+ ] ,
842+ } ) ,
843+ ) ! . term ,
844+ ) . toEqualRdfTerm ( objectLoader . createCompactedResource ( 'xsd:integer' ) ! . term ) ;
845+ } ) ;
846+
847+ it ( 'should not merge if union of matches of right does not match left' , ( ) => {
848+ expect ( genericsContext . mergeRanges (
849+ objectLoader . createCompactedResource ( 'xsd:integer' ) ,
850+ objectLoader . createCompactedResource ( {
851+ '@type' : 'ParameterRangeUnion' ,
852+ parameterRangeElements : [
853+ 'xsd:boolean' ,
854+ 'xsd:boolean' ,
855+ 'xsd:boolean' ,
856+ ] ,
857+ } ) ,
858+ ) ) . toBeUndefined ( ) ;
859+ } ) ;
754860 } ) ;
755861
756862 describe ( 'isXsdSubType' , ( ) => {
0 commit comments