Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
inoas committed Jan 16, 2025
1 parent eb8b568 commit 2d6eb79
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- `given.when` to allow for more complex lazy conditions.
- `given.when_not` to allow for more complex lazy conditions.
- `given.empty` to check if a list is empty.
- `given.not_empty` to check if a list is not empty.
- `given.non_empty` to check if a list is not empty.
- `given.all_ok` to check if all results are ok.
- `given.any_ok` to check if any results are ok.
- `given.all_error` to check if all results are errors.
Expand Down
4 changes: 2 additions & 2 deletions src/given.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,13 @@ pub fn empty(
///
/// let list = []
///
/// use <- given.not_empty(list, else_return: fn() { "Empty" })
/// use <- given.non_empty(list, else_return: fn() { "Empty" })
///
/// // …handle non-empty list here…
/// "Not empty"
/// ```
///
pub fn not_empty(
pub fn non_empty(
list list: List(a),
else_return alternative: fn() -> b,
return consequence: fn() -> b,
Expand Down
2 changes: 2 additions & 0 deletions src/given/internal/examples.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import given.{not as not_given, that as given}

// TODO: add new examples

pub fn given_example() {
let user_understood = False

Expand Down
40 changes: 40 additions & 0 deletions test/given_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ pub fn when_not_test() {
// |> should.equal("Not an Admin")
}

pub fn empty_test() {
todo
}

pub fn non_empty_test() {
todo
}

pub fn ok_test() {
{
let result = Ok(great)
Expand All @@ -178,6 +186,14 @@ pub fn ok_test() {
|> should.equal(woof)
}

pub fn any_ok_test() {
todo
}

pub fn all_ok_test() {
todo
}

pub fn error_test() {
{
let result = Error(woof)
Expand All @@ -204,6 +220,14 @@ pub fn error_test() {
|> should.equal(great)
}

pub fn any_error_test() {
todo
}

pub fn all_error_test() {
todo
}

pub fn some_test() {
{
let option = Some(great)
Expand All @@ -226,6 +250,14 @@ pub fn some_test() {
|> should.equal(great)
}

pub fn any_some_test() {
todo
}

pub fn all_some_test() {
todo
}

pub fn none_test() {
{
let option = Some(great)
Expand All @@ -247,3 +279,11 @@ pub fn none_test() {
}
|> should.equal("None encountered!")
}

pub fn any_none_test() {
todo
}

pub fn all_none_test() {
todo
}

0 comments on commit 2d6eb79

Please sign in to comment.