Skip to content

Commit

Permalink
detail: tests for twine
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Aug 15, 2024
1 parent 805aef8 commit ca1d75a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 4 additions & 2 deletions test/twine/t10.expected
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
serialized T10.B {x = 42} is:
[0x0]: C_1(42)
serialized T10.B {x = 42; y = [T10.Bar1]; z = (Some "a")} is:
[0x0]: ["a"] (len=1)
[0x3]: [C_0] (len=1)
[0x5]: C_1(42,@0x3,@0x0)

13 changes: 11 additions & 2 deletions test/twine/t10.ml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
type bar =
| Bar1
| Bar2
[@@deriving eq, show, twine]

type foo =
| A
| B of { x: int }
| B of {
x: int;
y: bar list;
z: string option;
}
[@@deriving twine, eq, show]

let x = B { x = 42 }
let x = B { x = 42; y = [ Bar1 ]; z = Some "a" }
let x_str = Imandrakit_twine.Encode.encode_to_string foo_to_twine x
let x' = Imandrakit_twine.Decode.decode_string foo_of_twine x_str

Expand Down

0 comments on commit ca1d75a

Please sign in to comment.