aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinoas <mail@inoas.com>2022-06-27 19:47:37 +0000
committerGitHub <noreply@github.com>2022-06-27 20:47:37 +0100
commit151304663034ae06dfe2b137cc79b70577628605 (patch)
tree9c19f23b998e5f4ae89524dfacc74b4ebd2b4d1e
parentf3f9aa54c1b9863fef0b2840deecd574f7c28aa6 (diff)
downloadgleam_stdlib-151304663034ae06dfe2b137cc79b70577628605.tar.gz
gleam_stdlib-151304663034ae06dfe2b137cc79b70577628605.zip
String.inspect bitstring tests (#309)
-rw-r--r--test/gleam/string_test.gleam18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/gleam/string_test.gleam b/test/gleam/string_test.gleam
index 0fcc0e7..46b5e91 100644
--- a/test/gleam/string_test.gleam
+++ b/test/gleam/string_test.gleam
@@ -729,6 +729,11 @@ if javascript {
string.inspect(#(1.0))
|> should.equal("#(1)")
+
+ // Unlike on Erlang, on JavaScript `BitString` and `String` do have a different runtime representation.
+ <<"abc":utf8>>
+ |> string.inspect()
+ |> should.equal("<<97, 98, 99>>")
}
}
@@ -742,13 +747,13 @@ if erlang {
"erlang" "make_ref"
pub fn target_inspect_test() {
- // Erlang's internal representation does not allow a correct differentiation
+ // Erlang's internal representation does not allow a correct differentiation.
// |> should.equal("#(InspectTypeZero, InspectTypeZero)")
//
string.inspect(#(InspectTypeZero, InspectTypeZero))
|> should.equal("InspectTypeZero(InspectTypeZero)")
- // Unlike JavaScript, Erlang correctly differentiates between 1 and 1.0
+ // Unlike JavaScript, Erlang correctly differentiates between `1` and `1.0`.
//
string.inspect(-1.0)
|> should.equal("-1.0")
@@ -765,14 +770,14 @@ if erlang {
string.inspect(#(1.0))
|> should.equal("#(1.0)")
- // Looks like `//erl(<0.83.0>)`
+ // Looks like `//erl(<0.83.0>)`.
assert Ok(regular_expression) =
regex.from_string("^\\/\\/erl\\(<[0-9]+\\.[0-9]+\\.[0-9]+>\\)$")
string.inspect(create_erlang_pid())
|> regex.check(regular_expression, _)
|> should.equal(True)
- // Looks like: `//erl(#Ref<0.1809744150.4035444737.100468>)`
+ // Looks like: `//erl(#Ref<0.1809744150.4035444737.100468>)`.
assert Ok(regular_expression) =
regex.from_string(
"^\\/\\/erl\\(#Ref<[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+>\\)$",
@@ -780,5 +785,10 @@ if erlang {
string.inspect(create_erlang_reference())
|> regex.check(regular_expression, _)
|> should.equal(True)
+
+ // On Erlang the runtime representation for `String` and `BitString` is indistinguishable.
+ <<"abc":utf8>>
+ |> string.inspect()
+ |> should.equal("\"abc\"")
}
}