diff --git a/CHANGELOG.md b/CHANGELOG.md index 680cbd0..047b9ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/gleam.toml b/gleam.toml index 5ed40ee..bd78276 100644 --- a/gleam.toml +++ b/gleam.toml @@ -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" diff --git a/manifest.toml b/manifest.toml index 04ba09d..6b1363a 100644 --- a/manifest.toml +++ b/manifest.toml @@ -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] diff --git a/src/gleeunit/should.gleam b/src/gleeunit/should.gleam index c393c23..9dd2032 100644 --- a/src/gleeunit/should.gleam +++ b/src/gleeunit/should.gleam @@ -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"]) } }