Skip to content

Commit 6025a3b

Browse files
committed
Add a few more tests
1 parent a2b8277 commit 6025a3b

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

test/datatypes/interval-test.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,24 +1950,53 @@ describe('DateTimeInterval', () => {
19501950
should(() => ivl.pointFrom()).throw(Error);
19511951
});
19521952

1953+
it('should return the point value for a unit interval with open low bound', () => {
1954+
const point = DateTime.parse('2012-01-01T00:00:00.0+00');
1955+
const ivl = new Interval(point.predecessor(), point, false, true);
1956+
1957+
ivl.pointFrom().should.eql(point);
1958+
});
1959+
19531960
it('should return the point value for a unit interval with open high bound', () => {
19541961
const point = DateTime.parse('2012-01-01T00:00:00.0+00');
19551962
const ivl = new Interval(point, point.successor(), true, false);
19561963

19571964
ivl.pointFrom().should.eql(point);
19581965
});
19591966

1967+
it('should throw for a non-unit interval with closed high bound', () => {
1968+
const point = DateTime.parse('2012-01-01T00:00:00.0+00');
1969+
const ivl = new Interval(point, point.successor(), true, true);
1970+
1971+
should(() => ivl.pointFrom()).throw(Error);
1972+
});
1973+
19601974
it('should return the point value for a unit interval with limited precision', () => {
19611975
const point = DateTime.parse('2012-01-01');
19621976
const ivl = new Interval(point, point);
19631977

19641978
ivl.pointFrom().should.eql(point);
19651979
});
19661980

1967-
it('should throw for an interval with null high bound', function () {
1981+
it('should throw for an interval with closed null high bound', function () {
19681982
const ivl = new Interval(DateTime.parse('2012-01-01T00:00:00.0+00'), null);
19691983
should(() => ivl.pointFrom()).throw(Error);
19701984
});
1985+
1986+
it('should throw for an interval with open null high bound', function () {
1987+
const ivl = new Interval(DateTime.parse('2012-01-01T00:00:00.0+00'), null, true, false);
1988+
should(() => ivl.pointFrom()).throw(Error);
1989+
});
1990+
1991+
it('should throw for an interval with closed null low bound', function () {
1992+
const ivl = new Interval(null, DateTime.parse('2012-01-01T00:00:00.0+00'));
1993+
should(() => ivl.pointFrom()).throw(Error);
1994+
});
1995+
1996+
it('should throw for an interval with open null low bound', function () {
1997+
const ivl = new Interval(null, DateTime.parse('2012-01-01T00:00:00.0+00'), false, true);
1998+
should(() => ivl.pointFrom()).throw(Error);
1999+
});
19712000
});
19722001
});
19732002

0 commit comments

Comments
 (0)