@kaiko.io/rescript-deser 3.1.3 → 4.0.0-alpha.1
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.
- package/lib/bs/.bsdeps +5 -5
- package/lib/bs/.compiler.log +2 -2
- package/lib/bs/.ninja_log +70 -27
- package/lib/bs/build.ninja +3 -3
- package/lib/bs/src/JSON.ast +0 -0
- package/lib/bs/src/JSON.cmi +0 -0
- package/lib/bs/src/JSON.cmj +0 -0
- package/lib/bs/src/JSON.cmt +0 -0
- package/lib/bs/tests/Appointment.cmt +0 -0
- package/lib/bs/tests/QUnit.ast +0 -0
- package/lib/bs/tests/QUnit.cmi +0 -0
- package/lib/bs/tests/QUnit.cmt +0 -0
- package/lib/bs/tests/Recursive.cmt +0 -0
- package/lib/bs/tests/basic.test.cmt +0 -0
- package/lib/bs/tests/index.ast +0 -0
- package/lib/bs/tests/index.cmi +0 -0
- package/lib/bs/tests/index.cmt +0 -0
- package/lib/bs/tests/old.cmt +0 -0
- package/lib/es6/src/JSON.js +187 -169
- package/lib/es6/tests/index.js +37 -37
- package/lib/js/src/JSON.js +187 -169
- package/lib/js/tests/index.js +37 -37
- package/package.json +3 -3
- package/src/JSON.res +10 -12
package/lib/es6/tests/index.js
CHANGED
|
@@ -6,21 +6,21 @@ import * as Qunit from "qunit";
|
|
|
6
6
|
import * as Prelude from "@kaiko.io/rescript-prelude/lib/es6/src/Prelude.js";
|
|
7
7
|
|
|
8
8
|
var fields = {
|
|
9
|
-
TAG:
|
|
9
|
+
TAG: "Object",
|
|
10
10
|
_0: [
|
|
11
11
|
[
|
|
12
12
|
"note",
|
|
13
|
-
|
|
13
|
+
"String"
|
|
14
14
|
],
|
|
15
15
|
[
|
|
16
16
|
"date",
|
|
17
|
-
|
|
17
|
+
"Date"
|
|
18
18
|
],
|
|
19
19
|
[
|
|
20
20
|
"extra",
|
|
21
21
|
{
|
|
22
|
-
TAG:
|
|
23
|
-
_0:
|
|
22
|
+
TAG: "Optional",
|
|
23
|
+
_0: "String"
|
|
24
24
|
}
|
|
25
25
|
]
|
|
26
26
|
]
|
|
@@ -62,8 +62,8 @@ Qunit.module("Basic deserializer", (function (param) {
|
|
|
62
62
|
Curry._2(Prelude.$$Array.forEach, valid, (function (param) {
|
|
63
63
|
var data = param[0];
|
|
64
64
|
console.log("Running sample", data);
|
|
65
|
-
var result =
|
|
66
|
-
if (result.TAG ===
|
|
65
|
+
var result = Deserializer.fromJSON(data);
|
|
66
|
+
if (result.TAG === "Ok") {
|
|
67
67
|
qunit.deepEqual(result._0, param[1], "result == expected");
|
|
68
68
|
return ;
|
|
69
69
|
}
|
|
@@ -79,8 +79,8 @@ Qunit.module("Basic deserializer", (function (param) {
|
|
|
79
79
|
Curry._2(Prelude.$$Array.forEach, invalid, (function (param) {
|
|
80
80
|
var data = param[1];
|
|
81
81
|
console.log("Running sample", param[0], data);
|
|
82
|
-
var result =
|
|
83
|
-
if (result.TAG ===
|
|
82
|
+
var result = Deserializer.fromJSON(data);
|
|
83
|
+
if (result.TAG === "Ok") {
|
|
84
84
|
console.error("Invalid being accepted: ", result._0);
|
|
85
85
|
return ;
|
|
86
86
|
}
|
|
@@ -92,17 +92,17 @@ Qunit.module("Basic deserializer", (function (param) {
|
|
|
92
92
|
|
|
93
93
|
Qunit.module("Recursive deserializer", (function (param) {
|
|
94
94
|
var fields = {
|
|
95
|
-
TAG:
|
|
95
|
+
TAG: "Object",
|
|
96
96
|
_0: [
|
|
97
97
|
[
|
|
98
98
|
"data",
|
|
99
|
-
|
|
99
|
+
"Any"
|
|
100
100
|
],
|
|
101
101
|
[
|
|
102
102
|
"children",
|
|
103
103
|
{
|
|
104
|
-
TAG:
|
|
105
|
-
_0:
|
|
104
|
+
TAG: "Array",
|
|
105
|
+
_0: "Self"
|
|
106
106
|
}
|
|
107
107
|
]
|
|
108
108
|
]
|
|
@@ -112,7 +112,7 @@ Qunit.module("Recursive deserializer", (function (param) {
|
|
|
112
112
|
});
|
|
113
113
|
var checkFieldsSanity = DeserializerImpl.checkFieldsSanity;
|
|
114
114
|
var fromJSON = function (data) {
|
|
115
|
-
return Curry._2(Prelude.Result.map,
|
|
115
|
+
return Curry._2(Prelude.Result.map, DeserializerImpl.fromJSON(data), (function (prim) {
|
|
116
116
|
return prim;
|
|
117
117
|
}));
|
|
118
118
|
};
|
|
@@ -143,22 +143,22 @@ Qunit.module("Recursive deserializer", (function (param) {
|
|
|
143
143
|
]];
|
|
144
144
|
Qunit.test("Trivial recursion detection: Ok", (function (qunit) {
|
|
145
145
|
qunit.expect(1);
|
|
146
|
-
qunit.deepEqual(
|
|
147
|
-
TAG:
|
|
146
|
+
qunit.deepEqual(checkFieldsSanity(undefined), {
|
|
147
|
+
TAG: "Ok",
|
|
148
148
|
_0: undefined
|
|
149
149
|
}, "Ok");
|
|
150
150
|
}));
|
|
151
151
|
Qunit.test("Infinite list", (function (qunit) {
|
|
152
152
|
var fields = {
|
|
153
|
-
TAG:
|
|
153
|
+
TAG: "Object",
|
|
154
154
|
_0: [
|
|
155
155
|
[
|
|
156
156
|
"head",
|
|
157
|
-
|
|
157
|
+
"String"
|
|
158
158
|
],
|
|
159
159
|
[
|
|
160
160
|
"tail",
|
|
161
|
-
|
|
161
|
+
"Self"
|
|
162
162
|
]
|
|
163
163
|
]
|
|
164
164
|
};
|
|
@@ -166,21 +166,21 @@ Qunit.module("Recursive deserializer", (function (param) {
|
|
|
166
166
|
fields: fields
|
|
167
167
|
});
|
|
168
168
|
qunit.expect(1);
|
|
169
|
-
qunit.deepEqual(Curry._1(Prelude.Result.isError,
|
|
169
|
+
qunit.deepEqual(Curry._1(Prelude.Result.isError, InfiniteList.checkFieldsSanity(undefined)), true, "Ok");
|
|
170
170
|
}));
|
|
171
171
|
Qunit.test("Finite list", (function (qunit) {
|
|
172
172
|
var fields = {
|
|
173
|
-
TAG:
|
|
173
|
+
TAG: "Object",
|
|
174
174
|
_0: [
|
|
175
175
|
[
|
|
176
176
|
"head",
|
|
177
|
-
|
|
177
|
+
"String"
|
|
178
178
|
],
|
|
179
179
|
[
|
|
180
180
|
"tail",
|
|
181
181
|
{
|
|
182
|
-
TAG:
|
|
183
|
-
_0:
|
|
182
|
+
TAG: "Optional",
|
|
183
|
+
_0: "Self"
|
|
184
184
|
}
|
|
185
185
|
]
|
|
186
186
|
]
|
|
@@ -189,8 +189,8 @@ Qunit.module("Recursive deserializer", (function (param) {
|
|
|
189
189
|
fields: fields
|
|
190
190
|
});
|
|
191
191
|
qunit.expect(1);
|
|
192
|
-
qunit.deepEqual(
|
|
193
|
-
TAG:
|
|
192
|
+
qunit.deepEqual(List.checkFieldsSanity(undefined), {
|
|
193
|
+
TAG: "Ok",
|
|
194
194
|
_0: undefined
|
|
195
195
|
}, "Ok");
|
|
196
196
|
}));
|
|
@@ -200,7 +200,7 @@ Qunit.module("Recursive deserializer", (function (param) {
|
|
|
200
200
|
var data = param[0];
|
|
201
201
|
console.log("Running sample", data);
|
|
202
202
|
var result = fromJSON(data);
|
|
203
|
-
if (result.TAG ===
|
|
203
|
+
if (result.TAG === "Ok") {
|
|
204
204
|
qunit.deepEqual(result._0, param[1], "result == expected");
|
|
205
205
|
return ;
|
|
206
206
|
}
|
|
@@ -209,17 +209,17 @@ Qunit.module("Recursive deserializer", (function (param) {
|
|
|
209
209
|
}));
|
|
210
210
|
Qunit.test("Recursion in sub-deserializer", (function (qunit) {
|
|
211
211
|
var fields = {
|
|
212
|
-
TAG:
|
|
212
|
+
TAG: "Object",
|
|
213
213
|
_0: [
|
|
214
214
|
[
|
|
215
215
|
"head",
|
|
216
|
-
|
|
216
|
+
"String"
|
|
217
217
|
],
|
|
218
218
|
[
|
|
219
219
|
"tail",
|
|
220
220
|
{
|
|
221
|
-
TAG:
|
|
222
|
-
_0:
|
|
221
|
+
TAG: "Optional",
|
|
222
|
+
_0: "Self"
|
|
223
223
|
}
|
|
224
224
|
]
|
|
225
225
|
]
|
|
@@ -228,20 +228,20 @@ Qunit.module("Recursive deserializer", (function (param) {
|
|
|
228
228
|
fields: fields
|
|
229
229
|
});
|
|
230
230
|
var fields$1 = {
|
|
231
|
-
TAG:
|
|
231
|
+
TAG: "Object",
|
|
232
232
|
_0: [
|
|
233
233
|
[
|
|
234
234
|
"records",
|
|
235
235
|
{
|
|
236
|
-
TAG:
|
|
236
|
+
TAG: "Deserializer",
|
|
237
237
|
_0: List
|
|
238
238
|
}
|
|
239
239
|
],
|
|
240
240
|
[
|
|
241
241
|
"next",
|
|
242
242
|
{
|
|
243
|
-
TAG:
|
|
244
|
-
_0:
|
|
243
|
+
TAG: "Optional",
|
|
244
|
+
_0: "Self"
|
|
245
245
|
}
|
|
246
246
|
]
|
|
247
247
|
]
|
|
@@ -271,8 +271,8 @@ Qunit.module("Recursive deserializer", (function (param) {
|
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
273
|
qunit.expect(1);
|
|
274
|
-
qunit.deepEqual(
|
|
275
|
-
TAG:
|
|
274
|
+
qunit.deepEqual(Ledger.fromJSON(data), {
|
|
275
|
+
TAG: "Ok",
|
|
276
276
|
_0: expected
|
|
277
277
|
}, "nice ledger");
|
|
278
278
|
}));
|