diff options
author | Jamie Luck <delucks@users.noreply.github.com> | 2020-03-29 06:07:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-29 11:07:06 +0100 |
commit | eead09e4fc457b85a5ff6cb990cf293c5d84336c (patch) | |
tree | 093af27b46333eda5aea4e7da6f48cc680c77256 /src | |
parent | 338ad88b61fda07b008632652b9553c6bf2c0aab (diff) | |
download | gleam_stdlib-eead09e4fc457b85a5ff6cb990cf293c5d84336c.tar.gz gleam_stdlib-eead09e4fc457b85a5ff6cb990cf293c5d84336c.zip |
Rename gleam/expect to gleam/should (#27)
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/expect.gleam | 20 | ||||
-rw-r--r-- | src/gleam/should.gleam | 20 | ||||
-rw-r--r-- | src/gleam_stdlib.erl | 16 |
3 files changed, 28 insertions, 28 deletions
diff --git a/src/gleam/expect.gleam b/src/gleam/expect.gleam deleted file mode 100644 index fb46f1e..0000000 --- a/src/gleam/expect.gleam +++ /dev/null @@ -1,20 +0,0 @@ -// TODO: Move this module into another package so it can be used as a -// dep only in test. - -pub external type Expectation; - -pub external fn equal(a, a) -> Expectation = "gleam_stdlib" "expect_equal"; - -pub external fn not_equal(a, a) -> Expectation = "gleam_stdlib" "expect_not_equal"; - -pub external fn true(Bool) -> Expectation = "gleam_stdlib" "expect_true"; - -pub external fn false(Bool) -> Expectation = "gleam_stdlib" "expect_false"; - -pub external fn is_ok(Result(a, b)) -> Expectation = "gleam_stdlib" "expect_is_ok"; - -pub external fn is_error(Result(a, b)) -> Expectation = "gleam_stdlib" "expect_is_error"; - -pub fn fail() -> Expectation { - true(False) -} diff --git a/src/gleam/should.gleam b/src/gleam/should.gleam new file mode 100644 index 0000000..0fbebeb --- /dev/null +++ b/src/gleam/should.gleam @@ -0,0 +1,20 @@ +// TODO: Move this module into another package so it can be used as a +// dep only in test. + +pub external type Expectation; + +pub external fn equal(a, a) -> Expectation = "gleam_stdlib" "should_equal"; + +pub external fn not_equal(a, a) -> Expectation = "gleam_stdlib" "should_not_equal"; + +pub external fn be_true(Bool) -> Expectation = "gleam_stdlib" "should_be_true"; + +pub external fn be_false(Bool) -> Expectation = "gleam_stdlib" "should_be_false"; + +pub external fn be_ok(Result(a, b)) -> Expectation = "gleam_stdlib" "should_be_ok"; + +pub external fn be_error(Result(a, b)) -> Expectation = "gleam_stdlib" "should_be_error"; + +pub fn fail() -> Expectation { + be_true(False) +} diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl index 9f380ef..1f1f652 100644 --- a/src/gleam_stdlib.erl +++ b/src/gleam_stdlib.erl @@ -1,19 +1,19 @@ -module(gleam_stdlib). -include_lib("eunit/include/eunit.hrl"). --export([expect_equal/2, expect_not_equal/2, expect_true/1, expect_false/1, - expect_is_ok/1, expect_is_error/1, atom_from_string/1, +-export([should_equal/2, should_not_equal/2, should_be_true/1, should_be_false/1, + should_be_ok/1, should_be_error/1, atom_from_string/1, atom_create_from_string/1, atom_to_string/1, map_get/2, iodata_append/2, iodata_prepend/2, identity/1, decode_int/1, decode_string/1, decode_bool/1, decode_float/1, decode_thunk/1, decode_atom/1, decode_list/1, decode_field/2, decode_element/2, parse_int/1, parse_float/1, compare_strings/2]). -expect_equal(Actual, Expected) -> ?assertEqual(Expected, Actual). -expect_not_equal(Actual, Expected) -> ?assertNotEqual(Expected, Actual). -expect_true(A) -> ?assert(A). -expect_false(A) -> ?assertNot(A). -expect_is_ok(A) -> ?assertMatch({ok, _}, A). -expect_is_error(A) -> ?assertMatch({error, _}, A). +should_equal(Actual, Expected) -> ?assertEqual(Expected, Actual). +should_not_equal(Actual, Expected) -> ?assertNotEqual(Expected, Actual). +should_be_true(A) -> ?assert(A). +should_be_false(A) -> ?assertNot(A). +should_be_ok(A) -> ?assertMatch({ok, _}, A). +should_be_error(A) -> ?assertMatch({error, _}, A). map_get(Map, Key) -> case maps:find(Key, Map) of |