@greenlabs/ppx-spice 0.1.8-rc1 → 0.1.9-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +6 -2
  2. package/README.md +4 -0
  3. package/docs/GUIDE.md +139 -0
  4. package/package.json +1 -1
  5. package/ppx-windows.exe +0 -0
  6. package/.github/workflows/build_linux.yml +0 -41
  7. package/.github/workflows/build_macos.yml +0 -41
  8. package/.github/workflows/build_windows.yml +0 -41
  9. package/.github/workflows/print_esy_cache.js +0 -13
  10. package/.github/workflows/publish.yml +0 -161
  11. package/.github/workflows/publish_prerelease.yml +0 -177
  12. package/.vscode/settings.json +0 -6
  13. package/src/.ocamlformat +0 -0
  14. package/src/bin/bin.ml +0 -1
  15. package/src/bin/dune +0 -5
  16. package/src/dune +0 -1
  17. package/src/dune-project +0 -2
  18. package/src/dune-workspace +0 -3
  19. package/src/esy.lock/.gitattributes +0 -3
  20. package/src/esy.lock/.gitignore +0 -3
  21. package/src/esy.lock/index.json +0 -1196
  22. package/src/esy.lock/opam/astring.0.8.5/opam +0 -37
  23. package/src/esy.lock/opam/base-bytes.base/opam +0 -9
  24. package/src/esy.lock/opam/base-threads.base/opam +0 -6
  25. package/src/esy.lock/opam/base-unix.base/opam +0 -6
  26. package/src/esy.lock/opam/base.v0.14.1/opam +0 -36
  27. package/src/esy.lock/opam/biniou.1.2.1/opam +0 -45
  28. package/src/esy.lock/opam/cmdliner.1.0.4/opam +0 -36
  29. package/src/esy.lock/opam/cppo.1.6.8/opam +0 -37
  30. package/src/esy.lock/opam/csexp.1.5.1/opam +0 -60
  31. package/src/esy.lock/opam/dot-merlin-reader.4.1/opam +0 -30
  32. package/src/esy.lock/opam/dune-build-info.2.9.1/opam +0 -42
  33. package/src/esy.lock/opam/dune-configurator.2.9.1/opam +0 -47
  34. package/src/esy.lock/opam/dune.2.9.1/opam +0 -58
  35. package/src/esy.lock/opam/easy-format.1.3.2/opam +0 -46
  36. package/src/esy.lock/opam/fix.20201120/opam +0 -24
  37. package/src/esy.lock/opam/fpath.0.7.3/opam +0 -36
  38. package/src/esy.lock/opam/menhir.20211012/opam +0 -28
  39. package/src/esy.lock/opam/menhirLib.20211012/opam +0 -29
  40. package/src/esy.lock/opam/menhirSdk.20211012/opam +0 -29
  41. package/src/esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam +0 -39
  42. package/src/esy.lock/opam/ocaml-lsp-server.1.8.3/opam +0 -54
  43. package/src/esy.lock/opam/ocamlbuild.0.14.0/opam +0 -36
  44. package/src/esy.lock/opam/ocamlfind.1.9.1/opam +0 -44
  45. package/src/esy.lock/opam/ocamlformat-rpc-lib.0.18.0/opam +0 -40
  46. package/src/esy.lock/opam/ocamlformat.0.19.0/opam +0 -55
  47. package/src/esy.lock/opam/ocp-indent.1.8.1/opam +0 -57
  48. package/src/esy.lock/opam/odoc-parser.0.9.0/opam +0 -45
  49. package/src/esy.lock/opam/pp.1.1.2/opam +0 -58
  50. package/src/esy.lock/opam/ppx_derivers.1.2.1/opam +0 -23
  51. package/src/esy.lock/opam/ppx_yojson_conv_lib.v0.14.0/opam +0 -24
  52. package/src/esy.lock/opam/ppxlib.0.23.0/opam +0 -62
  53. package/src/esy.lock/opam/re.1.10.3/opam +0 -46
  54. package/src/esy.lock/opam/result.1.5/opam +0 -22
  55. package/src/esy.lock/opam/seq.base/files/META.seq +0 -4
  56. package/src/esy.lock/opam/seq.base/files/seq.install +0 -3
  57. package/src/esy.lock/opam/seq.base/opam +0 -15
  58. package/src/esy.lock/opam/sexplib0.v0.14.0/opam +0 -26
  59. package/src/esy.lock/opam/stdio.v0.14.0/opam +0 -27
  60. package/src/esy.lock/opam/stdlib-shims.0.3.0/opam +0 -31
  61. package/src/esy.lock/opam/topkg.1.0.4/opam +0 -44
  62. package/src/esy.lock/opam/uchar.0.0.2/opam +0 -36
  63. package/src/esy.lock/opam/uucp.14.0.0/opam +0 -41
  64. package/src/esy.lock/opam/uuseg.14.0.0/opam +0 -43
  65. package/src/esy.lock/opam/uutf.1.0.2/opam +0 -40
  66. package/src/esy.lock/opam/yojson.1.7.0/opam +0 -38
  67. package/src/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/files/ocamlbuild-0.14.0.patch +0 -463
  68. package/src/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/package.json +0 -27
  69. package/src/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.1_opam_override/files/findlib-1.9.1.patch +0 -471
  70. package/src/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.1_opam_override/package.json +0 -61
  71. package/src/ppx/codecs.ml +0 -120
  72. package/src/ppx/decode_cases.ml +0 -18
  73. package/src/ppx/dune +0 -9
  74. package/src/ppx/polyvariants.ml +0 -288
  75. package/src/ppx/ppx_spice.ml +0 -19
  76. package/src/ppx/records.ml +0 -163
  77. package/src/ppx/signature.ml +0 -86
  78. package/src/ppx/structure.ml +0 -109
  79. package/src/ppx/tuple.ml +0 -68
  80. package/src/ppx/utils.ml +0 -117
  81. package/src/ppx/variants.ml +0 -257
  82. package/src/ppx_spice.opam +0 -21
  83. package/test/__tests__/test_optional_field_records.js +0 -91
  84. package/test/__tests__/test_optional_field_records.res +0 -98
  85. package/test/__tests__/test_polyvariants.js +0 -57
  86. package/test/__tests__/test_polyvariants.res +0 -41
  87. package/test/__tests__/test_records.js +0 -100
  88. package/test/__tests__/test_records.res +0 -111
  89. package/test/__tests__/test_variants.js +0 -85
  90. package/test/__tests__/test_variants.res +0 -63
  91. package/test/bsconfig.json +0 -27
  92. package/test/package.json +0 -18
  93. package/test/src/OptionalFieldRecords.js +0 -237
  94. package/test/src/OptionalFieldRecords.res +0 -23
  95. package/test/src/Polyvariants.js +0 -94
  96. package/test/src/Polyvariants.res +0 -5
  97. package/test/src/Polyvariants.resi +0 -5
  98. package/test/src/Records.js +0 -186
  99. package/test/src/Records.res +0 -17
  100. package/test/src/Records.resi +0 -17
  101. package/test/src/Spice.js +0 -448
  102. package/test/src/Spice_Codecs.js +0 -57
  103. package/test/src/Variants.js +0 -115
  104. package/test/src/Variants.res +0 -11
  105. package/test/src/Variants.resi +0 -11
  106. package/test/yarn.lock +0 -4194
@@ -1,57 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
- 'use strict';
3
-
4
- var Jest = require("@glennsl/bs-jest/src/jest.js");
5
- var Polyvariants = require("../src/Polyvariants.js");
6
-
7
- Jest.describe("polymorphic variants with attribute", (function (param) {
8
- Jest.test("encode 하나", (function (param) {
9
- var polyvariantEncoded = Polyvariants.t_encode("one");
10
- return Jest.Expect.toEqual("하나", Jest.Expect.expect(polyvariantEncoded));
11
- }));
12
- Jest.test("encode 둘", (function (param) {
13
- var polyvariantEncoded = Polyvariants.t_encode("two");
14
- return Jest.Expect.toEqual("둘", Jest.Expect.expect(polyvariantEncoded));
15
- }));
16
- Jest.test("decode 하나", (function (param) {
17
- var polyvariantDecoded = Polyvariants.t_decode("하나");
18
- return Jest.Expect.toEqual({
19
- TAG: /* Ok */0,
20
- _0: "one"
21
- }, Jest.Expect.expect(polyvariantDecoded));
22
- }));
23
- Jest.test("decode 둘", (function (param) {
24
- var polyvariantDecoded = Polyvariants.t_decode("둘");
25
- return Jest.Expect.toEqual({
26
- TAG: /* Ok */0,
27
- _0: "two"
28
- }, Jest.Expect.expect(polyvariantDecoded));
29
- }));
30
- }));
31
-
32
- Jest.describe("polymorphic variants", (function (param) {
33
- Jest.test("encode #one", (function (param) {
34
- var polyvariantEncoded = Polyvariants.t1_encode("one");
35
- return Jest.Expect.toEqual(["one"], Jest.Expect.expect(polyvariantEncoded));
36
- }));
37
- Jest.test("encode #two", (function (param) {
38
- var polyvariantEncoded = Polyvariants.t1_encode("two");
39
- return Jest.Expect.toEqual(["two"], Jest.Expect.expect(polyvariantEncoded));
40
- }));
41
- Jest.test("decode one", (function (param) {
42
- var polyvariantDecoded = Polyvariants.t1_decode(["one"]);
43
- return Jest.Expect.toEqual({
44
- TAG: /* Ok */0,
45
- _0: "one"
46
- }, Jest.Expect.expect(polyvariantDecoded));
47
- }));
48
- Jest.test("decode two", (function (param) {
49
- var polyvariantDecoded = Polyvariants.t1_decode(["two"]);
50
- return Jest.Expect.toEqual({
51
- TAG: /* Ok */0,
52
- _0: "two"
53
- }, Jest.Expect.expect(polyvariantDecoded));
54
- }));
55
- }));
56
-
57
- /* Not a pure module */
@@ -1,41 +0,0 @@
1
- open Jest
2
- open Expect
3
- // open Belt
4
-
5
- describe("polymorphic variants with attribute", _ => {
6
- test("encode 하나", _ => {
7
- let polyvariantEncoded = #one->Polyvariants.t_encode
8
- expect(polyvariantEncoded) |> toEqual(Js.Json.string(`하나`))
9
- })
10
- test("encode 둘", _ => {
11
- let polyvariantEncoded = #two->Polyvariants.t_encode
12
- expect(polyvariantEncoded) |> toEqual(Js.Json.string(`둘`))
13
- })
14
- test("decode 하나", _ => {
15
- let polyvariantDecoded = Js.Json.string(`하나`)->Polyvariants.t_decode
16
- expect(polyvariantDecoded) |> toEqual(Ok(#one))
17
- })
18
- test("decode 둘", _ => {
19
- let polyvariantDecoded = Js.Json.string(`둘`)->Polyvariants.t_decode
20
- expect(polyvariantDecoded) |> toEqual(Ok(#two))
21
- })
22
- })
23
-
24
- describe("polymorphic variants", _ => {
25
- test(`encode #one`, _ => {
26
- let polyvariantEncoded = #one->Polyvariants.t1_encode
27
- expect(polyvariantEncoded) |> toEqual(Js.Json.array([Js.Json.string(`one`)]))
28
- })
29
- test(`encode #two`, _ => {
30
- let polyvariantEncoded = #two->Polyvariants.t1_encode
31
- expect(polyvariantEncoded) |> toEqual(Js.Json.array([Js.Json.string(`two`)]))
32
- })
33
- test(`decode one`, _ => {
34
- let polyvariantDecoded = Js.Json.array([Js.Json.string(`one`)])->Polyvariants.t1_decode
35
- expect(polyvariantDecoded) |> toEqual(Ok(#one))
36
- })
37
- test(`decode two`, _ => {
38
- let polyvariantDecoded = Js.Json.array([Js.Json.string(`two`)])->Polyvariants.t1_decode
39
- expect(polyvariantDecoded) |> toEqual(Ok(#two))
40
- })
41
- })
@@ -1,100 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
- 'use strict';
3
-
4
- var Jest = require("@glennsl/bs-jest/src/jest.js");
5
- var Records = require("../src/Records.js");
6
-
7
- Jest.describe("record with @spice.key", (function (param) {
8
- var sample = {};
9
- sample["spice-label"] = "sample";
10
- sample["spice-value"] = 1.0;
11
- var sampleRecord = {
12
- label: "sample",
13
- value: 1
14
- };
15
- Jest.test("encode", (function (param) {
16
- var encoded = Records.t_encode(sampleRecord);
17
- return Jest.Expect.toEqual(sample, Jest.Expect.expect(encoded));
18
- }));
19
- Jest.test("decode", (function (param) {
20
- var decoded = Records.t_decode(sample);
21
- return Jest.Expect.toEqual({
22
- TAG: /* Ok */0,
23
- _0: sampleRecord
24
- }, Jest.Expect.expect(decoded));
25
- }));
26
- }));
27
-
28
- Jest.describe("record without @spice.key", (function (param) {
29
- var sample = {};
30
- sample["label"] = "sample";
31
- sample["value"] = 1.0;
32
- var sampleRecord = {
33
- label: "sample",
34
- value: 1
35
- };
36
- Jest.test("encode", (function (param) {
37
- var encoded = Records.t1_encode(sampleRecord);
38
- return Jest.Expect.toEqual(sample, Jest.Expect.expect(encoded));
39
- }));
40
- Jest.test("decode", (function (param) {
41
- var decoded = Records.t1_decode(sample);
42
- return Jest.Expect.toEqual({
43
- TAG: /* Ok */0,
44
- _0: sampleRecord
45
- }, Jest.Expect.expect(decoded));
46
- }));
47
- }));
48
-
49
- Jest.describe("record with optional field", (function (param) {
50
- var sample1 = {};
51
- sample1["label"] = "sample";
52
- sample1["value"] = 1.0;
53
- var sampleRecord1 = {
54
- label: "sample",
55
- value: 1
56
- };
57
- Jest.test("encode", (function (param) {
58
- var encoded = Records.tOp_encode(sampleRecord1);
59
- return Jest.Expect.toEqual(sample1, Jest.Expect.expect(encoded));
60
- }));
61
- Jest.test("decode", (function (param) {
62
- var decoded = Records.tOp_decode(sample1);
63
- return Jest.Expect.toEqual({
64
- TAG: /* Ok */0,
65
- _0: sampleRecord1
66
- }, Jest.Expect.expect(decoded));
67
- }));
68
- var sample2 = {};
69
- sample2["label"] = "sample";
70
- var sampleRecord2 = {
71
- label: "sample"
72
- };
73
- Jest.test("encode omit optional field", (function (param) {
74
- var encoded = Records.tOp_encode(sampleRecord2);
75
- return Jest.Expect.toEqual(sample2, Jest.Expect.expect(encoded));
76
- }));
77
- Jest.test("decode omit optional field", (function (param) {
78
- var decoded = Records.tOp_decode(sample2);
79
- return Jest.Expect.toEqual({
80
- TAG: /* Ok */0,
81
- _0: sampleRecord2
82
- }, Jest.Expect.expect(decoded));
83
- }));
84
- var sample3 = {};
85
- sample3["label"] = null;
86
- var sampleRecord3 = {};
87
- Jest.test("encode omit optional field with None field", (function (param) {
88
- var encoded = Records.tOp_encode(sampleRecord3);
89
- return Jest.Expect.toEqual(sample3, Jest.Expect.expect(encoded));
90
- }));
91
- Jest.test("decode omit optional field with None field", (function (param) {
92
- var decoded = Records.tOp_decode(sample3);
93
- return Jest.Expect.toEqual({
94
- TAG: /* Ok */0,
95
- _0: sampleRecord3
96
- }, Jest.Expect.expect(decoded));
97
- }));
98
- }));
99
-
100
- /* Not a pure module */
@@ -1,111 +0,0 @@
1
- open Jest
2
- open Expect
3
- // open Belt
4
-
5
- describe("record with @spice.key", _ => {
6
- open Records
7
-
8
- let sample = Js.Dict.empty()
9
- sample->Js.Dict.set("spice-label", Js.Json.string("sample"))
10
- sample->Js.Dict.set("spice-value", Js.Json.number(1.0))
11
- let sampleJson = sample->Js.Json.object_
12
-
13
- let sampleRecord: t = {
14
- label: "sample",
15
- value: 1,
16
- }
17
-
18
- test(`encode`, _ => {
19
- let encoded = sampleRecord->Records.t_encode
20
- expect(encoded) |> toEqual(sampleJson)
21
- })
22
-
23
- test(`decode`, _ => {
24
- let decoded = sampleJson->Records.t_decode
25
- expect(decoded) |> toEqual(Belt.Result.Ok(sampleRecord))
26
- })
27
- })
28
-
29
- describe("record without @spice.key", _ => {
30
- open Records
31
-
32
- let sample = Js.Dict.empty()
33
- sample->Js.Dict.set("label", Js.Json.string("sample"))
34
- sample->Js.Dict.set("value", Js.Json.number(1.0))
35
- let sampleJson = sample->Js.Json.object_
36
-
37
- let sampleRecord: t1 = {
38
- label: "sample",
39
- value: 1,
40
- }
41
-
42
- test(`encode`, _ => {
43
- let encoded = sampleRecord->t1_encode
44
- expect(encoded) |> toEqual(sampleJson)
45
- })
46
-
47
- test(`decode`, _ => {
48
- let decoded = sampleJson->Records.t1_decode
49
- expect(decoded) |> toEqual(Belt.Result.Ok(sampleRecord))
50
- })
51
- })
52
-
53
- describe("record with optional field", _ => {
54
- open Records
55
-
56
- let sample1 = Js.Dict.empty()
57
- sample1->Js.Dict.set("label", Js.Json.string("sample"))
58
- sample1->Js.Dict.set("value", Js.Json.number(1.0))
59
- let sampleJson1 = sample1->Js.Json.object_
60
-
61
- let sampleRecord1: tOp = {
62
- label: Some("sample"),
63
- value: 1,
64
- }
65
-
66
- test(`encode`, _ => {
67
- let encoded = sampleRecord1->tOp_encode
68
- expect(encoded) |> toEqual(sampleJson1)
69
- })
70
-
71
- test(`decode`, _ => {
72
- let decoded = sampleJson1->Records.tOp_decode
73
- expect(decoded) |> toEqual(Belt.Result.Ok(sampleRecord1))
74
- })
75
-
76
- let sample2 = Js.Dict.empty()
77
- sample2->Js.Dict.set("label", Js.Json.string("sample"))
78
- let sampleJson2 = sample2->Js.Json.object_
79
-
80
- let sampleRecord2: tOp = {
81
- label: Some("sample"),
82
- }
83
-
84
- test(`encode omit optional field`, _ => {
85
- let encoded = sampleRecord2->tOp_encode
86
- expect(encoded) |> toEqual(sampleJson2)
87
- })
88
-
89
- test(`decode omit optional field`, _ => {
90
- let decoded = sampleJson2->Records.tOp_decode
91
- expect(decoded) |> toEqual(Belt.Result.Ok(sampleRecord2))
92
- })
93
-
94
- let sample3 = Js.Dict.empty()
95
- sample3->Js.Dict.set("label", Js.Json.null)
96
- let sampleJson3 = sample3->Js.Json.object_
97
-
98
- let sampleRecord3: tOp = {
99
- label: None,
100
- }
101
-
102
- test(`encode omit optional field with None field`, _ => {
103
- let encoded = sampleRecord3->tOp_encode
104
- expect(encoded) |> toEqual(sampleJson3)
105
- })
106
-
107
- test(`decode omit optional field with None field`, _ => {
108
- let decoded = sampleJson3->Records.tOp_decode
109
- expect(decoded) |> toEqual(Belt.Result.Ok(sampleRecord3))
110
- })
111
- })
@@ -1,85 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
- 'use strict';
3
-
4
- var Jest = require("@glennsl/bs-jest/src/jest.js");
5
- var Variants = require("../src/Variants.js");
6
-
7
- Jest.describe("variants with @spice.as", (function (param) {
8
- Jest.test("encode 하나", (function (param) {
9
- var variantEncoded = Variants.t_encode(/* One */0);
10
- return Jest.Expect.toEqual("하나", Jest.Expect.expect(variantEncoded));
11
- }));
12
- Jest.test("encode 둘", (function (param) {
13
- var variantEncoded = Variants.t_encode(/* Two */1);
14
- return Jest.Expect.toEqual("둘", Jest.Expect.expect(variantEncoded));
15
- }));
16
- Jest.test("decode 하나", (function (param) {
17
- var variantDecoded = Variants.t_decode("하나");
18
- return Jest.Expect.toEqual({
19
- TAG: /* Ok */0,
20
- _0: /* One */0
21
- }, Jest.Expect.expect(variantDecoded));
22
- }));
23
- Jest.test("decode 둘", (function (param) {
24
- var variantDecoded = Variants.t_decode("둘");
25
- return Jest.Expect.toEqual({
26
- TAG: /* Ok */0,
27
- _0: /* Two */1
28
- }, Jest.Expect.expect(variantDecoded));
29
- }));
30
- }));
31
-
32
- Jest.describe("variants without @spice.as", (function (param) {
33
- Jest.test("encode One1", (function (param) {
34
- var variantEncoded = Variants.t1_encode(/* One1 */0);
35
- return Jest.Expect.toEqual(["One1"], Jest.Expect.expect(variantEncoded));
36
- }));
37
- Jest.test("encode Two1", (function (param) {
38
- var variantEncoded = Variants.t1_encode(/* Two1 */1);
39
- return Jest.Expect.toEqual(["Two1"], Jest.Expect.expect(variantEncoded));
40
- }));
41
- Jest.test("decode [\"One1\"]", (function (param) {
42
- var variantDecoded = Variants.t1_decode(["One1"]);
43
- return Jest.Expect.toEqual({
44
- TAG: /* Ok */0,
45
- _0: /* One1 */0
46
- }, Jest.Expect.expect(variantDecoded));
47
- }));
48
- Jest.test("decode [\"Two1\"]", (function (param) {
49
- var variantDecoded = Variants.t1_decode(["Two1"]);
50
- return Jest.Expect.toEqual({
51
- TAG: /* Ok */0,
52
- _0: /* Two1 */1
53
- }, Jest.Expect.expect(variantDecoded));
54
- }));
55
- }));
56
-
57
- Jest.describe("unboxed variants with @spice.as", (function (param) {
58
- Jest.test("encode 하나", (function (param) {
59
- var variantEncoded = Variants.t2_encode(0);
60
- return Jest.Expect.toEqual(0.0, Jest.Expect.expect(variantEncoded));
61
- }));
62
- Jest.test("decode 하나", (function (param) {
63
- var variantDecoded = Variants.t2_decode(0.0);
64
- return Jest.Expect.toEqual({
65
- TAG: /* Ok */0,
66
- _0: 0
67
- }, Jest.Expect.expect(variantDecoded));
68
- }));
69
- }));
70
-
71
- Jest.describe("unboxed variants without @spice.as", (function (param) {
72
- Jest.test("encode One3(0)", (function (param) {
73
- var variantEncoded = Variants.t3_encode(0);
74
- return Jest.Expect.toEqual(0.0, Jest.Expect.expect(variantEncoded));
75
- }));
76
- Jest.test("decode 0", (function (param) {
77
- var variantDecoded = Variants.t3_decode(0.0);
78
- return Jest.Expect.toEqual({
79
- TAG: /* Ok */0,
80
- _0: 0
81
- }, Jest.Expect.expect(variantDecoded));
82
- }));
83
- }));
84
-
85
- /* Not a pure module */
@@ -1,63 +0,0 @@
1
- open Jest
2
- open Expect
3
- // open Belt
4
-
5
- describe("variants with @spice.as", _ => {
6
- test(`encode 하나`, _ => {
7
- let variantEncoded = Variants.One->Variants.t_encode
8
- expect(variantEncoded) |> toEqual(Js.Json.string(`하나`))
9
- })
10
- test(`encode 둘`, _ => {
11
- let variantEncoded = Variants.Two->Variants.t_encode
12
- expect(variantEncoded) |> toEqual(Js.Json.string(`둘`))
13
- })
14
- test(`decode 하나`, _ => {
15
- let variantDecoded = Js.Json.string(`하나`)->Variants.t_decode
16
- expect(variantDecoded) |> toEqual(Ok(Variants.One))
17
- })
18
- test(`decode 둘`, _ => {
19
- let variantDecoded = Js.Json.string(`둘`)->Variants.t_decode
20
- expect(variantDecoded) |> toEqual(Ok(Variants.Two))
21
- })
22
- })
23
-
24
- describe(`variants without @spice.as`, _ => {
25
- test(`encode One1`, _ => {
26
- let variantEncoded = Variants.One1->Variants.t1_encode
27
- expect(variantEncoded) |> toEqual(Js.Json.array([Js.Json.string(`One1`)]))
28
- })
29
- test(`encode Two1`, _ => {
30
- let variantEncoded = Variants.Two1->Variants.t1_encode
31
- expect(variantEncoded) |> toEqual(Js.Json.array([Js.Json.string(`Two1`)]))
32
- })
33
- test(`decode ["One1"]`, _ => {
34
- let variantDecoded = Js.Json.array([Js.Json.string(`One1`)])->Variants.t1_decode
35
- expect(variantDecoded) |> toEqual(Ok(Variants.One1))
36
- })
37
- test(`decode ["Two1"]`, _ => {
38
- let variantDecoded = Js.Json.array([Js.Json.string(`Two1`)])->Variants.t1_decode
39
- expect(variantDecoded) |> toEqual(Ok(Variants.Two1))
40
- })
41
- })
42
-
43
- describe("unboxed variants with @spice.as", _ => {
44
- test(`encode 하나`, _ => {
45
- let variantEncoded = Variants.One2(0)->Variants.t2_encode
46
- expect(variantEncoded) |> toEqual(Js.Json.number(0.0))
47
- })
48
- test(`decode 하나`, _ => {
49
- let variantDecoded = Js.Json.number(0.0)->Variants.t2_decode
50
- expect(variantDecoded) |> toEqual(Ok(Variants.One2(0)))
51
- })
52
- })
53
-
54
- describe(`unboxed variants without @spice.as`, _ => {
55
- test(`encode One3(0)`, _ => {
56
- let variantEncoded = Variants.One3(0)->Variants.t3_encode
57
- expect(variantEncoded) |> toEqual(Js.Json.number(0.0))
58
- })
59
- test(`decode 0`, _ => {
60
- let variantDecoded = Js.Json.number(0.0)->Variants.t3_decode
61
- expect(variantDecoded) |> toEqual(Ok(Variants.One3(0)))
62
- })
63
- })
@@ -1,27 +0,0 @@
1
- {
2
- "name": "spice-ppx",
3
- "sources": [
4
- {
5
- "dir": "__tests__",
6
- "type": "dev"
7
- },
8
- {
9
- "dir": "src"
10
- }
11
- ],
12
- "package-specs": [
13
- {
14
- "module": "commonjs",
15
- "in-source": true
16
- }
17
- ],
18
- "bs-dependencies": [],
19
- "bs-dev-dependencies": ["@glennsl/bs-jest"],
20
- "ppx-flags": ["../ppx"],
21
- "warnings": {
22
- "error": true,
23
- "number": "-48"
24
- },
25
- "generators": [],
26
- "bsc-flags": ["-bs-super-errors"]
27
- }
package/test/package.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "name": "spice-ppx-test",
3
- "version": "1.0.0",
4
- "description": "Test spice ppx",
5
- "license": "MIT",
6
- "devDependencies": {
7
- "@glennsl/bs-jest": "^0.7.0",
8
- "jest": "^27.3.1",
9
- "rescript": "^10.0.1"
10
- },
11
- "scripts": {
12
- "res:build": "rescript",
13
- "res:clean": "rescript clean",
14
- "res:watch": "rescript build -w",
15
- "test": "jest",
16
- "test:watch": "jest --watchAll"
17
- }
18
- }