-
-
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.
ord: add S.lt, S.lte, S.gt, and S.gte
- Loading branch information
1 parent
f32201e
commit d6b3822
Showing
5 changed files
with
312 additions
and
0 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,55 @@ | ||
'use strict'; | ||
|
||
var S = require('..'); | ||
|
||
var eq = require('./internal/eq'); | ||
var throws = require('./internal/throws'); | ||
|
||
|
||
test('gt', function() { | ||
|
||
eq(typeof S.gt, 'function'); | ||
eq(S.gt.length, 2); | ||
|
||
throws(function() { S.gt(null); }, | ||
TypeError, | ||
'Type-class constraint violation\n' + | ||
'\n' + | ||
'gt :: Ord a => a -> a -> Boolean\n' + | ||
' ^^^^^ ^\n' + | ||
' 1\n' + | ||
'\n' + | ||
'1) null :: Null\n' + | ||
'\n' + | ||
'‘gt’ requires ‘a’ to satisfy the Ord type-class constraint; the value at position 1 does not.\n'); | ||
|
||
throws(function() { S.gt('abc', 123); }, | ||
TypeError, | ||
'Type-variable constraint violation\n' + | ||
'\n' + | ||
'gt :: Ord a => a -> a -> Boolean\n' + | ||
' ^ ^\n' + | ||
' 1 2\n' + | ||
'\n' + | ||
'1) "abc" :: String\n' + | ||
'\n' + | ||
'2) 123 :: Number, FiniteNumber, NonZeroFiniteNumber, Integer, ValidNumber\n' + | ||
'\n' + | ||
'Since there is no type of which all the above values are members, the type-variable constraint has been violated.\n'); | ||
|
||
eq(S.gt(0, 0), false); | ||
eq(S.gt(0, -0), false); | ||
eq(S.gt(-0, 0), false); | ||
eq(S.gt(-0, -0), false); | ||
eq(S.gt(0, 1), false); | ||
eq(S.gt(1, 0), true); | ||
eq(S.gt(0, -1), true); | ||
eq(S.gt(-1, 0), false); | ||
eq(S.gt('a', 'a'), false); | ||
eq(S.gt('a', 'z'), false); | ||
eq(S.gt('z', 'a'), true); | ||
eq(S.gt(new Date(0), new Date(0)), false); | ||
eq(S.gt(new Date(0), new Date(1)), false); | ||
eq(S.gt(new Date(1), new Date(0)), true); | ||
|
||
}); |
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,55 @@ | ||
'use strict'; | ||
|
||
var S = require('..'); | ||
|
||
var eq = require('./internal/eq'); | ||
var throws = require('./internal/throws'); | ||
|
||
|
||
test('gte', function() { | ||
|
||
eq(typeof S.gte, 'function'); | ||
eq(S.gte.length, 2); | ||
|
||
throws(function() { S.gte(null); }, | ||
TypeError, | ||
'Type-class constraint violation\n' + | ||
'\n' + | ||
'gte :: Ord a => a -> a -> Boolean\n' + | ||
' ^^^^^ ^\n' + | ||
' 1\n' + | ||
'\n' + | ||
'1) null :: Null\n' + | ||
'\n' + | ||
'‘gte’ requires ‘a’ to satisfy the Ord type-class constraint; the value at position 1 does not.\n'); | ||
|
||
throws(function() { S.gte('abc', 123); }, | ||
TypeError, | ||
'Type-variable constraint violation\n' + | ||
'\n' + | ||
'gte :: Ord a => a -> a -> Boolean\n' + | ||
' ^ ^\n' + | ||
' 1 2\n' + | ||
'\n' + | ||
'1) "abc" :: String\n' + | ||
'\n' + | ||
'2) 123 :: Number, FiniteNumber, NonZeroFiniteNumber, Integer, ValidNumber\n' + | ||
'\n' + | ||
'Since there is no type of which all the above values are members, the type-variable constraint has been violated.\n'); | ||
|
||
eq(S.gte(0, 0), true); | ||
eq(S.gte(0, -0), true); | ||
eq(S.gte(-0, 0), true); | ||
eq(S.gte(-0, -0), true); | ||
eq(S.gte(0, 1), false); | ||
eq(S.gte(1, 0), true); | ||
eq(S.gte(0, -1), true); | ||
eq(S.gte(-1, 0), false); | ||
eq(S.gte('a', 'a'), true); | ||
eq(S.gte('a', 'z'), false); | ||
eq(S.gte('z', 'a'), true); | ||
eq(S.gte(new Date(0), new Date(0)), true); | ||
eq(S.gte(new Date(0), new Date(1)), false); | ||
eq(S.gte(new Date(1), new Date(0)), true); | ||
|
||
}); |
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,55 @@ | ||
'use strict'; | ||
|
||
var S = require('..'); | ||
|
||
var eq = require('./internal/eq'); | ||
var throws = require('./internal/throws'); | ||
|
||
|
||
test('lt', function() { | ||
|
||
eq(typeof S.lt, 'function'); | ||
eq(S.lt.length, 2); | ||
|
||
throws(function() { S.lt(null); }, | ||
TypeError, | ||
'Type-class constraint violation\n' + | ||
'\n' + | ||
'lt :: Ord a => a -> a -> Boolean\n' + | ||
' ^^^^^ ^\n' + | ||
' 1\n' + | ||
'\n' + | ||
'1) null :: Null\n' + | ||
'\n' + | ||
'‘lt’ requires ‘a’ to satisfy the Ord type-class constraint; the value at position 1 does not.\n'); | ||
|
||
throws(function() { S.lt('abc', 123); }, | ||
TypeError, | ||
'Type-variable constraint violation\n' + | ||
'\n' + | ||
'lt :: Ord a => a -> a -> Boolean\n' + | ||
' ^ ^\n' + | ||
' 1 2\n' + | ||
'\n' + | ||
'1) "abc" :: String\n' + | ||
'\n' + | ||
'2) 123 :: Number, FiniteNumber, NonZeroFiniteNumber, Integer, ValidNumber\n' + | ||
'\n' + | ||
'Since there is no type of which all the above values are members, the type-variable constraint has been violated.\n'); | ||
|
||
eq(S.lt(0, 0), false); | ||
eq(S.lt(0, -0), false); | ||
eq(S.lt(-0, 0), false); | ||
eq(S.lt(-0, -0), false); | ||
eq(S.lt(0, 1), true); | ||
eq(S.lt(1, 0), false); | ||
eq(S.lt(0, -1), false); | ||
eq(S.lt(-1, 0), true); | ||
eq(S.lt('a', 'a'), false); | ||
eq(S.lt('a', 'z'), true); | ||
eq(S.lt('z', 'a'), false); | ||
eq(S.lt(new Date(0), new Date(0)), false); | ||
eq(S.lt(new Date(0), new Date(1)), true); | ||
eq(S.lt(new Date(1), new Date(0)), false); | ||
|
||
}); |
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,55 @@ | ||
'use strict'; | ||
|
||
var S = require('..'); | ||
|
||
var eq = require('./internal/eq'); | ||
var throws = require('./internal/throws'); | ||
|
||
|
||
test('lte', function() { | ||
|
||
eq(typeof S.lte, 'function'); | ||
eq(S.lte.length, 2); | ||
|
||
throws(function() { S.lte(null); }, | ||
TypeError, | ||
'Type-class constraint violation\n' + | ||
'\n' + | ||
'lte :: Ord a => a -> a -> Boolean\n' + | ||
' ^^^^^ ^\n' + | ||
' 1\n' + | ||
'\n' + | ||
'1) null :: Null\n' + | ||
'\n' + | ||
'‘lte’ requires ‘a’ to satisfy the Ord type-class constraint; the value at position 1 does not.\n'); | ||
|
||
throws(function() { S.lte('abc', 123); }, | ||
TypeError, | ||
'Type-variable constraint violation\n' + | ||
'\n' + | ||
'lte :: Ord a => a -> a -> Boolean\n' + | ||
' ^ ^\n' + | ||
' 1 2\n' + | ||
'\n' + | ||
'1) "abc" :: String\n' + | ||
'\n' + | ||
'2) 123 :: Number, FiniteNumber, NonZeroFiniteNumber, Integer, ValidNumber\n' + | ||
'\n' + | ||
'Since there is no type of which all the above values are members, the type-variable constraint has been violated.\n'); | ||
|
||
eq(S.lte(0, 0), true); | ||
eq(S.lte(0, -0), true); | ||
eq(S.lte(-0, 0), true); | ||
eq(S.lte(-0, -0), true); | ||
eq(S.lte(0, 1), true); | ||
eq(S.lte(1, 0), false); | ||
eq(S.lte(0, -1), false); | ||
eq(S.lte(-1, 0), true); | ||
eq(S.lte('a', 'a'), true); | ||
eq(S.lte('a', 'z'), true); | ||
eq(S.lte('z', 'a'), false); | ||
eq(S.lte(new Date(0), new Date(0)), true); | ||
eq(S.lte(new Date(0), new Date(1)), true); | ||
eq(S.lte(new Date(1), new Date(0)), false); | ||
|
||
}); |