aboutsummaryrefslogtreecommitdiff
path: root/test/atom_test.gleam
blob: 60686ab7f8c3769fe38dcd9f85e502f206284cef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import atom
import expect

pub fn from_string_test() {
  "ok"
  |> atom:from_string
  |> expect:is_ok

  "expect"
  |> atom:from_string
  |> expect:is_ok

  "this is not an atom we have seen before"
  |> atom:from_string
  // |> expect:equal(_, Error(AtomNotLoaded))
  |> expect:is_error
}

pub fn create_from_string_test() {
  "ok"
  |> atom:create_from_string
  |> Ok
  |> expect:equal(_, atom:from_string("ok"))

  "expect"
  |> atom:create_from_string
  |> Ok
  |> expect:equal(_, atom:from_string("expect"))

  "this is another atom we have not seen before"
  |> atom:create_from_string
  |> Ok
  |> expect:equal(_, atom:from_string("this is another atom we have not seen before"))
}

pub fn to_string_test() {
  "ok"
  |> atom:create_from_string
  |> atom:to_string
  |> expect:equal(_, "ok")

  "expect"
  |> atom:create_from_string
  |> atom:to_string
  |> expect:equal(_, "expect")
}