@cobol-ts/cursor-loader-cobol 0.0.4 → 0.0.5
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/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/src/cobol.array.selection.d.ts +56 -0
- package/dist/src/cobol.array.selection.js +172 -0
- package/dist/src/cobol.array.selection.js.map +1 -0
- package/dist/src/cobol.array.selection.spec.d.ts +1 -0
- package/dist/src/cobol.array.selection.spec.js +64 -0
- package/dist/src/cobol.array.selection.spec.js.map +1 -0
- package/dist/src/cobol.callback.spec.d.ts +1 -0
- package/dist/src/cobol.callback.spec.js +69 -0
- package/dist/src/cobol.callback.spec.js.map +1 -0
- package/dist/src/cobol.debug.range.d.ts +21 -0
- package/dist/src/cobol.debug.range.js +53 -0
- package/dist/src/cobol.debug.range.js.map +1 -0
- package/dist/src/cobol.debug.range.spec.d.ts +1 -0
- package/dist/src/cobol.debug.range.spec.js +29 -0
- package/dist/src/cobol.debug.range.spec.js.map +1 -0
- package/dist/src/cobol.decoded.file.spec.d.ts +1 -0
- package/dist/src/cobol.decoded.file.spec.js +41 -0
- package/dist/src/cobol.decoded.file.spec.js.map +1 -0
- package/dist/src/cobol.decoded.integration.spec.d.ts +1 -0
- package/dist/src/cobol.decoded.integration.spec.js +124 -0
- package/dist/src/cobol.decoded.integration.spec.js.map +1 -0
- package/dist/src/cobol.file.node.d.ts +37 -0
- package/dist/src/cobol.file.node.js +65 -0
- package/dist/src/cobol.file.node.js.map +1 -0
- package/dist/src/cobol.fixed.array.projection.spec.d.ts +1 -0
- package/dist/src/cobol.fixed.array.projection.spec.js +128 -0
- package/dist/src/cobol.fixed.array.projection.spec.js.map +1 -0
- package/dist/src/cobol.layout.index.d.ts +18 -0
- package/dist/src/cobol.layout.index.js +33 -0
- package/dist/src/cobol.layout.index.js.map +1 -0
- package/dist/src/cobol.layout.index.spec.d.ts +1 -0
- package/dist/src/cobol.layout.index.spec.js +195 -0
- package/dist/src/cobol.layout.index.spec.js.map +1 -0
- package/dist/src/cobol.metrics.odo.spec.d.ts +1 -0
- package/dist/src/cobol.metrics.odo.spec.js +52 -0
- package/dist/src/cobol.metrics.odo.spec.js.map +1 -0
- package/dist/src/cobol.metrics.scalar.spec.d.ts +1 -0
- package/dist/src/cobol.metrics.scalar.spec.js +28 -0
- package/dist/src/cobol.metrics.scalar.spec.js.map +1 -0
- package/dist/src/cobol.multiple.nested.arrays.spec.d.ts +1 -0
- package/dist/src/cobol.multiple.nested.arrays.spec.js +253 -0
- package/dist/src/cobol.multiple.nested.arrays.spec.js.map +1 -0
- package/dist/src/cobol.multiple.nested.odo.spec.d.ts +1 -0
- package/dist/src/cobol.multiple.nested.odo.spec.js +129 -0
- package/dist/src/cobol.multiple.nested.odo.spec.js.map +1 -0
- package/dist/src/cobol.nested.redefines.projection.spec.d.ts +1 -0
- package/dist/src/cobol.nested.redefines.projection.spec.js +195 -0
- package/dist/src/cobol.nested.redefines.projection.spec.js.map +1 -0
- package/dist/src/cobol.occurrence.context.spec.d.ts +1 -0
- package/dist/src/cobol.occurrence.context.spec.js +187 -0
- package/dist/src/cobol.occurrence.context.spec.js.map +1 -0
- package/dist/src/cobol.occurs.clause.d.ts +10 -0
- package/dist/src/cobol.occurs.clause.js +14 -0
- package/dist/src/cobol.occurs.clause.js.map +1 -0
- package/dist/src/cobol.occurs.clause.spec.d.ts +1 -0
- package/dist/src/cobol.occurs.clause.spec.js +21 -0
- package/dist/src/cobol.occurs.clause.spec.js.map +1 -0
- package/dist/src/cobol.odo.positions.d.ts +17 -0
- package/dist/src/cobol.odo.positions.js +70 -0
- package/dist/src/cobol.odo.positions.js.map +1 -0
- package/dist/src/cobol.odo.positions.spec.d.ts +1 -0
- package/dist/src/cobol.odo.positions.spec.js +108 -0
- package/dist/src/cobol.odo.positions.spec.js.map +1 -0
- package/dist/src/cobol.odo.projection.spec.d.ts +1 -0
- package/dist/src/cobol.odo.projection.spec.js +246 -0
- package/dist/src/cobol.odo.projection.spec.js.map +1 -0
- package/dist/src/cobol.odo.three.level.spec.d.ts +1 -0
- package/dist/src/cobol.odo.three.level.spec.js +202 -0
- package/dist/src/cobol.odo.three.level.spec.js.map +1 -0
- package/dist/src/cobol.parser.d.ts +112 -0
- package/dist/src/cobol.parser.js +322 -0
- package/dist/src/cobol.parser.js.map +1 -0
- package/dist/src/cobol.projection.path.d.ts +50 -0
- package/dist/src/cobol.projection.path.js +146 -0
- package/dist/src/cobol.projection.path.js.map +1 -0
- package/dist/src/cobol.projection.symbolic.d.ts +68 -0
- package/dist/src/cobol.projection.symbolic.js +257 -0
- package/dist/src/cobol.projection.symbolic.js.map +1 -0
- package/dist/src/cobol.registration.d.ts +4 -0
- package/dist/src/cobol.registration.js +17 -0
- package/dist/src/cobol.registration.js.map +1 -0
- package/dist/src/cobol.representation.d.ts +16 -0
- package/dist/src/cobol.representation.js +29 -0
- package/dist/src/cobol.representation.js.map +1 -0
- package/dist/src/cobol.shared.fixed.lifecycle.spec.d.ts +1 -0
- package/dist/src/cobol.shared.fixed.lifecycle.spec.js +50 -0
- package/dist/src/cobol.shared.fixed.lifecycle.spec.js.map +1 -0
- package/dist/src/cobol.shared.odo.lifecycle.spec.d.ts +1 -0
- package/dist/src/cobol.shared.odo.lifecycle.spec.js +152 -0
- package/dist/src/cobol.shared.odo.lifecycle.spec.js.map +1 -0
- package/dist/src/cobol.symbolic.allocation.spec.d.ts +1 -0
- package/dist/src/cobol.symbolic.allocation.spec.js +84 -0
- package/dist/src/cobol.symbolic.allocation.spec.js.map +1 -0
- package/dist/src/customer.fixtures.d.ts +90 -0
- package/dist/src/customer.fixtures.js +167 -0
- package/dist/src/customer.fixtures.js.map +1 -0
- package/dist/src/customer.fixtures.spec.d.ts +1 -0
- package/dist/src/customer.fixtures.spec.js +132 -0
- package/dist/src/customer.fixtures.spec.js.map +1 -0
- package/dist/src/customer.projections.d.ts +44 -0
- package/dist/src/customer.projections.js +31 -0
- package/dist/src/customer.projections.js.map +1 -0
- package/dist/src/customer.projections.spec.d.ts +1 -0
- package/dist/src/customer.projections.spec.js +209 -0
- package/dist/src/customer.projections.spec.js.map +1 -0
- package/package.json +11 -11
- package/node.d.ts +0 -1
- package/node.js +0 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.displacement = exports.physical = void 0;
|
|
4
|
+
exports.symbolicView = symbolicView;
|
|
5
|
+
exports.countResolver = countResolver;
|
|
6
|
+
const cobol_projection_symbolic_1 = require("./cobol.projection.symbolic");
|
|
7
|
+
const physical = (view) => "physical" in view ? view.physical : view;
|
|
8
|
+
exports.physical = physical;
|
|
9
|
+
const displacement = (view) => "physical" in view && "displacementBits" in view ? view.displacementBits : 0;
|
|
10
|
+
exports.displacement = displacement;
|
|
11
|
+
/** Keep the root's record-specific boundary in reusable record-state scratch. */
|
|
12
|
+
function symbolicView(view) {
|
|
13
|
+
if ("originBits" in view)
|
|
14
|
+
return view;
|
|
15
|
+
const record = (0, exports.physical)(view), state = record.recordState;
|
|
16
|
+
const root = state.rootScratch ?? (state.rootScratch = (0, cobol_projection_symbolic_1.rootSymbolicView)(record));
|
|
17
|
+
root.physical = record;
|
|
18
|
+
root.originBits = (state.dataOffsetBytes ?? 0) * 8;
|
|
19
|
+
root.endBits = (record.endByte - record.startByte) * 8;
|
|
20
|
+
return root;
|
|
21
|
+
}
|
|
22
|
+
/** A stable resolver closure per pooled physical holder, rebound on each lease. */
|
|
23
|
+
function countResolver(details, record) {
|
|
24
|
+
const context = record.recordState.countContext;
|
|
25
|
+
context.details = details;
|
|
26
|
+
context.record = record;
|
|
27
|
+
return context.resolve;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=cobol.representation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cobol.representation.js","sourceRoot":"","sources":["../../src/cobol.representation.ts"],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OAAO,OAAO,CAAC,OAAO,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cursor_projection_1 = require("@cobol-ts/cursor-projection");
|
|
4
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
5
|
+
const cobol_parser_1 = require("./cobol.parser");
|
|
6
|
+
const customer_fixtures_1 = require("./customer.fixtures");
|
|
7
|
+
const projection = (0, cursor_projection_1.defineProjection)({
|
|
8
|
+
telephones: { type: 'array', path: ['CUSTOMER', 'TELEPHONES'], element: { raw: { type: 'string', path: ['PHONE-RAW'] } } }
|
|
9
|
+
});
|
|
10
|
+
const details = (0, errors_1.valueOrThrow)((0, cobol_parser_1.createCobolFixedDetails)(customer_fixtures_1.customerFixedOccurs.layout));
|
|
11
|
+
const record = (index, state = (0, cobol_parser_1.createCobolRecordState)()) => ({
|
|
12
|
+
buffers: [Uint8Array.from(customer_fixtures_1.customerFixedOccurs.records[index].bytes)],
|
|
13
|
+
startByte: 0, endByte: 17, lastValidByte: 17,
|
|
14
|
+
source: 'phones.fb', recordNumber: index + 1, recordState: state
|
|
15
|
+
});
|
|
16
|
+
test('shared native fixed arrays read original bytes, clear once, and rebind same children', () => {
|
|
17
|
+
const factory = (0, cursor_projection_1.createProjection)(cobol_parser_1.cobolParser, details, undefined, projection);
|
|
18
|
+
const row = factory.create(), a = record(0);
|
|
19
|
+
factory.bind(row, a, a);
|
|
20
|
+
const array = row.telephones;
|
|
21
|
+
expect(Array.isArray(array)).toBe(true);
|
|
22
|
+
const first = array[0], second = array[1];
|
|
23
|
+
expect(first.raw()).toBe('4/10/c8 f1 f2 f3 f4 f5');
|
|
24
|
+
expect(second.raw()).toBe('10/16/d4 f6 f7 f8 f9 f0');
|
|
25
|
+
a.buffers[0][4] = 0xC9;
|
|
26
|
+
expect(first.raw()).toBe('4/10/c9 f1 f2 f3 f4 f5');
|
|
27
|
+
factory.clear(row);
|
|
28
|
+
expect(() => first.raw()).toThrow(/not bound/);
|
|
29
|
+
const b = record(1, a.recordState);
|
|
30
|
+
factory.bind(row, b, b);
|
|
31
|
+
expect(row.telephones).toBe(array);
|
|
32
|
+
expect(row.telephones[0]).toBe(first);
|
|
33
|
+
expect(row.telephones[1]).toBe(second);
|
|
34
|
+
expect(first.raw()).toBe('4/10/e6 f5 f4 f3 f2 f1');
|
|
35
|
+
factory.clear(row);
|
|
36
|
+
});
|
|
37
|
+
test('two simultaneous live records have distinct shared bindings', () => {
|
|
38
|
+
const factory = (0, cursor_projection_1.createProjection)(cobol_parser_1.cobolParser, details, undefined, projection);
|
|
39
|
+
const a = record(0), b = record(1), rowA = factory.create(), rowB = factory.create();
|
|
40
|
+
factory.bind(rowA, a, a);
|
|
41
|
+
factory.bind(rowB, b, b);
|
|
42
|
+
const first = rowA.telephones[0], second = rowB.telephones[0];
|
|
43
|
+
expect(first.raw()).toBe('4/10/c8 f1 f2 f3 f4 f5');
|
|
44
|
+
expect(second.raw()).toBe('4/10/e6 f5 f4 f3 f2 f1');
|
|
45
|
+
factory.clear(rowA);
|
|
46
|
+
expect(() => first.raw()).toThrow(/not bound/);
|
|
47
|
+
expect(second.raw()).toBe('4/10/e6 f5 f4 f3 f2 f1');
|
|
48
|
+
factory.clear(rowB);
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=cobol.shared.fixed.lifecycle.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cobol.shared.fixed.lifecycle.spec.js","sourceRoot":"","sources":["../../src/cobol.shared.fixed.lifecycle.spec.ts"],"names":[],"mappings":";;AAEA,mEAA8E;AAC9E,6CAA8C;AAC9C,iDAA0F;AAC1F,2DAAwD;AAGxD,MAAM,UAAU,GAAC,IAAA,oCAAgB,EAAW;IACxC,UAAU,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,IAAI,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AAC,CAAC,CAAC,EAAC,CAAC,GAAC,MAAM,CAAC,CAAC,CAAC,EAAC,IAAI,GAAC,OAAO,CAAC,MAAM,EAAE,EAAC,IAAI,GAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC1E,OAAO,CAAC,IAAI,CAAC,IAAI,EAAC,CAAC,EAAC,CAAC,CAAC,CAAC;IAAA,OAAO,CAAC,IAAI,CAAC,IAAI,EAAC,CAAC,EAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAC,MAAM,GAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACzD,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACnD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACpD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,MAAM,CAAC,GAAE,EAAE,CAAA,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7C,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACpD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cursor_projection_1 = require("@cobol-ts/cursor-projection");
|
|
4
|
+
const copybook_1 = require("@cobol-ts/copybook");
|
|
5
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
6
|
+
const layout_1 = require("@cobol-ts/layout");
|
|
7
|
+
const metrics_1 = require("@cobol-ts/metrics");
|
|
8
|
+
const cobol_parser_1 = require("./cobol.parser");
|
|
9
|
+
const compile = (max = 8) => (0, errors_1.valueOrThrow)((0, layout_1.compileCobolLayout)((0, errors_1.valueOrThrow)((0, copybook_1.parseCopybook)([
|
|
10
|
+
'01 ROW.',
|
|
11
|
+
' 05 ITEM-COUNT PIC 9.',
|
|
12
|
+
` 05 ITEMS OCCURS 0 TO ${max} TIMES DEPENDING ON ITEM-COUNT.`,
|
|
13
|
+
' 10 ITEM-VALUE PIC 9(3).'
|
|
14
|
+
].join('\n'))), 'shared-odo.cbl'));
|
|
15
|
+
const projection = (0, cursor_projection_1.defineProjection)({
|
|
16
|
+
items: { type: 'array', path: ['ROW', 'ITEMS'], element: { value: { type: 'integer', path: ['ITEM-VALUE'] } } }
|
|
17
|
+
});
|
|
18
|
+
const record = (count, recordNumber = 1, state = (0, cobol_parser_1.createCobolRecordState)()) => {
|
|
19
|
+
// Keep physical framing fixed. Only the active COBOL group length varies.
|
|
20
|
+
const bytes = Buffer.alloc(32, 0x20);
|
|
21
|
+
bytes.write(String(count), 0, 'ascii');
|
|
22
|
+
for (let index = 0; index < 8; index++)
|
|
23
|
+
bytes.write(String(100 + recordNumber * 10 + index).padStart(3, '0'), 1 + index * 3, 'ascii');
|
|
24
|
+
return { buffers: [bytes], startByte: 0, endByte: bytes.length, lastValidByte: bytes.length,
|
|
25
|
+
source: 'shared-odo.fb', recordNumber, recordState: state };
|
|
26
|
+
};
|
|
27
|
+
function setup(enabled, max = 8, metrics = new metrics_1.MemoryMetrics()) {
|
|
28
|
+
const details = { ...(0, errors_1.valueOrThrow)((0, cobol_parser_1.createCobolDecodedProjectionDetails)(compile(max), { encoding: 'ascii' })),
|
|
29
|
+
experimentalSharedOdoArrays: enabled, metrics };
|
|
30
|
+
return { factory: (0, cursor_projection_1.createProjection)(cobol_parser_1.cobolParser, details, undefined, projection, metrics), metrics };
|
|
31
|
+
}
|
|
32
|
+
test('shared ODO retains its child views across 8 -> 0 -> 8 and invalidates old leases', () => {
|
|
33
|
+
const { factory, metrics } = setup(true);
|
|
34
|
+
const row = factory.create(), state = (0, cobol_parser_1.createCobolRecordState)(metrics);
|
|
35
|
+
const first = record(8, 1, state);
|
|
36
|
+
factory.bind(row, first, first);
|
|
37
|
+
const array = row.items;
|
|
38
|
+
expect(Array.isArray(array)).toBe(true);
|
|
39
|
+
expect(array.length).toBe(8);
|
|
40
|
+
const firstChild = array[0], lastChild = array[7];
|
|
41
|
+
expect(firstChild.value()).toBe(110);
|
|
42
|
+
expect(lastChild.value()).toBe(117);
|
|
43
|
+
first.buffers[0][1] = 0x32; // modify underlying ASCII byte, no data copy
|
|
44
|
+
expect(firstChild.value()).toBe(210);
|
|
45
|
+
factory.clear(row);
|
|
46
|
+
expect(() => firstChild.value()).toThrow(/not bound/);
|
|
47
|
+
expect(() => lastChild.value()).toThrow(/not bound/);
|
|
48
|
+
const empty = record(0, 2, state);
|
|
49
|
+
factory.bind(row, empty, empty);
|
|
50
|
+
expect(row.items).toBe(array);
|
|
51
|
+
expect(array.length).toBe(0);
|
|
52
|
+
expect(array[0]).toBeUndefined();
|
|
53
|
+
expect(() => lastChild.value()).toThrow(/not active/);
|
|
54
|
+
factory.clear(row);
|
|
55
|
+
const third = record(8, 3, state);
|
|
56
|
+
factory.bind(row, third, third);
|
|
57
|
+
expect(row.items).toBe(array);
|
|
58
|
+
expect(array.length).toBe(8);
|
|
59
|
+
expect(array[0]).toBe(firstChild);
|
|
60
|
+
expect(array[7]).toBe(lastChild);
|
|
61
|
+
expect(firstChild.value()).toBe(130);
|
|
62
|
+
expect(lastChild.value()).toBe(137);
|
|
63
|
+
factory.clear(row);
|
|
64
|
+
expect(() => lastChild.value()).toThrow(/not bound/);
|
|
65
|
+
expect(metrics.get(metrics_1.METRIC.ARRAY_PROXY_INDEX)).toBe(0);
|
|
66
|
+
expect(metrics.get(metrics_1.METRIC.ARRAY_CHILD_BIND)).toBe(0);
|
|
67
|
+
expect(metrics.get(metrics_1.METRIC.PROJECTION_BIND)).toBe(3);
|
|
68
|
+
});
|
|
69
|
+
test('concurrent ODO leases do not share a physical binding or active count', () => {
|
|
70
|
+
const { factory } = setup(true);
|
|
71
|
+
const a = record(1, 1), b = record(8, 2);
|
|
72
|
+
const rowA = factory.create(), rowB = factory.create();
|
|
73
|
+
factory.bind(rowA, a, a);
|
|
74
|
+
factory.bind(rowB, b, b);
|
|
75
|
+
const arrayA = rowA.items, arrayB = rowB.items;
|
|
76
|
+
expect(arrayA.length).toBe(1);
|
|
77
|
+
expect(arrayB.length).toBe(8);
|
|
78
|
+
const aFirst = arrayA[0], bLast = arrayB[7];
|
|
79
|
+
expect(aFirst.value()).toBe(110);
|
|
80
|
+
expect(bLast.value()).toBe(127);
|
|
81
|
+
factory.clear(rowA);
|
|
82
|
+
expect(() => aFirst.value()).toThrow(/not bound/);
|
|
83
|
+
expect(bLast.value()).toBe(127);
|
|
84
|
+
factory.clear(rowB);
|
|
85
|
+
});
|
|
86
|
+
test('the default and unsupported large-ODO layouts keep lazy Proxy selection', () => {
|
|
87
|
+
for (const [enabled, max] of [[false, 8], [true, 9]]) {
|
|
88
|
+
const { factory, metrics } = setup(enabled, max);
|
|
89
|
+
const row = factory.create(), r = record(2);
|
|
90
|
+
factory.bind(row, r, r);
|
|
91
|
+
expect(row.items.length).toBe(2);
|
|
92
|
+
expect(row.items[0].value()).toBe(110);
|
|
93
|
+
expect(row.items[1].value()).toBe(111);
|
|
94
|
+
expect(metrics.get(metrics_1.METRIC.ARRAY_PROXY_INDEX)).toBe(2);
|
|
95
|
+
expect(metrics.get(metrics_1.METRIC.ARRAY_CHILD_BIND)).toBe(2);
|
|
96
|
+
factory.clear(row);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
test('the active count is read once per ODO binding in the fast path', () => {
|
|
100
|
+
const { factory, metrics } = setup(true);
|
|
101
|
+
const row = factory.create(), state = (0, cobol_parser_1.createCobolRecordState)(metrics);
|
|
102
|
+
for (const count of [0, 1, 8, 2, 0, 8]) {
|
|
103
|
+
const current = record(count, count + 1, state);
|
|
104
|
+
factory.bind(row, current, current);
|
|
105
|
+
expect(row.items.length).toBe(count);
|
|
106
|
+
if (count > 0)
|
|
107
|
+
expect(row.items[0].value()).toBe(110 + 10 * count);
|
|
108
|
+
factory.clear(row);
|
|
109
|
+
}
|
|
110
|
+
expect(metrics.get(metrics_1.METRIC.COBOL_CONTROLLER_READ)).toBe(6);
|
|
111
|
+
expect(metrics.get(metrics_1.METRIC.PROJECTION_BIND)).toBe(6);
|
|
112
|
+
});
|
|
113
|
+
test('nested symbolic arrays retain Proxy selection with ODO fast path enabled', () => {
|
|
114
|
+
const layout = (0, errors_1.valueOrThrow)((0, layout_1.compileCobolLayout)((0, errors_1.valueOrThrow)((0, copybook_1.parseCopybook)([
|
|
115
|
+
'01 ROW.',
|
|
116
|
+
' 05 ITEM-COUNT PIC 9.',
|
|
117
|
+
' 05 ORDERS OCCURS 2 TIMES.',
|
|
118
|
+
' 10 ITEMS OCCURS 0 TO 8 TIMES DEPENDING ON ITEM-COUNT.',
|
|
119
|
+
' 15 ITEM-VALUE PIC 9(3).'
|
|
120
|
+
].join('\n'))), 'nested-odo.cbl'));
|
|
121
|
+
const nested = (0, cursor_projection_1.defineProjection)({ orders: { type: 'array', path: ['ROW', 'ORDERS'], element: {
|
|
122
|
+
items: { type: 'array', path: ['ITEMS'], element: { value: { type: 'integer', path: ['ITEM-VALUE'] } } }
|
|
123
|
+
} } });
|
|
124
|
+
const metrics = new metrics_1.MemoryMetrics();
|
|
125
|
+
const details = { ...(0, errors_1.valueOrThrow)((0, cobol_parser_1.createCobolDecodedProjectionDetails)(layout, { encoding: 'ascii' })),
|
|
126
|
+
experimentalSharedOdoArrays: true, metrics };
|
|
127
|
+
const factory = (0, cursor_projection_1.createProjection)(cobol_parser_1.cobolParser, details, undefined, nested, metrics);
|
|
128
|
+
const bytes = Buffer.alloc(32, 0x20);
|
|
129
|
+
bytes.write('2' + '110111' + '120121', 0, 'ascii');
|
|
130
|
+
const current = { buffers: [bytes], startByte: 0, endByte: bytes.length, lastValidByte: bytes.length,
|
|
131
|
+
source: 'nested-odo.fb', recordNumber: 1, recordState: (0, cobol_parser_1.createCobolRecordState)(metrics) };
|
|
132
|
+
const row = factory.create();
|
|
133
|
+
factory.bind(row, current, current);
|
|
134
|
+
expect(row.orders[0].items[0].value()).toBe(110);
|
|
135
|
+
expect(row.orders[1].items[1].value()).toBe(121);
|
|
136
|
+
expect(metrics.get(metrics_1.METRIC.ARRAY_PROXY_INDEX)).toBe(4);
|
|
137
|
+
factory.clear(row);
|
|
138
|
+
});
|
|
139
|
+
test('the fast ODO binding rejects invalid and out-of-range controller values', () => {
|
|
140
|
+
const { factory } = setup(true);
|
|
141
|
+
const row = factory.create();
|
|
142
|
+
const tooMany = record(9);
|
|
143
|
+
factory.bind(row, tooMany, tooMany);
|
|
144
|
+
expect(() => row.items).toThrow(/outside declared bounds/);
|
|
145
|
+
factory.clear(row);
|
|
146
|
+
const invalid = record(1);
|
|
147
|
+
invalid.buffers[0][0] = 0x58; // 'X' is not an ASCII DISPLAY digit
|
|
148
|
+
factory.bind(row, invalid, invalid);
|
|
149
|
+
expect(() => row.items).toThrow(/Invalid unsigned DISPLAY ODO controller digit/);
|
|
150
|
+
factory.clear(row);
|
|
151
|
+
});
|
|
152
|
+
//# sourceMappingURL=cobol.shared.odo.lifecycle.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cobol.shared.odo.lifecycle.spec.js","sourceRoot":"","sources":["../../src/cobol.shared.odo.lifecycle.spec.ts"],"names":[],"mappings":";;AAEA,mEAA8E;AAC9E,iDAAiD;AACjD,6CAA8C;AAC9C,6CAAoD;AACpD,+CAAuD;AACvD,iDAAsG;AAEtG,MAAM,OAAO,GAAC,CAAC,GAAG,GAAC,CAAC,EAAC,EAAE,CAAA,IAAA,qBAAY,EAAC,IAAA,2BAAkB,EAAC,IAAA,qBAAY,EAAC,IAAA,wBAAa,EAAC;IA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strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const copybook_1 = require("@cobol-ts/copybook");
|
|
4
|
+
const layout_1 = require("@cobol-ts/layout");
|
|
5
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
6
|
+
const cursor_projection_1 = require("@cobol-ts/cursor-projection");
|
|
7
|
+
const cobol_parser_1 = require("./cobol.parser");
|
|
8
|
+
const size_1 = require("@cobol-ts/size");
|
|
9
|
+
const layout = (0, errors_1.valueOrThrow)((0, layout_1.compileCobolLayout)((0, errors_1.valueOrThrow)((0, copybook_1.parseCopybook)([
|
|
10
|
+
"01 ROW.",
|
|
11
|
+
" 05 COUNT PIC 9.",
|
|
12
|
+
" 05 ITEMS OCCURS 0 TO 3 TIMES DEPENDING ON COUNT.",
|
|
13
|
+
" 10 GROUP-DETAILS.",
|
|
14
|
+
" 15 CODE PIC X(2).",
|
|
15
|
+
" 05 FINAL PIC X."
|
|
16
|
+
].join("\n"))), "allocation.cpy"));
|
|
17
|
+
const details = (0, errors_1.valueOrThrow)((0, cobol_parser_1.createCobolProjectionDetails)(layout));
|
|
18
|
+
const definition = (0, cursor_projection_1.defineProjection)({
|
|
19
|
+
items: { type: "array", path: ["ROW", "ITEMS"], element: {
|
|
20
|
+
details: { type: "object", path: ["GROUP-DETAILS"], fields: { code: { type: "string", path: ["CODE"] } } }
|
|
21
|
+
} },
|
|
22
|
+
final: { type: "string", path: ["ROW", "FINAL"] }
|
|
23
|
+
});
|
|
24
|
+
const holder = (data, number = 5) => ({
|
|
25
|
+
buffers: [data], startByte: 0, endByte: data.length, lastValidByte: data.length,
|
|
26
|
+
source: "allocation.fb", recordNumber: number, recordState: (0, cobol_parser_1.createCobolRecordState)()
|
|
27
|
+
});
|
|
28
|
+
describe("COBOL symbolic hot-path reuse", () => {
|
|
29
|
+
test("repeated scalar reads reuse numeric selection scratch and controller location", () => {
|
|
30
|
+
const factory = (0, cursor_projection_1.createProjection)(cobol_parser_1.cobolParser, details, undefined, definition), row = factory.create();
|
|
31
|
+
const physical = holder(Uint8Array.of(0xf2, 0xc1, 0xc2, 0xd1, 0xd2, 0xe9));
|
|
32
|
+
factory.bind(row, physical, physical);
|
|
33
|
+
const selected = row.items[1].details;
|
|
34
|
+
expect(selected.code()).toBe("3/5/d1 d2");
|
|
35
|
+
const state = physical.recordState;
|
|
36
|
+
const scratch = state.scalarScratch, range = state.rangeScratch, root = state.rootScratch;
|
|
37
|
+
expect(scratch).toBeDefined();
|
|
38
|
+
expect(range).toBeDefined();
|
|
39
|
+
expect(root).toBeDefined();
|
|
40
|
+
expect(selected.code()).toBe("3/5/d1 d2");
|
|
41
|
+
expect(row.items[1].details).toBe(selected);
|
|
42
|
+
expect(state.scalarScratch).toBe(scratch);
|
|
43
|
+
expect(state.rangeScratch).toBe(range);
|
|
44
|
+
expect(state.rootScratch).toBe(root);
|
|
45
|
+
const declaration = layout[0].kind === "group" ? layout[0].children.find(n => n.kind === "group") : undefined;
|
|
46
|
+
if (!declaration || declaration.kind !== "group")
|
|
47
|
+
throw new Error("missing ITEMS");
|
|
48
|
+
if (typeof declaration.size === "number" || declaration.size.kind !== "depending-on")
|
|
49
|
+
throw new Error("missing dependent count");
|
|
50
|
+
const controller = declaration.size.path;
|
|
51
|
+
const position = details.controllerLocations.get(controller);
|
|
52
|
+
expect(position).toBeDefined();
|
|
53
|
+
expect(row.items.length).toBe(2);
|
|
54
|
+
expect(details.controllerLocations.get(controller)).toBe(position);
|
|
55
|
+
factory.clear(row);
|
|
56
|
+
(0, cobol_parser_1.cleanCobolRecordState)(state);
|
|
57
|
+
expect(state.countContext.record).toBeUndefined();
|
|
58
|
+
expect(state.countContext.details).toBeUndefined();
|
|
59
|
+
});
|
|
60
|
+
test("controller values are reread from bytes; only immutable coordinates are cached", () => {
|
|
61
|
+
const factory = (0, cursor_projection_1.createProjection)(cobol_parser_1.cobolParser, details, undefined, definition), row = factory.create();
|
|
62
|
+
const bytes = Uint8Array.of(0xf1, 0xc1, 0xc2, 0xe9), physical = holder(bytes, 49);
|
|
63
|
+
factory.bind(row, physical, physical);
|
|
64
|
+
expect(row.items.length).toBe(1);
|
|
65
|
+
bytes[0] = 0xf0;
|
|
66
|
+
expect(row.items.length).toBe(0);
|
|
67
|
+
// The structural position cache requires stable counts during a lease,
|
|
68
|
+
// but scalar controller reads themselves must not memoise values.
|
|
69
|
+
factory.clear(row);
|
|
70
|
+
});
|
|
71
|
+
test("literal dependency paths retain compiled identity without constructing arrays", () => {
|
|
72
|
+
const literal = ["ROW", "COUNT"];
|
|
73
|
+
expect((0, size_1.resolveDependingOnCount)(literal, path => {
|
|
74
|
+
expect(path).toBe(literal);
|
|
75
|
+
return 2;
|
|
76
|
+
})).toBe(2);
|
|
77
|
+
const variable = ["ROW", 0];
|
|
78
|
+
expect((0, size_1.resolveDependingOnCount)(variable, path => {
|
|
79
|
+
expect(path).toEqual(["ROW", 3]);
|
|
80
|
+
return 1;
|
|
81
|
+
}, [3])).toBe(1);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=cobol.symbolic.allocation.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cobol.symbolic.allocation.spec.js","sourceRoot":"","sources":["../../src/cobol.symbolic.allocation.spec.ts"],"names":[],"mappings":";;AAEA,iDAAiD;AACjD,6CAAoD;AACpD,6CAA8C;AAC9C,mEAA8E;AAC9E,iDAAqH;AACrH,yCAAuD;AAEvD,MAAM,MAAM,GAAC,IAAA,qBAAY,EAAC,IAAA,2BAAkB,EAAC,IAAA,qBAAY,EAAC,IAAA,wBAAa,EAAC;IACpE,SAAS;IACT,mBAAmB;IACnB,oDAAoD;IACpD,uBAAuB;IACvB,yBAAyB;IACzB,mBAAmB;CACtB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,gBAAgB,CAAC,CAAC,CAAC;AAClC,MAAM,OAAO,GAAC,IAAA,qBAAY,EAAC,IAAA,2CAA4B,EA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iledCobolEntry } from "@cobol-ts/layout";
|
|
3
|
+
import type { ProjectionField } from "@cobol-ts/cursor-loader-types";
|
|
4
|
+
/** Independently specified oracle: byte offsets are record-relative, end-exclusive. */
|
|
5
|
+
export type CustomerFieldSlice = Readonly<{
|
|
6
|
+
path: readonly (string | number)[];
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
9
|
+
hex: string;
|
|
10
|
+
}>;
|
|
11
|
+
export type CustomerRecordFixture = Readonly<{
|
|
12
|
+
label: string;
|
|
13
|
+
/** Original bytes, not a COBOL value decoded and then re-encoded by the layout. */
|
|
14
|
+
bytes: Uint8Array;
|
|
15
|
+
/** Expected total record length, independently specified. */
|
|
16
|
+
length: number;
|
|
17
|
+
/** Expected field locations and contents, independently specified. */
|
|
18
|
+
slices: readonly CustomerFieldSlice[];
|
|
19
|
+
/** For future ODO evaluation tests, not used by the name index. */
|
|
20
|
+
itemCount?: number;
|
|
21
|
+
}>;
|
|
22
|
+
export type CustomerFixture = Readonly<{
|
|
23
|
+
label: string;
|
|
24
|
+
copybook: string;
|
|
25
|
+
ast: CopybookAst;
|
|
26
|
+
layout: readonly CompiledCobolEntry[];
|
|
27
|
+
/** Typed application mapping, canonicalised by the actual projection factory. */
|
|
28
|
+
projection: Readonly<Record<string, ProjectionField>>;
|
|
29
|
+
records: readonly CustomerRecordFixture[];
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Turn a byte-oriented hexadecimal fixture into source bytes. Hex is deliberately
|
|
33
|
+
* supplied literally: no production COBOL encoder or compiled layout is involved.
|
|
34
|
+
*/
|
|
35
|
+
export declare function customerHexBytes(hex: string): Uint8Array;
|
|
36
|
+
/** Stage 1: flat fixed-length DISPLAY fields. Two 15-byte EBCDIC-037 records. */
|
|
37
|
+
export declare const customerSimple: Readonly<{
|
|
38
|
+
label: string;
|
|
39
|
+
copybook: string;
|
|
40
|
+
ast: CopybookAst;
|
|
41
|
+
layout: readonly CompiledCobolEntry[];
|
|
42
|
+
/** Typed application mapping, canonicalised by the actual projection factory. */
|
|
43
|
+
projection: Readonly<Record<string, ProjectionField>>;
|
|
44
|
+
records: readonly CustomerRecordFixture[];
|
|
45
|
+
}>;
|
|
46
|
+
/** Stage 2: groups and inaccessible FILLER. Two 21-byte EBCDIC records. */
|
|
47
|
+
export declare const customerNested: Readonly<{
|
|
48
|
+
label: string;
|
|
49
|
+
copybook: string;
|
|
50
|
+
ast: CopybookAst;
|
|
51
|
+
layout: readonly CompiledCobolEntry[];
|
|
52
|
+
/** Typed application mapping, canonicalised by the actual projection factory. */
|
|
53
|
+
projection: Readonly<Record<string, ProjectionField>>;
|
|
54
|
+
records: readonly CustomerRecordFixture[];
|
|
55
|
+
}>;
|
|
56
|
+
/** Stage 3: generated SYNCHRONIZED padding. COMP bytes are literal and not decoded. */
|
|
57
|
+
export declare const customerAligned: Readonly<{
|
|
58
|
+
label: string;
|
|
59
|
+
copybook: string;
|
|
60
|
+
ast: CopybookAst;
|
|
61
|
+
layout: readonly CompiledCobolEntry[];
|
|
62
|
+
/** Typed application mapping, canonicalised by the actual projection factory. */
|
|
63
|
+
projection: Readonly<Record<string, ProjectionField>>;
|
|
64
|
+
records: readonly CustomerRecordFixture[];
|
|
65
|
+
}>;
|
|
66
|
+
/** Stage 4: fixed OCCURS and REDEFINES within the repeated occurrence body. */
|
|
67
|
+
export declare const customerFixedOccurs: Readonly<{
|
|
68
|
+
label: string;
|
|
69
|
+
copybook: string;
|
|
70
|
+
ast: CopybookAst;
|
|
71
|
+
layout: readonly CompiledCobolEntry[];
|
|
72
|
+
/** Typed application mapping, canonicalised by the actual projection factory. */
|
|
73
|
+
projection: Readonly<Record<string, ProjectionField>>;
|
|
74
|
+
records: readonly CustomerRecordFixture[];
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Stage 5: legal fixed-position controller + ODO + REDEFINES inside the ODO body.
|
|
78
|
+
* The overlay is *inside* PURCHASES; no direct REDEFINES participant declares ODO.
|
|
79
|
+
* The two records exercise zero and maximum active occurrences.
|
|
80
|
+
*/
|
|
81
|
+
export declare const customerOdoRedefines: Readonly<{
|
|
82
|
+
label: string;
|
|
83
|
+
copybook: string;
|
|
84
|
+
ast: CopybookAst;
|
|
85
|
+
layout: readonly CompiledCobolEntry[];
|
|
86
|
+
/** Typed application mapping, canonicalised by the actual projection factory. */
|
|
87
|
+
projection: Readonly<Record<string, ProjectionField>>;
|
|
88
|
+
records: readonly CustomerRecordFixture[];
|
|
89
|
+
}>;
|
|
90
|
+
export declare const customerFixtures: readonly CustomerFixture[];
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.customerFixtures = exports.customerOdoRedefines = exports.customerFixedOccurs = exports.customerAligned = exports.customerNested = exports.customerSimple = void 0;
|
|
4
|
+
exports.customerHexBytes = customerHexBytes;
|
|
5
|
+
const copybook_1 = require("@cobol-ts/copybook");
|
|
6
|
+
const layout_1 = require("@cobol-ts/layout");
|
|
7
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
8
|
+
const customer_projections_1 = require("./customer.projections");
|
|
9
|
+
/**
|
|
10
|
+
* Turn a byte-oriented hexadecimal fixture into source bytes. Hex is deliberately
|
|
11
|
+
* supplied literally: no production COBOL encoder or compiled layout is involved.
|
|
12
|
+
*/
|
|
13
|
+
function customerHexBytes(hex) {
|
|
14
|
+
const words = hex.trim().split(/\s+/);
|
|
15
|
+
if (words.some(word => !/^[0-9A-Fa-f]{2}$/.test(word))) {
|
|
16
|
+
throw new Error(`Invalid customer fixture hex: ${hex}`);
|
|
17
|
+
}
|
|
18
|
+
return Uint8Array.from(words.map(word => parseInt(word, 16)));
|
|
19
|
+
}
|
|
20
|
+
const record = (label, length, hex, slices, itemCount) => ({ label, length, bytes: customerHexBytes(hex), slices, itemCount });
|
|
21
|
+
/**
|
|
22
|
+
* This is the production compilation path, run exactly once per fixture:
|
|
23
|
+
* copybook source -> parseCopybook -> CopybookAst -> compileCobolLayout -> layout.
|
|
24
|
+
* Errors in the parser/compiler fail fixture construction immediately.
|
|
25
|
+
*/
|
|
26
|
+
const customerFixture = (label, copybook, projection, records) => {
|
|
27
|
+
const ast = (0, errors_1.valueOrThrow)((0, copybook_1.parseCopybook)(copybook));
|
|
28
|
+
const layout = (0, errors_1.valueOrThrow)((0, layout_1.compileCobolLayout)(ast, `${label}.cpy`));
|
|
29
|
+
return { label, copybook, ast, layout, projection, records };
|
|
30
|
+
};
|
|
31
|
+
/** Stage 1: flat fixed-length DISPLAY fields. Two 15-byte EBCDIC-037 records. */
|
|
32
|
+
exports.customerSimple = customerFixture("customer-simple", [
|
|
33
|
+
"01 CUSTOMER.",
|
|
34
|
+
" 05 CUSTOMER-ID PIC 9(4).",
|
|
35
|
+
" 05 CUSTOMER-NAME PIC X(10).",
|
|
36
|
+
" 05 STATUS PIC X."
|
|
37
|
+
].join("\n"), customer_projections_1.customerSimpleProjection, [
|
|
38
|
+
record("Alice", 15,
|
|
39
|
+
// 0001 | ALICE_____ | A
|
|
40
|
+
"F0 F0 F0 F1 C1 D3 C9 C3 C5 40 40 40 40 40 C1", [
|
|
41
|
+
{ path: ["CUSTOMER", "CUSTOMER-ID"], from: 0, to: 4, hex: "F0 F0 F0 F1" },
|
|
42
|
+
{ path: ["CUSTOMER", "CUSTOMER-NAME"], from: 4, to: 14, hex: "C1 D3 C9 C3 C5 40 40 40 40 40" },
|
|
43
|
+
{ path: ["CUSTOMER", "STATUS"], from: 14, to: 15, hex: "C1" }
|
|
44
|
+
]),
|
|
45
|
+
record("Bob", 15,
|
|
46
|
+
// 0042 | BOB_______ | I
|
|
47
|
+
"F0 F0 F4 F2 C2 D6 C2 40 40 40 40 40 40 40 C9", [
|
|
48
|
+
{ path: ["CUSTOMER", "CUSTOMER-ID"], from: 0, to: 4, hex: "F0 F0 F4 F2" },
|
|
49
|
+
{ path: ["CUSTOMER", "CUSTOMER-NAME"], from: 4, to: 14, hex: "C2 D6 C2 40 40 40 40 40 40 40" },
|
|
50
|
+
{ path: ["CUSTOMER", "STATUS"], from: 14, to: 15, hex: "C9" }
|
|
51
|
+
])
|
|
52
|
+
]);
|
|
53
|
+
/** Stage 2: groups and inaccessible FILLER. Two 21-byte EBCDIC records. */
|
|
54
|
+
exports.customerNested = customerFixture("customer-nested", [
|
|
55
|
+
"01 CUSTOMER.",
|
|
56
|
+
" 05 CUSTOMER-ID PIC 9(4).",
|
|
57
|
+
" 05 CONTACT.",
|
|
58
|
+
" 10 FIRST-NAME PIC X(6).",
|
|
59
|
+
" 10 LAST-NAME PIC X(8).",
|
|
60
|
+
" 05 FILLER PIC X(2).",
|
|
61
|
+
" 05 STATUS PIC X."
|
|
62
|
+
].join("\n"), customer_projections_1.customerNestedProjection, [
|
|
63
|
+
record("Alice Smith", 21,
|
|
64
|
+
// 1001 | ALICE_ | SMITH___ | FILLER(2) | A
|
|
65
|
+
"F1 F0 F0 F1 C1 D3 C9 C3 C5 40 E2 D4 C9 E3 C8 40 40 40 40 40 C1", [
|
|
66
|
+
{ path: ["CUSTOMER", "CUSTOMER-ID"], from: 0, to: 4, hex: "F1 F0 F0 F1" },
|
|
67
|
+
{ path: ["CUSTOMER", "CONTACT", "FIRST-NAME"], from: 4, to: 10, hex: "C1 D3 C9 C3 C5 40" },
|
|
68
|
+
{ path: ["CUSTOMER", "CONTACT", "LAST-NAME"], from: 10, to: 18, hex: "E2 D4 C9 E3 C8 40 40 40" },
|
|
69
|
+
{ path: ["CUSTOMER", "STATUS"], from: 20, to: 21, hex: "C1" }
|
|
70
|
+
]),
|
|
71
|
+
record("Bob Jones", 21, "F2 F0 F0 F2 C2 D6 C2 40 40 40 D1 D6 D5 C5 E2 40 40 40 40 40 C9", [
|
|
72
|
+
{ path: ["CUSTOMER", "CUSTOMER-ID"], from: 0, to: 4, hex: "F2 F0 F0 F2" },
|
|
73
|
+
{ path: ["CUSTOMER", "CONTACT", "FIRST-NAME"], from: 4, to: 10, hex: "C2 D6 C2 40 40 40" },
|
|
74
|
+
{ path: ["CUSTOMER", "CONTACT", "LAST-NAME"], from: 10, to: 18, hex: "D1 D6 D5 C5 E2 40 40 40" },
|
|
75
|
+
{ path: ["CUSTOMER", "STATUS"], from: 20, to: 21, hex: "C9" }
|
|
76
|
+
])
|
|
77
|
+
]);
|
|
78
|
+
/** Stage 3: generated SYNCHRONIZED padding. COMP bytes are literal and not decoded. */
|
|
79
|
+
exports.customerAligned = customerFixture("customer-aligned", [
|
|
80
|
+
"01 CUSTOMER.",
|
|
81
|
+
" 05 CUSTOMER-ID PIC X(3).",
|
|
82
|
+
" 05 BALANCE PIC S9(9) COMP SYNCHRONIZED.",
|
|
83
|
+
" 05 STATUS PIC X."
|
|
84
|
+
].join("\n"), customer_projections_1.customerAlignedProjection, [
|
|
85
|
+
record("Positive", 9,
|
|
86
|
+
// A01 | padding 00 | big-endian COMP +1 | A
|
|
87
|
+
"C1 F0 F1 00 00 00 00 01 C1", [
|
|
88
|
+
{ path: ["CUSTOMER", "CUSTOMER-ID"], from: 0, to: 3, hex: "C1 F0 F1" },
|
|
89
|
+
{ path: ["CUSTOMER", "BALANCE"], from: 4, to: 8, hex: "00 00 00 01" },
|
|
90
|
+
{ path: ["CUSTOMER", "STATUS"], from: 8, to: 9, hex: "C1" }
|
|
91
|
+
]),
|
|
92
|
+
record("Negative", 9,
|
|
93
|
+
// B02 | padding 00 | big-endian COMP -1 | I
|
|
94
|
+
"C2 F0 F2 00 FF FF FF FF C9", [
|
|
95
|
+
{ path: ["CUSTOMER", "CUSTOMER-ID"], from: 0, to: 3, hex: "C2 F0 F2" },
|
|
96
|
+
{ path: ["CUSTOMER", "BALANCE"], from: 4, to: 8, hex: "FF FF FF FF" },
|
|
97
|
+
{ path: ["CUSTOMER", "STATUS"], from: 8, to: 9, hex: "C9" }
|
|
98
|
+
])
|
|
99
|
+
]);
|
|
100
|
+
/** Stage 4: fixed OCCURS and REDEFINES within the repeated occurrence body. */
|
|
101
|
+
exports.customerFixedOccurs = customerFixture("customer-fixed-occurs", [
|
|
102
|
+
"01 CUSTOMER.",
|
|
103
|
+
" 05 CUSTOMER-ID PIC 9(4).",
|
|
104
|
+
" 05 TELEPHONES OCCURS 2 TIMES.",
|
|
105
|
+
" 10 PHONE-RAW PIC X(6).",
|
|
106
|
+
" 10 PHONE-PARTS REDEFINES PHONE-RAW.",
|
|
107
|
+
" 15 PHONE-KIND PIC X.",
|
|
108
|
+
" 15 PHONE-NUMBER PIC X(5).",
|
|
109
|
+
" 05 STATUS PIC X."
|
|
110
|
+
].join("\n"), customer_projections_1.customerFixedOccursProjection, [
|
|
111
|
+
record("Alice", 17,
|
|
112
|
+
// 1001 | home | mobile | A
|
|
113
|
+
"F1 F0 F0 F1 C8 F1 F2 F3 F4 F5 D4 F6 F7 F8 F9 F0 C1", [
|
|
114
|
+
{ path: ["CUSTOMER", "CUSTOMER-ID"], from: 0, to: 4, hex: "F1 F0 F0 F1" },
|
|
115
|
+
{ path: ["CUSTOMER", "TELEPHONES", 0, "PHONE-RAW"], from: 4, to: 10, hex: "C8 F1 F2 F3 F4 F5" },
|
|
116
|
+
{ path: ["CUSTOMER", "TELEPHONES", 0, "PHONE-PARTS", "PHONE-KIND"], from: 4, to: 5, hex: "C8" },
|
|
117
|
+
{ path: ["CUSTOMER", "TELEPHONES", 1, "PHONE-PARTS", "PHONE-NUMBER"], from: 11, to: 16, hex: "F6 F7 F8 F9 F0" },
|
|
118
|
+
{ path: ["CUSTOMER", "STATUS"], from: 16, to: 17, hex: "C1" }
|
|
119
|
+
]),
|
|
120
|
+
record("Bob", 17, "F2 F0 F0 F2 E6 F5 F4 F3 F2 F1 C2 F1 F1 F2 F2 F3 C9", [
|
|
121
|
+
{ path: ["CUSTOMER", "CUSTOMER-ID"], from: 0, to: 4, hex: "F2 F0 F0 F2" },
|
|
122
|
+
{ path: ["CUSTOMER", "TELEPHONES", 0, "PHONE-PARTS", "PHONE-KIND"], from: 4, to: 5, hex: "E6" },
|
|
123
|
+
{ path: ["CUSTOMER", "TELEPHONES", 1, "PHONE-RAW"], from: 10, to: 16, hex: "C2 F1 F1 F2 F2 F3" },
|
|
124
|
+
{ path: ["CUSTOMER", "STATUS"], from: 16, to: 17, hex: "C9" }
|
|
125
|
+
])
|
|
126
|
+
]);
|
|
127
|
+
/**
|
|
128
|
+
* Stage 5: legal fixed-position controller + ODO + REDEFINES inside the ODO body.
|
|
129
|
+
* The overlay is *inside* PURCHASES; no direct REDEFINES participant declares ODO.
|
|
130
|
+
* The two records exercise zero and maximum active occurrences.
|
|
131
|
+
*/
|
|
132
|
+
exports.customerOdoRedefines = customerFixture("customer-odo-redefines", [
|
|
133
|
+
"01 CUSTOMER.",
|
|
134
|
+
" 05 ITEM-COUNT PIC 9.",
|
|
135
|
+
" 05 CUSTOMER-ID PIC 9(4).",
|
|
136
|
+
" 05 CUSTOMER-NAME PIC X(8).",
|
|
137
|
+
" 05 PURCHASES OCCURS 0 TO 3 TIMES DEPENDING ON ITEM-COUNT.",
|
|
138
|
+
" 10 PURCHASE-RAW PIC X(3).",
|
|
139
|
+
" 10 PURCHASE-PARTS REDEFINES PURCHASE-RAW.",
|
|
140
|
+
" 15 SKU PIC X(2).",
|
|
141
|
+
" 15 QUANTITY PIC 9.",
|
|
142
|
+
" 05 STATUS PIC X."
|
|
143
|
+
].join("\n"), customer_projections_1.customerOdoProjection, [
|
|
144
|
+
record("No purchases", 14,
|
|
145
|
+
// count 0 | 1001 | ALICE___ | A
|
|
146
|
+
"F0 F1 F0 F0 F1 C1 D3 C9 C3 C5 40 40 40 C1", [
|
|
147
|
+
{ path: ["CUSTOMER", "ITEM-COUNT"], from: 0, to: 1, hex: "F0" },
|
|
148
|
+
{ path: ["CUSTOMER", "CUSTOMER-ID"], from: 1, to: 5, hex: "F1 F0 F0 F1" },
|
|
149
|
+
{ path: ["CUSTOMER", "CUSTOMER-NAME"], from: 5, to: 13, hex: "C1 D3 C9 C3 C5 40 40 40" },
|
|
150
|
+
{ path: ["CUSTOMER", "STATUS"], from: 13, to: 14, hex: "C1" }
|
|
151
|
+
], 0),
|
|
152
|
+
record("Three purchases", 23,
|
|
153
|
+
// count 3 | 2002 | BOB_____ | AB1 CD2 EF3 | I
|
|
154
|
+
"F3 F2 F0 F0 F2 C2 D6 C2 40 40 40 40 40 C1 C2 F1 C3 C4 F2 C5 C6 F3 C9", [
|
|
155
|
+
{ path: ["CUSTOMER", "ITEM-COUNT"], from: 0, to: 1, hex: "F3" },
|
|
156
|
+
{ path: ["CUSTOMER", "CUSTOMER-ID"], from: 1, to: 5, hex: "F2 F0 F0 F2" },
|
|
157
|
+
{ path: ["CUSTOMER", "CUSTOMER-NAME"], from: 5, to: 13, hex: "C2 D6 C2 40 40 40 40 40" },
|
|
158
|
+
{ path: ["CUSTOMER", "PURCHASES", 0, "PURCHASE-RAW"], from: 13, to: 16, hex: "C1 C2 F1" },
|
|
159
|
+
{ path: ["CUSTOMER", "PURCHASES", 1, "PURCHASE-PARTS", "SKU"], from: 16, to: 18, hex: "C3 C4" },
|
|
160
|
+
{ path: ["CUSTOMER", "PURCHASES", 2, "PURCHASE-PARTS", "QUANTITY"], from: 21, to: 22, hex: "F3" },
|
|
161
|
+
{ path: ["CUSTOMER", "STATUS"], from: 22, to: 23, hex: "C9" }
|
|
162
|
+
], 3)
|
|
163
|
+
]);
|
|
164
|
+
exports.customerFixtures = [
|
|
165
|
+
exports.customerSimple, exports.customerNested, exports.customerAligned, exports.customerFixedOccurs, exports.customerOdoRedefines
|
|
166
|
+
];
|
|
167
|
+
//# sourceMappingURL=customer.fixtures.js.map
|