-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #612 from sanctuary-js/davidchambers/value
strmap: add S.value
- Loading branch information
Showing
6 changed files
with
98 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const proto = Object.create (null); | ||
|
||
Object.defineProperty ( | ||
proto, | ||
'non-enumerable inherited property', | ||
{enumerable: false, value: 'non-enumerable inherited property'} | ||
); | ||
Object.defineProperty ( | ||
proto, | ||
'enumerable inherited property', | ||
{enumerable: true, value: 'enumerable inherited property'} | ||
); | ||
|
||
const strMap = Object.create (proto); | ||
|
||
Object.defineProperty ( | ||
strMap, | ||
'non-enumerable own property', | ||
{enumerable: false, value: 'non-enumerable own property'} | ||
); | ||
Object.defineProperty ( | ||
strMap, | ||
'enumerable own property', | ||
{enumerable: true, value: 'enumerable own property'} | ||
); | ||
|
||
module.exports = strMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
const S = require ('..'); | ||
|
||
const eq = require ('./internal/eq'); | ||
const strMap = require ('./internal/strMap'); | ||
|
||
|
||
test ('value', () => { | ||
|
||
eq (typeof S.value) ('function'); | ||
eq (S.value.length) (1); | ||
eq (S.show (S.value)) ('value :: String -> StrMap a -> Maybe a'); | ||
|
||
eq (S.value ('foo') ({foo: 1, bar: 2})) (S.Just (1)); | ||
eq (S.value ('bar') ({foo: 1, bar: 2})) (S.Just (2)); | ||
eq (S.value ('baz') ({foo: 1, bar: 2})) (S.Nothing); | ||
|
||
eq (S.value ('valueOf') ({})) (S.Nothing); | ||
|
||
eq (S.value ('non-enumerable inherited property') (strMap)) (S.Nothing); | ||
eq (S.value ('enumerable inherited property') (strMap)) (S.Nothing); | ||
eq (S.value ('non-enumerable own property') (strMap)) (S.Nothing); | ||
eq (S.value ('enumerable own property') (strMap)) (S.Just ('enumerable own property')); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters