diff --git a/app/assets/javascripts/hqmf_util.js.coffee b/app/assets/javascripts/hqmf_util.js.coffee index c7c3842..69f2fa0 100644 --- a/app/assets/javascripts/hqmf_util.js.coffee +++ b/app/assets/javascripts/hqmf_util.js.coffee @@ -300,7 +300,15 @@ class IVL_TS DURING: (other) -> this.SDU(other) && this.EDU(other) # Overlap: this overlaps with other - OVERLAP: (other) -> this.SDU(other) || this.EDU(other) || (this.SBS(other) && this.EAE(other)) + OVERLAP: (other) -> + if @high.date == null && other.high.date == null + true # If neither have ends, they inherently overlap on the timeline + else if @high.date == null + !this.SAE(other) + else if other.high.date == null + !this.EBS(other) + else + this.SDU(other) || this.EDU(other) || (this.SBS(other) && this.EAE(other)) # Concurrent: this low and high are the same as other low and high CONCURRENT: (other) -> this.SCW(other) && this.ECW(other) diff --git a/test/unit/library_function_test.rb b/test/unit/library_function_test.rb index b749ea8..c55fa2f 100644 --- a/test/unit/library_function_test.rb +++ b/test/unit/library_function_test.rb @@ -361,6 +361,10 @@ def test_temporal_operators @context.eval('var events1 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105"), new TS("20120105"));}}]') @context.eval('var events2 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120102"), new TS("20120105"));}}]') @context.eval('var events3 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105203030"), new TS("20120105203030"));}}]') + @context.eval('var nullEndEvent = new IVL_TS(new TS("20110101"), new TS("20120105"));') + @context.eval('nullEndEvent.high.date = null;') + @context.eval('var events4 = [{"asIVL_TS": function() {return nullEndEvent;}}]') + @context.eval('var events5 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20140101"), new TS("20140201"));}}]') @context.eval('var bound1 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105"), new TS("20120105"));}}]') @context.eval('var bound2 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120107"), new TS("20120107"));}}]') @context.eval('var bound3 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120103"), new TS("20120107"));}}]') @@ -368,8 +372,11 @@ def test_temporal_operators @context.eval('var bound5 = {"asIVL_TS": function() {return new IVL_TS(new TS("20120106"), new TS("20120107"));}}') @context.eval('var nullStartBound = new IVL_TS(new TS("20120105"), new TS("20120105"));') @context.eval('nullStartBound.low.date = null;') + @context.eval('var nullEndBound = new IVL_TS(new TS("20140601"), new TS("20140601"));') + @context.eval('nullEndBound.high.date = null;') @context.eval('var bound6 = {"asIVL_TS": function() {return nullStartBound;}}') @context.eval('var bound7 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105193030"), new TS("20120105193030"));}}]') + @context.eval('var bound8 = {"asIVL_TS": function() {return nullEndBound;}}') @context.eval('var range1 = new IVL_PQ(null, new PQ(1, "d"))') @context.eval('var range2 = new IVL_PQ(new PQ(1, "d"), null)') @context.eval('var range3 = new IVL_PQ(new PQ(0, "d"), null)') @@ -430,6 +437,9 @@ def test_temporal_operators assert_equal 0, @context.eval('OVERLAP(events2, XPRODUCT(bound6))').count assert_equal 1, @context.eval('OVERLAP(events2, XPRODUCT(bound1))').count assert_equal 0, @context.eval('OVERLAP(events2, XPRODUCT(bound2))').count + ## Overlap with null ending + assert_equal 1, @context.eval('OVERLAP(events4, bound1)').count + assert_equal 0, @context.eval('OVERLAP(events5, bound8)').count # SCW assert_equal 1, @context.eval('SCW(events1, bound1)').count