-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat(Array): add dropLast and dropRight functions #724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
81c2d4c
feat(Array): add dropLast and dropRight functions
XiayiZhang 844c992
fix: Refine code and add tests based on review feedback.
XiayiZhang 5d12804
fix: Replace a with element in the signature of dropLast and dropRight
XiayiZhang f097d08
chore(codemap): regenerate Array API artifacts
NickSeagullBot ab82262
fix(array): preserve dropRight input for non-positive counts
NickSeagullBot 41cc244
merge: update feature/dropLast with main
NickSeagullBot 1f9f6f6
test(array): exercise drop operations in core suite
NickSeagullBot bd9fad6
test(array): cover singleton and empty boundaries
NickSeagullBot f27eeb3
chore(codemap): refresh Array test call counts
NickSeagullBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,27 @@ | ||
| {-# OPTIONS_GHC -Wno-unused-imports #-} | ||
|
|
||
| module ArraySpec where | ||
|
|
||
| import Array qualified | ||
| import Test | ||
|
|
||
| spec :: Spec Unit | ||
| spec = do | ||
| describe "Array" do | ||
| describe "dropLast" do | ||
| it "removes the final element" \_ -> do | ||
| Array.fromLinkedList [1, 2, 3] |> Array.dropLast |> shouldBe (Array.fromLinkedList [1, 2]) | ||
|
|
||
| it "returns the same empty array" \_ -> do | ||
| Array.empty |> Array.dropLast |> shouldBe (Array.empty :: Array.Array Int) | ||
|
|
||
| describe "dropRight" do | ||
| it "drops the last n elements" \_ -> do | ||
| Array.fromLinkedList [1, 2, 3, 4] |> Array.dropRight 2 |> shouldBe (Array.fromLinkedList [1, 2]) | ||
|
|
||
| it "returns the original array when n is zero" \_ -> do | ||
| Array.fromLinkedList [1, 2, 3] |> Array.dropRight 0 |> shouldBe (Array.fromLinkedList [1, 2, 3]) | ||
|
|
||
| it "returns an empty array when n is at least the length" \_ -> do | ||
| Array.fromLinkedList [1, 2, 3] |> Array.dropRight 3 |> shouldBe (Array.empty :: Array.Array Int) | ||
| Array.fromLinkedList [1, 2, 3] |> Array.dropRight 5 |> shouldBe (Array.empty :: Array.Array Int) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.