Skip to content

Commit 64c60ab

Browse files
committed
two empties make an empty
1 parent 3d1bf69 commit 64c60ab

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/types/make-maybe-test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,19 @@ QUnit.test("difference", function() {
183183
);
184184
QUnit.deepEqual(res, gt3, "secondary and primary");
185185

186+
res = set.difference(
187+
new MaybeDateStringSet({
188+
range: new is.In([3]),
189+
enum: set.EMPTY
190+
}),
191+
new MaybeDateStringSet({
192+
range: new is.In([3]),
193+
enum: set.EMPTY
194+
})
195+
);
196+
197+
QUnit.equal(res, set.EMPTY, "equal is empty");
198+
186199
});
187200

188201
QUnit.test("difference with ComparisonSet", function() {
@@ -304,7 +317,23 @@ QUnit.test("union", function() {
304317
});
305318

306319

320+
QUnit.test("isSubset", function() {
321+
var res;
307322

323+
res = set.isSubset(
324+
new MaybeDateStringSet({
325+
range: new is.In([3]),
326+
enum: set.EMPTY
327+
}),
328+
new MaybeDateStringSet({
329+
range: new is.In([3]),
330+
enum: set.EMPTY
331+
})
332+
);
333+
334+
QUnit.ok(res, "is a subset");
335+
336+
});
308337

309338
QUnit.test("can make maybe type from normal type and makeMaybeSetType", function() {
310339
var MaybeNumber = canReflect.assignSymbols({}, {

src/types/make-maybe.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ function makeMaybe(inValues, makeChildType) {
9595
} else {
9696
this.enum = result.enum;
9797
}
98+
if(this.enum === set.EMPTY && this.range === set.EMPTY) {
99+
return set.EMPTY;
100+
}
98101
}
99102
Maybe.prototype.orValues = function() {
100103
var values = [];
@@ -112,6 +115,8 @@ function makeMaybe(inValues, makeChildType) {
112115
return rangeIsMember.apply(this.range, arguments) || enumIsMember.apply(this.enum, arguments);
113116
}
114117

118+
119+
115120
set.defineComparison(Maybe, Maybe, {
116121
union: function(maybeA, maybeB) {
117122
var enumSet = set.union(maybeA.enum, maybeB.enum);

0 commit comments

Comments
 (0)