@nestia/e2e 14.0.1 → 14.0.2
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/ArrayUtil.d.ts +152 -70
- package/lib/ArrayUtil.js +168 -74
- package/lib/ArrayUtil.js.map +1 -1
- package/lib/DynamicExecutor.d.ts +139 -11
- package/lib/DynamicExecutor.js +98 -10
- package/lib/DynamicExecutor.js.map +1 -1
- package/lib/GaffComparator.d.ts +176 -73
- package/lib/GaffComparator.js +189 -76
- package/lib/GaffComparator.js.map +1 -1
- package/lib/MapUtil.d.ts +37 -6
- package/lib/MapUtil.js +37 -6
- package/lib/MapUtil.js.map +1 -1
- package/lib/RandomGenerator.d.ts +157 -84
- package/lib/RandomGenerator.js +173 -89
- package/lib/RandomGenerator.js.map +1 -1
- package/lib/TestValidator.d.ts +248 -74
- package/lib/TestValidator.js +252 -89
- package/lib/TestValidator.js.map +1 -1
- package/lib/internal/json_equal_to.d.ts +21 -0
- package/lib/internal/json_equal_to.js +26 -6
- package/lib/internal/json_equal_to.js.map +1 -1
- package/package.json +3 -2
- package/src/ArrayUtil.ts +172 -76
- package/src/DynamicExecutor.ts +158 -15
- package/src/GaffComparator.ts +187 -77
- package/src/MapUtil.ts +37 -6
- package/src/RandomGenerator.ts +172 -89
- package/src/TestValidator.ts +276 -98
- package/src/internal/json_equal_to.ts +25 -4
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two values through their JSON form and returns the accessors that
|
|
3
|
+
* differ.
|
|
4
|
+
*
|
|
5
|
+
* The comparison walks the keys of the first value, skipping keys whose value
|
|
6
|
+
* is `undefined` and keys the exception predicate accepts, so a key only the
|
|
7
|
+
* second value has is not a difference. Values with a `toJSON` are compared by
|
|
8
|
+
* it, functions are ignored, `null` differs from every object, and arrays must
|
|
9
|
+
* have the same length. An empty result means no difference.
|
|
10
|
+
*
|
|
11
|
+
* Processing cost: The walker traverses the first value and matching
|
|
12
|
+
* second-value positions, recording differing accessors. Object keys and
|
|
13
|
+
* recursion require space proportional to visited structure and depth; toJSON
|
|
14
|
+
* and exception callback costs belong to their implementations. Cyclic inputs
|
|
15
|
+
* are unsupported.
|
|
16
|
+
*
|
|
17
|
+
* @evidence contracts/common.md#principled-implementation Each pair is first read through `toJSON`, then separated by type, by `null`, by array against non-array, and by key walking, so the differences are the accessors where the JSON values differ over the keys of the first value; reading through `toJSON` compares a `Date` by its instant instead of treating every two dates as equal.
|
|
18
|
+
* @evidence contracts/common.md#clear-and-simple-design One curried function with three inner walkers (value, array, object) that append to one accessor list.
|
|
19
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The exception predicate is the caller's, and no key or type name is special-cased.
|
|
20
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the comparison rules and what the result means.
|
|
21
|
+
*/
|
|
1
22
|
export const json_equal_to =
|
|
2
23
|
(exception: (key: string) => boolean) =>
|
|
3
24
|
<T>(x: T) =>
|
|
@@ -20,10 +41,10 @@ export const json_equal_to =
|
|
|
20
41
|
// already was when the two operands were swapped.
|
|
21
42
|
else if (x === null || y === null) {
|
|
22
43
|
if (x !== y) container.push(accessor);
|
|
23
|
-
} else if (x
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
else if (x
|
|
44
|
+
} else if (Array.isArray(x) !== Array.isArray(y))
|
|
45
|
+
container.push(accessor);
|
|
46
|
+
else if (Array.isArray(x)) array(accessor)(x)(y);
|
|
47
|
+
else if (typeof x === "object") object(accessor)(x)(y);
|
|
27
48
|
else if (x !== y) container.push(accessor);
|
|
28
49
|
};
|
|
29
50
|
const array =
|