-
Notifications
You must be signed in to change notification settings - Fork 5
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 #4 from paluh/omap-index-based-operations
Add index based OMap operations
- Loading branch information
Showing
3 changed files
with
63 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,34 @@ | ||
module Data.Map.Ordered.Spec | ||
( orderedMapSpec | ||
) where | ||
|
||
import Prelude | ||
|
||
import Data.Map.Ordered.OMap (fromFoldable, moveLeft, moveRight) | ||
import Data.Maybe (Maybe(..)) | ||
import Data.Tuple.Nested ((/\)) | ||
import Test.Spec (Spec, describe, it) | ||
import Test.Spec.Assertions (shouldEqual) | ||
|
||
orderedMapSpec :: Spec Unit | ||
orderedMapSpec = do | ||
describe "moveLeft" do | ||
it "fails on the first element" do | ||
let | ||
m = fromFoldable [ "foo" /\ 1, "bar" /\ 2, "baz" /\ 3 ] | ||
moveLeft "foo" m `shouldEqual` Nothing | ||
it "moves the second element" do | ||
let | ||
m = fromFoldable [ "foo" /\ 1, "bar" /\ 2, "baz" /\ 3 ] | ||
moveLeft "bar" m `shouldEqual` | ||
(Just $ fromFoldable [ "bar" /\ 2, "foo" /\ 1, "baz" /\ 3 ]) | ||
describe "moveRight" do | ||
it "fails on the last element" do | ||
let | ||
m = fromFoldable [ "foo" /\ 1, "bar" /\ 2, "baz" /\ 3 ] | ||
moveRight "baz" m `shouldEqual` Nothing | ||
it "moves the second element" do | ||
let | ||
m = fromFoldable [ "foo" /\ 1, "bar" /\ 2, "baz" /\ 3 ] | ||
moveRight "bar" m `shouldEqual` | ||
(Just $ fromFoldable [ "foo" /\ 1, "baz" /\ 3, "bar" /\ 2 ]) |
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