Skip to content

Commit

Permalink
Merge pull request #243 from sanctuary-js/davidchambers/record-type
Browse files Browse the repository at this point in the history
types: exclude null and undefined from empty record types
  • Loading branch information
davidchambers authored Mar 29, 2019
2 parents d213ba1 + 9dfe4c6 commit 0b0955c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1743,6 +1743,7 @@
}

function test(x) {
if (x == null) return false;
var missing = {};
keys.forEach (function(k) { missing[k] = k; });
for (var k in x) delete missing[k];
Expand Down Expand Up @@ -1816,6 +1817,7 @@
}

function test(x) {
if (x == null) return false;
var missing = {};
keys.forEach (function(k) { missing[k] = k; });
for (var k in x) delete missing[k];
Expand Down
8 changes: 4 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1007,8 +1007,8 @@ Since there is no type of which all the above values are members, the type-varia
// Empty :: Type
const Empty = $.RecordType ({});

eq ($.test ([]) (Empty) (null)) (true);
eq ($.test ([]) (Empty) (undefined)) (true);
eq ($.test ([]) (Empty) (null)) (false);
eq ($.test ([]) (Empty) (undefined)) (false);
eq ($.test ([]) (Empty) (false)) (true);
eq ($.test ([]) (Empty) (12.34)) (true);
eq ($.test ([]) (Empty) ('xyz')) (true);
Expand Down Expand Up @@ -1264,8 +1264,8 @@ The value at position 1 is not a member of ‘{ length :: a }’.
// Empty :: Type
const Empty = $.NamedRecordType ('my-package/Empty') ('') ({});

eq ($.test ([]) (Empty) (null)) (true);
eq ($.test ([]) (Empty) (undefined)) (true);
eq ($.test ([]) (Empty) (null)) (false);
eq ($.test ([]) (Empty) (undefined)) (false);
eq ($.test ([]) (Empty) (false)) (true);
eq ($.test ([]) (Empty) (12.34)) (true);
eq ($.test ([]) (Empty) ('xyz')) (true);
Expand Down

0 comments on commit 0b0955c

Please sign in to comment.