aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2023-07-23 19:54:21 +0100
committerLouis Pilfold <louis@lpil.uk>2023-07-23 19:54:21 +0100
commita9fe25aca0a825ec4f38bf9b52e745ba98be02de (patch)
tree55ebc9c8acba29a5f49fe3ebb95803158328192c
parent6065a2102d6a77e8dd1a8cb71ed9394cefc80802 (diff)
downloadgleam_stdlib-a9fe25aca0a825ec4f38bf9b52e745ba98be02de.tar.gz
gleam_stdlib-a9fe25aca0a825ec4f38bf9b52e745ba98be02de.zip
Show atom function in string.inspect
-rw-r--r--src/gleam_stdlib.erl2
-rw-r--r--test/gleam/string_test.gleam16
2 files changed, 9 insertions, 9 deletions
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index 76b51f8..63067f6 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -375,7 +375,7 @@ inspect(Atom) when is_atom(Atom) ->
Binary = erlang:atom_to_binary(Atom),
case inspect_maybe_gleam_atom(Binary, none, <<>>) of
{ok, Inspected} -> Inspected;
- {error, _} -> ["//erl('", Binary, "')"]
+ {error, _} -> ["atom.create_from_string(\"", Binary, "\")"]
end;
inspect(Any) when is_integer(Any) ->
erlang:integer_to_list(Any);
diff --git a/test/gleam/string_test.gleam b/test/gleam/string_test.gleam
index 5b9b2a5..88eb39b 100644
--- a/test/gleam/string_test.gleam
+++ b/test/gleam/string_test.gleam
@@ -1016,28 +1016,28 @@ pub fn inspect_erlang_atom_is_valid_in_gleam_test() {
pub fn inspect_erlang_atom_with_a_leading_underscore_is_invalid_in_gleam_test() {
string_to_erlang_atom("_ok")
|> string.inspect
- |> should.equal("//erl('_ok')")
+ |> should.equal("atom.create_from_string(\"_ok\")")
}
@target(erlang)
pub fn inspect_erlang_atom_with_a_trailing_underscore_is_invalid_in_gleam_test() {
string_to_erlang_atom("ok_")
|> string.inspect
- |> should.equal("//erl('ok_')")
+ |> should.equal("atom.create_from_string(\"ok_\")")
}
@target(erlang)
pub fn inspect_erlang_atom_with_a_double_underscore_is_invalid_in_gleam_test() {
string_to_erlang_atom("ok__ok")
|> string.inspect
- |> should.equal("//erl('ok__ok')")
+ |> should.equal("atom.create_from_string(\"ok__ok\")")
}
@target(erlang)
pub fn inspect_erlang_atom_with_white_spaces_is_invalid_in_gleam_test() {
string_to_erlang_atom("ok ok")
|> string.inspect
- |> should.equal("//erl('ok ok')")
+ |> should.equal("atom.create_from_string(\"ok ok\")")
}
@target(erlang)
@@ -1045,25 +1045,25 @@ pub fn inspect_erlang_atom_that_is_an_empty_string_is_invalid_in_gleam_test() {
// An empty string based atom is invalid in gleam
string_to_erlang_atom("")
|> string.inspect
- |> should.equal("//erl('')")
+ |> should.equal("atom.create_from_string(\"\")")
}
@target(erlang)
pub fn inspect_erlang_atom_with_uppercases_invalid_in_gleam_test() {
string_to_erlang_atom("Upper")
|> string.inspect
- |> should.equal("//erl('Upper')")
+ |> should.equal("atom.create_from_string(\"Upper\")")
}
@target(erlang)
pub fn inspect_erlang_atom_with_leading_digit_invalid_in_gleam_test() {
string_to_erlang_atom("1_ok")
|> string.inspect
- |> should.equal("//erl('1_ok')")
+ |> should.equal("atom.create_from_string(\"1_ok\")")
string_to_erlang_atom("1Ok")
|> string.inspect
- |> should.equal("//erl('1Ok')")
+ |> should.equal("atom.create_from_string(\"1Ok\")")
}
pub fn byte_size_test() {