@libraz/coverwise 1.0.0
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/LICENSE +191 -0
- package/README.md +119 -0
- package/README.npm.md +119 -0
- package/dist/coverwise.js +2 -0
- package/dist/coverwise.wasm +0 -0
- package/dist/js/constraint.d.ts +78 -0
- package/dist/js/constraint.d.ts.map +1 -0
- package/dist/js/constraint.js +213 -0
- package/dist/js/constraint.js.map +1 -0
- package/dist/js/index.d.ts +94 -0
- package/dist/js/index.d.ts.map +1 -0
- package/dist/js/index.js +164 -0
- package/dist/js/index.js.map +1 -0
- package/dist/js/pure/adapter.d.ts +40 -0
- package/dist/js/pure/adapter.d.ts.map +1 -0
- package/dist/js/pure/adapter.js +207 -0
- package/dist/js/pure/adapter.js.map +1 -0
- package/dist/js/pure/index.d.ts +83 -0
- package/dist/js/pure/index.d.ts.map +1 -0
- package/dist/js/pure/index.js +132 -0
- package/dist/js/pure/index.js.map +1 -0
- package/dist/js/types.d.ts +132 -0
- package/dist/js/types.d.ts.map +1 -0
- package/dist/js/types.js +3 -0
- package/dist/js/types.js.map +1 -0
- package/dist/src/ts/algo/greedy.d.ts +9 -0
- package/dist/src/ts/algo/greedy.d.ts.map +1 -0
- package/dist/src/ts/algo/greedy.js +137 -0
- package/dist/src/ts/algo/greedy.js.map +1 -0
- package/dist/src/ts/algo/index.d.ts +2 -0
- package/dist/src/ts/algo/index.d.ts.map +1 -0
- package/dist/src/ts/algo/index.js +2 -0
- package/dist/src/ts/algo/index.js.map +1 -0
- package/dist/src/ts/core/coverage-engine.d.ts +40 -0
- package/dist/src/ts/core/coverage-engine.d.ts.map +1 -0
- package/dist/src/ts/core/coverage-engine.js +366 -0
- package/dist/src/ts/core/coverage-engine.js.map +1 -0
- package/dist/src/ts/core/generator.d.ts +6 -0
- package/dist/src/ts/core/generator.d.ts.map +1 -0
- package/dist/src/ts/core/generator.js +394 -0
- package/dist/src/ts/core/generator.js.map +1 -0
- package/dist/src/ts/core/index.d.ts +3 -0
- package/dist/src/ts/core/index.d.ts.map +1 -0
- package/dist/src/ts/core/index.js +3 -0
- package/dist/src/ts/core/index.js.map +1 -0
- package/dist/src/ts/model/boundary.d.ts +29 -0
- package/dist/src/ts/model/boundary.d.ts.map +1 -0
- package/dist/src/ts/model/boundary.js +102 -0
- package/dist/src/ts/model/boundary.js.map +1 -0
- package/dist/src/ts/model/constraint-ast.d.ts +152 -0
- package/dist/src/ts/model/constraint-ast.d.ts.map +1 -0
- package/dist/src/ts/model/constraint-ast.js +384 -0
- package/dist/src/ts/model/constraint-ast.js.map +1 -0
- package/dist/src/ts/model/constraint-parser.d.ts +49 -0
- package/dist/src/ts/model/constraint-parser.d.ts.map +1 -0
- package/dist/src/ts/model/constraint-parser.js +831 -0
- package/dist/src/ts/model/constraint-parser.js.map +1 -0
- package/dist/src/ts/model/error.d.ts +19 -0
- package/dist/src/ts/model/error.d.ts.map +1 -0
- package/dist/src/ts/model/error.js +19 -0
- package/dist/src/ts/model/error.js.map +1 -0
- package/dist/src/ts/model/generate-options.d.ts +82 -0
- package/dist/src/ts/model/generate-options.d.ts.map +1 -0
- package/dist/src/ts/model/generate-options.js +52 -0
- package/dist/src/ts/model/generate-options.js.map +1 -0
- package/dist/src/ts/model/index.d.ts +6 -0
- package/dist/src/ts/model/index.d.ts.map +1 -0
- package/dist/src/ts/model/index.js +6 -0
- package/dist/src/ts/model/index.js.map +1 -0
- package/dist/src/ts/model/parameter.d.ts +65 -0
- package/dist/src/ts/model/parameter.d.ts.map +1 -0
- package/dist/src/ts/model/parameter.js +157 -0
- package/dist/src/ts/model/parameter.js.map +1 -0
- package/dist/src/ts/model/test-case.d.ts +67 -0
- package/dist/src/ts/model/test-case.d.ts.map +1 -0
- package/dist/src/ts/model/test-case.js +28 -0
- package/dist/src/ts/model/test-case.js.map +1 -0
- package/dist/src/ts/util/bitset.d.ts +14 -0
- package/dist/src/ts/util/bitset.d.ts.map +1 -0
- package/dist/src/ts/util/bitset.js +66 -0
- package/dist/src/ts/util/bitset.js.map +1 -0
- package/dist/src/ts/util/combinatorics.d.ts +4 -0
- package/dist/src/ts/util/combinatorics.d.ts.map +1 -0
- package/dist/src/ts/util/combinatorics.js +60 -0
- package/dist/src/ts/util/combinatorics.js.map +1 -0
- package/dist/src/ts/util/index.d.ts +5 -0
- package/dist/src/ts/util/index.d.ts.map +1 -0
- package/dist/src/ts/util/index.js +7 -0
- package/dist/src/ts/util/index.js.map +1 -0
- package/dist/src/ts/util/rng.d.ts +13 -0
- package/dist/src/ts/util/rng.d.ts.map +1 -0
- package/dist/src/ts/util/rng.js +112 -0
- package/dist/src/ts/util/rng.js.map +1 -0
- package/dist/src/ts/util/string_util.d.ts +3 -0
- package/dist/src/ts/util/string_util.d.ts.map +1 -0
- package/dist/src/ts/util/string_util.js +25 -0
- package/dist/src/ts/util/string_util.js.map +1 -0
- package/dist/src/ts/validator/constraint-validator.d.ts +34 -0
- package/dist/src/ts/validator/constraint-validator.d.ts.map +1 -0
- package/dist/src/ts/validator/constraint-validator.js +51 -0
- package/dist/src/ts/validator/constraint-validator.js.map +1 -0
- package/dist/src/ts/validator/coverage-validator.d.ts +42 -0
- package/dist/src/ts/validator/coverage-validator.d.ts.map +1 -0
- package/dist/src/ts/validator/coverage-validator.js +230 -0
- package/dist/src/ts/validator/coverage-validator.js.map +1 -0
- package/dist/src/ts/validator/index.d.ts +3 -0
- package/dist/src/ts/validator/index.d.ts.map +1 -0
- package/dist/src/ts/validator/index.js +3 -0
- package/dist/src/ts/validator/index.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitset.d.ts","sourceRoot":"","sources":["../../../../src/ts/util/bitset.ts"],"names":[],"mappings":"AAoBA,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAc;gBAGhB,OAAO,GAAE,MAAU;IAM/B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKxB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAK5B,KAAK,IAAI,MAAM;IASf,IAAI,IAAI,MAAM;IAKd,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM;IASzC,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAOrC,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/// @file bitset.ts
|
|
2
|
+
/// @brief Dynamic bitset for coverage tracking using Uint32Array (32-bit blocks).
|
|
3
|
+
const BITS_PER_BLOCK = 32;
|
|
4
|
+
function numBlocks(numBits) {
|
|
5
|
+
return ((numBits + BITS_PER_BLOCK - 1) / BITS_PER_BLOCK) | 0;
|
|
6
|
+
}
|
|
7
|
+
/// Hamming weight (popcount) for a 32-bit integer.
|
|
8
|
+
function popcount32(x) {
|
|
9
|
+
x = x - ((x >>> 1) & 0x55555555);
|
|
10
|
+
x = (x & 0x33333333) + ((x >>> 2) & 0x33333333);
|
|
11
|
+
x = (x + (x >>> 4)) & 0x0f0f0f0f;
|
|
12
|
+
return (x * 0x01010101) >>> 24;
|
|
13
|
+
}
|
|
14
|
+
/// A dynamic bitset optimized for coverage tracking.
|
|
15
|
+
///
|
|
16
|
+
/// Uses Uint32Array blocks for efficient bulk operations (AND, OR, popcount).
|
|
17
|
+
export class DynamicBitset {
|
|
18
|
+
/// Construct a bitset with the given number of bits, all cleared.
|
|
19
|
+
constructor(numBits = 0) {
|
|
20
|
+
this.numBits = numBits;
|
|
21
|
+
this.blocks = new Uint32Array(numBlocks(numBits));
|
|
22
|
+
}
|
|
23
|
+
/// Set the bit at the given index.
|
|
24
|
+
set(index) {
|
|
25
|
+
this.blocks[index >>> 5] |= (1 << (index & 31)) >>> 0;
|
|
26
|
+
}
|
|
27
|
+
/// Clear the bit at the given index.
|
|
28
|
+
clear(index) {
|
|
29
|
+
this.blocks[index >>> 5] &= ~((1 << (index & 31)) >>> 0);
|
|
30
|
+
}
|
|
31
|
+
/// Test whether the bit at the given index is set.
|
|
32
|
+
test(index) {
|
|
33
|
+
return (this.blocks[index >>> 5] & ((1 << (index & 31)) >>> 0)) !== 0;
|
|
34
|
+
}
|
|
35
|
+
/// Count the number of set bits.
|
|
36
|
+
count() {
|
|
37
|
+
let total = 0;
|
|
38
|
+
for (let i = 0; i < this.blocks.length; i++) {
|
|
39
|
+
total += popcount32(this.blocks[i]);
|
|
40
|
+
}
|
|
41
|
+
return total;
|
|
42
|
+
}
|
|
43
|
+
/// Return the total number of bits.
|
|
44
|
+
size() {
|
|
45
|
+
return this.numBits;
|
|
46
|
+
}
|
|
47
|
+
/// Count bits set in (this AND NOT other).
|
|
48
|
+
countAndNot(other) {
|
|
49
|
+
let total = 0;
|
|
50
|
+
for (let i = 0; i < this.blocks.length; i++) {
|
|
51
|
+
total += popcount32((this.blocks[i] & ~other.blocks[i]) >>> 0);
|
|
52
|
+
}
|
|
53
|
+
return total;
|
|
54
|
+
}
|
|
55
|
+
/// Set all bits from other into this (this |= other).
|
|
56
|
+
unionWith(other) {
|
|
57
|
+
for (let i = 0; i < this.blocks.length; i++) {
|
|
58
|
+
this.blocks[i] |= other.blocks[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/// Clear all bits.
|
|
62
|
+
reset() {
|
|
63
|
+
this.blocks.fill(0);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=bitset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitset.js","sourceRoot":"","sources":["../../../../src/ts/util/bitset.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,kFAAkF;AAElF,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,SAAS,SAAS,CAAC,OAAe;IAChC,OAAO,CAAC,CAAC,OAAO,GAAG,cAAc,GAAG,CAAC,CAAC,G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
|
|
1
|
+
export declare function generateCombinations(n: number, k: number): number[][];
|
|
2
|
+
export declare function decodeMixedRadix(flatIndex: number, radixes: readonly number[]): number[];
|
|
3
|
+
export declare function encodeMixedRadix(indices: readonly number[], radixes: readonly number[]): number;
|
|
4
|
+
//# sourceMappingURL=combinatorics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combinatorics.d.ts","sourceRoot":"","sources":["../../../../src/ts/util/combinatorics.ts"],"names":[],"mappings":"AAQA,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CA8BrE;AAOD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAQxF;AAOD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAM/F"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// @file combinatorics.ts
|
|
2
|
+
/// @brief Combinatorial utility functions.
|
|
3
|
+
/// Generate all C(n, k) combinations of indices [0, n).
|
|
4
|
+
///
|
|
5
|
+
/// @param n The total number of elements.
|
|
6
|
+
/// @param k The size of each combination.
|
|
7
|
+
/// @returns Array of sorted index arrays. Empty if k === 0 or k > n.
|
|
8
|
+
export function generateCombinations(n, k) {
|
|
9
|
+
const result = [];
|
|
10
|
+
if (k === 0 || k > n) {
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
const indices = new Array(k);
|
|
14
|
+
for (let i = 0; i < k; i++) {
|
|
15
|
+
indices[i] = i;
|
|
16
|
+
}
|
|
17
|
+
while (true) {
|
|
18
|
+
result.push(indices.slice());
|
|
19
|
+
// Find rightmost index that can be incremented.
|
|
20
|
+
let pos = k - 1;
|
|
21
|
+
while (pos >= 0 && indices[pos] === n - k + pos) {
|
|
22
|
+
pos--;
|
|
23
|
+
}
|
|
24
|
+
if (pos < 0) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
indices[pos]++;
|
|
28
|
+
for (let j = pos + 1; j < k; j++) {
|
|
29
|
+
indices[j] = indices[j - 1] + 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
/// Decode a flat (mixed-radix) index into per-position value indices.
|
|
35
|
+
///
|
|
36
|
+
/// @param flatIndex The flat index to decode.
|
|
37
|
+
/// @param radixes The radix (number of values) for each position, in order.
|
|
38
|
+
/// @returns Array of decoded indices (same length as radixes).
|
|
39
|
+
export function decodeMixedRadix(flatIndex, radixes) {
|
|
40
|
+
const out = new Array(radixes.length);
|
|
41
|
+
let remainder = flatIndex;
|
|
42
|
+
for (let i = radixes.length - 1; i >= 0; i--) {
|
|
43
|
+
out[i] = remainder % radixes[i];
|
|
44
|
+
remainder = (remainder / radixes[i]) | 0;
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/// Encode per-position value indices into a flat (mixed-radix) index.
|
|
49
|
+
///
|
|
50
|
+
/// @param indices The per-position value indices.
|
|
51
|
+
/// @param radixes The radix (number of values) for each position, in order.
|
|
52
|
+
/// @returns The flat index.
|
|
53
|
+
export function encodeMixedRadix(indices, radixes) {
|
|
54
|
+
let result = 0;
|
|
55
|
+
for (let i = 0; i < indices.length; i++) {
|
|
56
|
+
result = result * radixes[i] + indices[i];
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=combinatorics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combinatorics.js","sourceRoot":"","sources":["../../../../src/ts/util/combinatorics.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,2CAA2C;AAE3C,wDAAwD;AACxD,GAAG;AACH,0CAA0C;AAC1C,0CAA0C;AAC1C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,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,SAAS,GAAG,SAAS,CAAC;IAC1B,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAChC,SAAS,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,sEAAsE;AACtE,GAAG;AACH,kDAAkD;AAClD,4EAA4E;AAC5E,4BAA4B;AAC5B,MAAM,UAAU,gBAAgB,CAAC,OAA0B,EAAE,OAA0B;IACrF,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DynamicBitset } from './bitset.js';
|
|
2
|
+
export { decodeMixedRadix, encodeMixedRadix, generateCombinations, } from './combinatorics.js';
|
|
3
|
+
export { Rng } from './rng.js';
|
|
4
|
+
export { isNumeric, toDouble } from './string_util.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ts/util/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// @file index.ts
|
|
2
|
+
/// @brief Re-exports for util module.
|
|
3
|
+
export { DynamicBitset } from './bitset.js';
|
|
4
|
+
export { decodeMixedRadix, encodeMixedRadix, generateCombinations, } from './combinatorics.js';
|
|
5
|
+
export { Rng } from './rng.js';
|
|
6
|
+
export { isNumeric, toDouble } from './string_util.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ts/util/index.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,sCAAsC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class Rng {
|
|
2
|
+
private s0;
|
|
3
|
+
private s1;
|
|
4
|
+
private s2;
|
|
5
|
+
private s3;
|
|
6
|
+
constructor(seed?: number);
|
|
7
|
+
private next;
|
|
8
|
+
uniformInt(min: number, max: number): number;
|
|
9
|
+
nextUint32(max: number): number;
|
|
10
|
+
weightedRandomIndex(weights: readonly number[]): number;
|
|
11
|
+
seed(seed: number): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=rng.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rng.d.ts","sourceRoot":"","sources":["../../../../src/ts/util/rng.ts"],"names":[],"mappings":"AAmBA,qBAAa,GAAG;IACd,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,EAAE,CAAS;gBAGP,IAAI,GAAE,MAAU;IAa5B,OAAO,CAAC,IAAI;IAsBZ,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAiB5C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAW/B,mBAAmB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;IAuBvD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAUzB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/// @file rng.ts
|
|
2
|
+
/// @brief Seeded PRNG for deterministic generation using xoshiro128**.
|
|
3
|
+
/// SplitMix32: used to initialize xoshiro128** state from a single seed.
|
|
4
|
+
function splitmix32(seed) {
|
|
5
|
+
let state = seed >>> 0;
|
|
6
|
+
return () => {
|
|
7
|
+
state = (state + 0x9e3779b9) >>> 0;
|
|
8
|
+
let z = state;
|
|
9
|
+
z = Math.imul(z ^ (z >>> 16), 0x85ebca6b) >>> 0;
|
|
10
|
+
z = Math.imul(z ^ (z >>> 13), 0xc2b2ae35) >>> 0;
|
|
11
|
+
return (z ^ (z >>> 16)) >>> 0;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/// Seeded PRNG using xoshiro128** algorithm.
|
|
15
|
+
///
|
|
16
|
+
/// Provides deterministic random number generation: same seed always produces
|
|
17
|
+
/// the same sequence of outputs.
|
|
18
|
+
export class Rng {
|
|
19
|
+
/// Construct a PRNG with the given seed.
|
|
20
|
+
constructor(seed = 0) {
|
|
21
|
+
const init = splitmix32(seed);
|
|
22
|
+
this.s0 = init();
|
|
23
|
+
this.s1 = init();
|
|
24
|
+
this.s2 = init();
|
|
25
|
+
this.s3 = init();
|
|
26
|
+
// Ensure state is never all-zero.
|
|
27
|
+
if ((this.s0 | this.s1 | this.s2 | this.s3) === 0) {
|
|
28
|
+
this.s0 = 1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/// Generate the next raw 32-bit value using xoshiro128**.
|
|
32
|
+
next() {
|
|
33
|
+
const result = Math.imul(rotl(Math.imul(this.s1, 5) >>> 0, 7), 9) >>> 0;
|
|
34
|
+
const t = (this.s1 << 9) >>> 0;
|
|
35
|
+
this.s2 ^= this.s0;
|
|
36
|
+
this.s3 ^= this.s1;
|
|
37
|
+
this.s1 ^= this.s2;
|
|
38
|
+
this.s0 ^= this.s3;
|
|
39
|
+
this.s2 ^= t;
|
|
40
|
+
this.s3 = rotl(this.s3, 11);
|
|
41
|
+
// Keep all state as unsigned 32-bit.
|
|
42
|
+
this.s0 >>>= 0;
|
|
43
|
+
this.s1 >>>= 0;
|
|
44
|
+
this.s2 >>>= 0;
|
|
45
|
+
this.s3 >>>= 0;
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
/// Generate a random integer in [min, max] (inclusive).
|
|
49
|
+
uniformInt(min, max) {
|
|
50
|
+
if (min >= max) {
|
|
51
|
+
return min;
|
|
52
|
+
}
|
|
53
|
+
const range = (max - min + 1) >>> 0;
|
|
54
|
+
// Use rejection sampling to avoid modulo bias.
|
|
55
|
+
// Standard debiasing: threshold = (2^32 - range) % range = (-range) % range.
|
|
56
|
+
// Values below threshold map unevenly; reject them.
|
|
57
|
+
const threshold = ((-range >>> 0) % range) >>> 0;
|
|
58
|
+
let r;
|
|
59
|
+
do {
|
|
60
|
+
r = this.next();
|
|
61
|
+
} while (r < threshold);
|
|
62
|
+
return min + (r % range);
|
|
63
|
+
}
|
|
64
|
+
/// Generate a random uint32 in [0, max) (exclusive upper bound).
|
|
65
|
+
nextUint32(max) {
|
|
66
|
+
if (max <= 0) {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
return this.uniformInt(0, max - 1);
|
|
70
|
+
}
|
|
71
|
+
/// Select a random index weighted by the given weights array.
|
|
72
|
+
///
|
|
73
|
+
/// @param weights Array of non-negative weights. At least one must be positive.
|
|
74
|
+
/// @returns The selected index.
|
|
75
|
+
weightedRandomIndex(weights) {
|
|
76
|
+
let totalWeight = 0;
|
|
77
|
+
for (let i = 0; i < weights.length; i++) {
|
|
78
|
+
totalWeight += weights[i];
|
|
79
|
+
}
|
|
80
|
+
if (totalWeight <= 0) {
|
|
81
|
+
return this.nextUint32(weights.length);
|
|
82
|
+
}
|
|
83
|
+
// Generate a random value in [0, totalWeight).
|
|
84
|
+
// Use floating-point multiplication for uniform distribution across the range.
|
|
85
|
+
const threshold = ((this.next() >>> 0) / 0x100000000) * totalWeight;
|
|
86
|
+
let cumulative = 0;
|
|
87
|
+
for (let i = 0; i < weights.length; i++) {
|
|
88
|
+
cumulative += weights[i];
|
|
89
|
+
if (threshold < cumulative) {
|
|
90
|
+
return i;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Fallback for floating-point edge cases.
|
|
94
|
+
return weights.length - 1;
|
|
95
|
+
}
|
|
96
|
+
/// Reseed the generator.
|
|
97
|
+
seed(seed) {
|
|
98
|
+
const init = splitmix32(seed);
|
|
99
|
+
this.s0 = init();
|
|
100
|
+
this.s1 = init();
|
|
101
|
+
this.s2 = init();
|
|
102
|
+
this.s3 = init();
|
|
103
|
+
if ((this.s0 | this.s1 | this.s2 | this.s3) === 0) {
|
|
104
|
+
this.s0 = 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/// 32-bit left rotation.
|
|
109
|
+
function rotl(x, k) {
|
|
110
|
+
return ((x << k) | (x >>> (32 - k))) >>> 0;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=rng.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rng.js","sourceRoot":"","sources":["../../../../src/ts/util/rng.ts"],"names":[],"mappings":"AAAA,gBAA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ED,yBAAyB;IACzB,IAAI,CAAC,IAAY;QACf,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,yBAAyB;AACzB,SAAS,IAAI,CAAC,CAAS,EAAE,CAAS;IAChC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string_util.d.ts","sourceRoot":"","sources":["../../../../src/ts/util/string_util.ts"],"names":[],"mappings":"AAQA,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAU5C;AAKD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE1C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// @file string_util.ts
|
|
2
|
+
/// @brief General-purpose string conversion utilities.
|
|
3
|
+
/// Check if a string can be parsed as a finite number.
|
|
4
|
+
///
|
|
5
|
+
/// Matches the behavior of the C++ version: the entire string must be a valid
|
|
6
|
+
/// numeric representation (no leading/trailing whitespace beyond what Number()
|
|
7
|
+
/// accepts, no empty strings, no non-finite values).
|
|
8
|
+
export function isNumeric(s) {
|
|
9
|
+
if (s.length === 0) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
// Reject strings that are only whitespace or contain non-numeric content.
|
|
13
|
+
if (s.trim().length === 0) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const n = Number(s);
|
|
17
|
+
return Number.isFinite(n);
|
|
18
|
+
}
|
|
19
|
+
/// Parse a string as a number (double-precision float).
|
|
20
|
+
///
|
|
21
|
+
/// Assumes the caller has verified the string is numeric via isNumeric().
|
|
22
|
+
export function toDouble(s) {
|
|
23
|
+
return Number(s);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=string_util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string_util.js","sourceRoot":"","sources":["../../../../src/ts/util/string_util.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,uDAAuD;AAEvD,uDAAuD;AACvD,GAAG;AACH,8EAA8E;AAC9E,+EAA+E;AAC/E,qDAAqD;AACrD,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,0EAA0E;IAC1E,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED,wDAAwD;AACxD,GAAG;AACH,0EAA0E;AAC1E,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ConstraintNode } from '../model/constraint-ast.js';
|
|
2
|
+
import type { TestCase } from '../model/test-case.js';
|
|
3
|
+
/** A single constraint violation record. */
|
|
4
|
+
export interface ConstraintViolation {
|
|
5
|
+
/** Index of the violating test case. */
|
|
6
|
+
testIndex: number;
|
|
7
|
+
/** Index of the violated constraint. */
|
|
8
|
+
constraintIndex: number;
|
|
9
|
+
/** Human-readable description. */
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
/** Constraint validation report. */
|
|
13
|
+
export interface ConstraintReport {
|
|
14
|
+
totalTests: number;
|
|
15
|
+
violations: number;
|
|
16
|
+
violatingIndices: number[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validate that all test cases satisfy all constraints.
|
|
20
|
+
*
|
|
21
|
+
* Evaluates each constraint against each test case. A test case violates
|
|
22
|
+
* a constraint if the constraint evaluates to False (fully assigned).
|
|
23
|
+
* @returns Array of constraint violations (empty if all tests pass).
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateConstraints(tests: TestCase[], constraints: ConstraintNode[]): ConstraintViolation[];
|
|
26
|
+
/**
|
|
27
|
+
* Validate constraints and return a summary report.
|
|
28
|
+
*
|
|
29
|
+
* Unlike validateConstraints which returns per-violation details, this function
|
|
30
|
+
* returns an aggregate report matching the C++ ConstraintReport structure.
|
|
31
|
+
* A test case is counted as violating at most once (on first violated constraint).
|
|
32
|
+
*/
|
|
33
|
+
export declare function validateConstraintReport(tests: TestCase[], constraints: ConstraintNode[]): ConstraintReport;
|
|
34
|
+
//# sourceMappingURL=constraint-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraint-validator.d.ts","sourceRoot":"","sources":["../../../../src/ts/validator/constraint-validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,QAAQ,EAAE,EACjB,WAAW,EAAE,cAAc,EAAE,GAC5B,mBAAmB,EAAE,CAiBvB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,QAAQ,EAAE,EACjB,WAAW,EAAE,cAAc,EAAE,GAC5B,gBAAgB,CAmBlB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// Validate that generated test cases satisfy all constraints.
|
|
2
|
+
import { ConstraintResult as CR } from '../model/constraint-ast.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validate that all test cases satisfy all constraints.
|
|
5
|
+
*
|
|
6
|
+
* Evaluates each constraint against each test case. A test case violates
|
|
7
|
+
* a constraint if the constraint evaluates to False (fully assigned).
|
|
8
|
+
* @returns Array of constraint violations (empty if all tests pass).
|
|
9
|
+
*/
|
|
10
|
+
export function validateConstraints(tests, constraints) {
|
|
11
|
+
const violations = [];
|
|
12
|
+
for (let i = 0; i < tests.length; ++i) {
|
|
13
|
+
for (let j = 0; j < constraints.length; ++j) {
|
|
14
|
+
const result = constraints[j].evaluate(tests[i].values);
|
|
15
|
+
if (result === CR.False) {
|
|
16
|
+
violations.push({
|
|
17
|
+
testIndex: i,
|
|
18
|
+
constraintIndex: j,
|
|
19
|
+
description: `Test case ${i} violates constraint ${j}`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return violations;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validate constraints and return a summary report.
|
|
28
|
+
*
|
|
29
|
+
* Unlike validateConstraints which returns per-violation details, this function
|
|
30
|
+
* returns an aggregate report matching the C++ ConstraintReport structure.
|
|
31
|
+
* A test case is counted as violating at most once (on first violated constraint).
|
|
32
|
+
*/
|
|
33
|
+
export function validateConstraintReport(tests, constraints) {
|
|
34
|
+
const report = {
|
|
35
|
+
totalTests: tests.length,
|
|
36
|
+
violations: 0,
|
|
37
|
+
violatingIndices: [],
|
|
38
|
+
};
|
|
39
|
+
for (let i = 0; i < tests.length; ++i) {
|
|
40
|
+
for (const constraint of constraints) {
|
|
41
|
+
const result = constraint.evaluate(tests[i].values);
|
|
42
|
+
if (result === CR.False) {
|
|
43
|
+
report.violations++;
|
|
44
|
+
report.violatingIndices.push(i);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return report;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=constraint-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraint-validator.js","sourceRoot":"","sources":["../../../../src/ts/validator/constraint-validator.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAG/D,OAAO,EAAE,gBAAgB,IAAI,EAAE,EAAE,MAAM,4BAA4B,CAAC;AAoBpE;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAiB,EACjB,WAA6B;IAE7B,MAAM,UAAU,GAA0B,EAAE,CAAC;IAE7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;YAC5C,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACxD,IAAI,MAAM,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC;gBACxB,UAAU,CAAC,IAAI,CAAC;oBACd,SAAS,EAAE,CAAC;oBACZ,eAAe,EAAE,CAAC;oBAClB,WAAW,EAAE,aAAa,CAAC,wBAAwB,CAAC,EAAE;iBACvD,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAiB,EACjB,WAA6B;IAE7B,MAAM,MAAM,GAAqB;QAC/B,UAAU,EAAE,KAAK,CAAC,MAAM;QACxB,UAAU,EAAE,CAAC;QACb,gBAAgB,EAAE,EAAE;KACrB,CAAC;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACtC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACpD,IAAI,MAAM,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC;gBACxB,MAAM,CAAC,UAAU,EAAE,CAAC;gBACpB,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChC,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Parameter } from '../model/parameter.js';
|
|
2
|
+
import type { GenerateResult, TestCase, UncoveredTuple } from '../model/test-case.js';
|
|
3
|
+
/** Coverage validation report with human-readable uncovered tuples. */
|
|
4
|
+
export interface CoverageReport {
|
|
5
|
+
totalTuples: number;
|
|
6
|
+
coveredTuples: number;
|
|
7
|
+
coverageRatio: number;
|
|
8
|
+
uncovered: UncoveredTuple[];
|
|
9
|
+
}
|
|
10
|
+
/** Equivalence class coverage report. */
|
|
11
|
+
export interface ClassCoverageReport {
|
|
12
|
+
totalClassTuples: number;
|
|
13
|
+
coveredClassTuples: number;
|
|
14
|
+
coverageRatio: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Independently validate t-wise coverage of a test suite.
|
|
18
|
+
*
|
|
19
|
+
* This validator enumerates all t-tuples from scratch (not using any
|
|
20
|
+
* generator internals) and checks each against the test suite.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateCoverage(params: Parameter[], tests: TestCase[], strength: number): CoverageReport;
|
|
23
|
+
/**
|
|
24
|
+
* Compute equivalence class coverage for a test suite.
|
|
25
|
+
*
|
|
26
|
+
* Maps each value to its equivalence class and enumerates all t-wise class
|
|
27
|
+
* tuples, counting how many are covered by the test suite.
|
|
28
|
+
* Only considers parameters that have equivalence classes defined.
|
|
29
|
+
* @returns Class coverage report. If no parameters have classes, returns all zeros.
|
|
30
|
+
*/
|
|
31
|
+
export declare function computeClassCoverage(params: Parameter[], tests: TestCase[], strength: number): ClassCoverageReport;
|
|
32
|
+
/**
|
|
33
|
+
* Annotate a GenerateResult with equivalence class coverage if applicable.
|
|
34
|
+
*
|
|
35
|
+
* Checks whether any parameter has equivalence classes defined. If so,
|
|
36
|
+
* computes class coverage and sets the classCoverage field on the result.
|
|
37
|
+
* @param result The generate result to annotate (modified in place).
|
|
38
|
+
* @param params The parameter definitions (with equivalence classes).
|
|
39
|
+
* @param strength The coverage strength used for generation.
|
|
40
|
+
*/
|
|
41
|
+
export declare function annotateClassCoverage(result: GenerateResult, params: Parameter[], strength: number): void;
|
|
42
|
+
//# sourceMappingURL=coverage-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-validator.d.ts","sourceRoot":"","sources":["../../../../src/ts/validator/coverage-validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtF,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED,yCAAyC;AACzC,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACvB;AA0CD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,EAAE,EACnB,KAAK,EAAE,QAAQ,EAAE,EACjB,QAAQ,EAAE,MAAM,GACf,cAAc,CA8EhB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EAAE,EACnB,KAAK,EAAE,QAAQ,EAAE,EACjB,QAAQ,EAAE,MAAM,GACf,mBAAmB,CA8FrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,SAAS,EAAE,EACnB,QAAQ,EAAE,MAAM,GACf,IAAI,CAkBN"}
|