Skip to content

Commit

Permalink
update tests, docs, examples
Browse files Browse the repository at this point in the history
  • Loading branch information
inoas committed Dec 16, 2024
1 parent 04608cf commit f8dc616
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

<!-- ## [Unreleased] -->

## [3.0.1] - 2024-12-16

- Added one inverse example for `none_in`.

## [3.0.0] - 2024-12-16

- Updated labels and internal code to be more consistent.

git
## [2.0.0] - 2024-12-14

- Removed `given` function prefixes from most functions to cut down import
Expand Down
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ import given.{given, not_given}
import gleam/io
import gleam/option.{None, Some}
pub fn main() {
given_example() |> io.debug()
// "🤯 Woof!"
not_given_example() |> io.debug()
// "👌 Access granted..."
given_ok_in_example() |> io.debug()
// "Hello Joe!"
given_error_in_example() |> io.debug()
// "Memory exhausted!"
given_some_in_example() |> io.debug()
// "One Penny"
given_none_in_example() |> io.debug()
// "Nothing at all"
given_none_in_another_example() |> io.debug()
// "None here"
}
import given.{given, not_given}
import gleam/io
import gleam/option.{None, Some}
pub fn main() {
given_example() |> io.debug()
// "🤯 Woof!"
Expand Down Expand Up @@ -116,6 +143,15 @@ pub fn given_none_in_example() {
"Nothing at all"
}
pub fn given_none_in_another_example() {
let an_option = None
use else_some_value <- given.none_in(an_option, return: fn() { "None here" })
// …handle Some value here…
else_some_value
}
```

Further documentation can be found at <https://hexdocs.pm/given>.
Expand Down
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "given"
version = "3.0.0"
version = "3.0.1"

# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
Expand Down
9 changes: 9 additions & 0 deletions src/given/internal/examples.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ pub fn given_none_in_example() {

"Nothing at all"
}

pub fn given_none_in_another_example() {
let an_option = None
use else_some_value <- given.none_in(an_option, return: fn() { "None here" })

// …handle Some value here…

else_some_value
}
6 changes: 4 additions & 2 deletions test/given_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ pub fn given_none_in_2nd_test() {

{
let option = None
use some_value <- given.none_in(option, return: fn() { "None encountered!" })
use else_some_value <- given.none_in(option, return: fn() {
"None encountered!"
})
// …user handles Some value here…
some_value
else_some_value
}
|> should.equal("None encountered!")
}

0 comments on commit f8dc616

Please sign in to comment.