aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2021-09-09 20:30:04 +0100
committerLouis Pilfold <louis@lpil.uk>2021-09-09 20:30:04 +0100
commit70136ec67863b0c97b9845edc13c6841eee033fc (patch)
tree5b0d429aa415ad8321a2d0bdea01b6184f638f56 /test
parent749ac8290d1e3d09e2287056f618d6df91f4e01b (diff)
downloadgleam_stdlib-70136ec67863b0c97b9845edc13c6841eee033fc.tar.gz
gleam_stdlib-70136ec67863b0c97b9845edc13c6841eee033fc.zip
JS dynamic bit string
Diffstat (limited to 'test')
-rw-r--r--test/gleam/dynamic_test.gleam49
1 files changed, 29 insertions, 20 deletions
diff --git a/test/gleam/dynamic_test.gleam b/test/gleam/dynamic_test.gleam
index 3229e3d..c65f98c 100644
--- a/test/gleam/dynamic_test.gleam
+++ b/test/gleam/dynamic_test.gleam
@@ -1,38 +1,42 @@
import gleam/should
import gleam/dynamic.{DecodeError}
+import gleam/bit_string
if erlang {
- import gleam/bit_string
import gleam/list
import gleam/result
import gleam/map
import gleam/option.{None, Some}
+}
- pub fn bit_string_test() {
- ""
- |> dynamic.from
- |> dynamic.bit_string
- |> should.equal(Ok(<<"":utf8>>))
+pub fn bit_string_test() {
+ <<>>
+ |> dynamic.from
+ |> dynamic.bit_string
+ |> should.equal(Ok(<<>>))
- "Hello"
- |> dynamic.from
- |> dynamic.bit_string
- |> should.equal(Ok(<<"Hello":utf8>>))
+ <<"Hello":utf8>>
+ |> dynamic.from
+ |> dynamic.bit_string
+ |> should.equal(Ok(<<"Hello":utf8>>))
- <<65535:16>>
- |> dynamic.from
- |> dynamic.bit_string
- |> should.equal(Ok(<<65535:16>>))
+ 1
+ |> dynamic.from
+ |> dynamic.bit_string
+ |> should.equal(Error(DecodeError(expected: "BitString", found: "Int")))
- 1
- |> dynamic.from
- |> dynamic.bit_string
- |> should.equal(Error(DecodeError(expected: "BitString", found: "Int")))
+ []
+ |> dynamic.from
+ |> dynamic.bit_string
+ |> should.equal(Error(DecodeError(expected: "BitString", found: "List")))
+}
- []
+if erlang {
+ pub fn bit_string_erlang_test() {
+ <<65535:16>>
|> dynamic.from
|> dynamic.bit_string
- |> should.equal(Error(DecodeError(expected: "BitString", found: "List")))
+ |> should.equal(Ok(<<65535:16>>))
}
}
@@ -82,6 +86,11 @@ pub fn int_test() {
|> dynamic.from
|> dynamic.int
|> should.equal(Error(DecodeError(expected: "Int", found: "List")))
+
+ <<1>>
+ |> dynamic.from
+ |> dynamic.int
+ |> should.equal(Error(DecodeError(expected: "Int", found: "BitString")))
}
pub fn float_test() {