Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Dec 19, 2023
1 parent efa24af commit 5a610ff
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.0.1 - 2023-12-19

- Updated for Gleam v0.33.0.

## v1.0.0 - 2023-08-06

- Updated for Gleam v0.32.0.
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 = "gleeunit"
version = "1.0.0"
version = "1.0.1"
licences = ["Apache-2.0"]
description = "Gleam bindings to Erlang's EUnit test framework"
gleam = ">= 0.32.0"
Expand Down
2 changes: 1 addition & 1 deletion manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# You typically do not need to edit this file

packages = [
{ name = "gleam_stdlib", version = "0.32.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "07D64C26D014CF570F8ACADCE602761EA2E74C842D26F2FD49B0D61973D9966F" },
{ name = "gleam_stdlib", version = "0.34.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1FB8454D2991E9B4C0C804544D8A9AD0F6184725E20D63C3155F0AEB4230B016" },
]

[requirements]
Expand Down
55 changes: 18 additions & 37 deletions src/gleeunit/should.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,55 @@
//// More information on running eunit can be found in [the rebar3
//// documentation](https://rebar3.org/docs/testing/eunit/).

@target(erlang)
@external(erlang, "gleeunit_ffi", "should_equal")
pub fn equal(a: a, b: a) -> Nil

@target(erlang)
@external(erlang, "gleeunit_ffi", "should_not_equal")
pub fn not_equal(a: a, b: a) -> Nil

@target(erlang)
@external(erlang, "gleeunit_ffi", "should_be_ok")
pub fn be_ok(a: Result(a, b)) -> a

@target(erlang)
@external(erlang, "gleeunit_ffi", "should_be_error")
pub fn be_error(a: Result(a, b)) -> b

@target(javascript)
import gleam/string

@target(javascript)
@external(javascript, "../gleam.mjs", "inspect")
fn stringify(a: anything) -> String

@target(javascript)
@external(javascript, "../gleeunit_ffi.mjs", "crash")
fn crash(a: String) -> anything

@target(javascript)
pub fn equal(a, b) {
@external(erlang, "gleeunit_ffi", "should_equal")
pub fn equal(a: t, b: t) -> Nil {
case a == b {
True -> Nil
_ ->
crash(string.concat([
panic as string.concat([
"\n\t",
stringify(a),
string.inspect(a),
"\n\tshould equal \n\t",
stringify(b),
]))
string.inspect(b),
])
}
}

@target(javascript)
pub fn not_equal(a, b) {
@external(erlang, "gleeunit_ffi", "should_not_equal")
pub fn not_equal(a: t, b: t) -> Nil {
case a != b {
True -> Nil
_ ->
crash(string.concat([
panic as string.concat([
"\n",
stringify(a),
string.inspect(a),
"\nshould not equal \n",
stringify(b),
]))
string.inspect(b),
])
}
}

@target(javascript)
pub fn be_ok(a) {
@external(erlang, "gleeunit_ffi", "should_be_ok")
pub fn be_ok(a: Result(a, e)) -> a {
case a {
Ok(value) -> value
_ -> crash(string.concat(["\n", stringify(a), "\nshould be ok"]))
_ -> panic as string.concat(["\n", string.inspect(a), "\nshould be ok"])
}
}

@target(javascript)
pub fn be_error(a) {
@external(erlang, "gleeunit_ffi", "should_be_error")
pub fn be_error(a: Result(a, e)) -> e {
case a {
Error(error) -> error
_ -> crash(string.concat(["\n", stringify(a), "\nshould be error"]))
_ -> panic as string.concat(["\n", string.inspect(a), "\nshould be error"])
}
}

Expand Down

0 comments on commit 5a610ff

Please sign in to comment.