aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--src/gleam_stdlib.erl2
-rw-r--r--test/gleam/bit_string_test.gleam16
3 files changed, 20 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2f47119..28e600d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog
+## Unreleased
+
+- Fixed a bug in `big_string.concat`, it now uses `erlang:list_to_bitstring`
- The `bit_builder` module gains the `from_bit_strings` function.
## v0.22.0 - 2022-06-15
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index e7b80d6..c4d01e4 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -163,7 +163,7 @@ string_pop_grapheme(String) ->
end.
bit_string_concat(BitStrings) ->
- iolist_to_binary(BitStrings).
+ list_to_bitstring(BitStrings).
bit_string_slice(Bin, Pos, Len) ->
try {ok, binary:part(Bin, Pos, Len)}
diff --git a/test/gleam/bit_string_test.gleam b/test/gleam/bit_string_test.gleam
index a395672..48f66d6 100644
--- a/test/gleam/bit_string_test.gleam
+++ b/test/gleam/bit_string_test.gleam
@@ -23,6 +23,14 @@ pub fn append_test() {
|> should.equal(<<1, 2, 3, 4>>)
}
+if erlang {
+ pub fn append_erlang_only_test() {
+ <<1, 2:4>>
+ |> bit_string.append(<<3>>)
+ |> should.equal(<<1, 2:4, 3>>)
+ }
+}
+
pub fn concat_test() {
[<<1, 2>>]
|> bit_string.concat
@@ -33,6 +41,14 @@ pub fn concat_test() {
|> should.equal(<<1, 2, 3, 4>>)
}
+if erlang {
+ pub fn concat_erlang_only_test() {
+ [<<1, 2:4>>, <<3>>]
+ |> bit_string.concat
+ |> should.equal(<<1, 2:4, 3>>)
+ }
+}
+
pub fn slice_test() {
<<"hello":utf8>>
|> bit_string.slice(0, 5)