@fairfox/polly 0.32.0 → 0.34.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.
|
@@ -1421,12 +1421,23 @@ var init_tla = __esm(() => {
|
|
|
1421
1421
|
emitPostconditions(postconditions) {
|
|
1422
1422
|
for (const postcondition of postconditions) {
|
|
1423
1423
|
const tlaExpr = this.tsExpressionToTLA(postcondition.expression, true);
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1424
|
+
const message = postcondition.message ?? "ensures failed";
|
|
1425
|
+
const escapedMessage = message.replace(/"/g, "\\\"");
|
|
1426
|
+
this.line(`/\\ Assert(${tlaExpr}, "${escapedMessage}")`);
|
|
1426
1427
|
}
|
|
1427
1428
|
}
|
|
1428
1429
|
processAssignments(assignments, state) {
|
|
1429
|
-
return assignments.filter((a) => this.shouldIncludeAssignment(a, state)).map((a) => this.mapNullAssignment(a, state));
|
|
1430
|
+
return assignments.filter((a) => this.isFieldModeled(a.field, state)).filter((a) => this.shouldIncludeAssignment(a, state)).map((a) => this.mapNullAssignment(a, state));
|
|
1431
|
+
}
|
|
1432
|
+
isFieldModeled(field, state) {
|
|
1433
|
+
const sanitized = this.sanitizeFieldName(field);
|
|
1434
|
+
const fakeConfig = {
|
|
1435
|
+
state,
|
|
1436
|
+
messages: { maxInFlight: null },
|
|
1437
|
+
onBuild: "warn",
|
|
1438
|
+
onRelease: "warn"
|
|
1439
|
+
};
|
|
1440
|
+
return this.flattenStateConfig(fakeConfig).has(sanitized);
|
|
1430
1441
|
}
|
|
1431
1442
|
shouldIncludeAssignment(assignment, state) {
|
|
1432
1443
|
if (assignment.value !== null)
|
|
@@ -5230,15 +5241,7 @@ class HandlerExtractor {
|
|
|
5230
5241
|
}
|
|
5231
5242
|
extractPropertyAssignment(prop, assignments, signalName) {
|
|
5232
5243
|
if (Node2.isPropertyAssignment(prop)) {
|
|
5233
|
-
|
|
5234
|
-
const initializer = prop.getInitializer();
|
|
5235
|
-
if (!name || !initializer)
|
|
5236
|
-
return;
|
|
5237
|
-
const value = this.extractValue(initializer);
|
|
5238
|
-
if (value === undefined)
|
|
5239
|
-
return;
|
|
5240
|
-
const field = signalName ? `${signalName}_${name}` : name;
|
|
5241
|
-
assignments.push({ field, value });
|
|
5244
|
+
this.extractRegularPropertyAssignment(prop, assignments, signalName);
|
|
5242
5245
|
return;
|
|
5243
5246
|
}
|
|
5244
5247
|
if (Node2.isShorthandPropertyAssignment(prop)) {
|
|
@@ -5251,6 +5254,37 @@ class HandlerExtractor {
|
|
|
5251
5254
|
}
|
|
5252
5255
|
}
|
|
5253
5256
|
}
|
|
5257
|
+
extractRegularPropertyAssignment(prop, assignments, signalName) {
|
|
5258
|
+
if (!Node2.isPropertyAssignment(prop))
|
|
5259
|
+
return;
|
|
5260
|
+
const name = prop.getName();
|
|
5261
|
+
const initializer = prop.getInitializer();
|
|
5262
|
+
if (!name || !initializer)
|
|
5263
|
+
return;
|
|
5264
|
+
const field = signalName ? `${signalName}_${name}` : name;
|
|
5265
|
+
const value = this.extractValue(initializer);
|
|
5266
|
+
if (value !== undefined) {
|
|
5267
|
+
assignments.push({ field, value });
|
|
5268
|
+
return;
|
|
5269
|
+
}
|
|
5270
|
+
const paramName = this.extractPayloadPropertyParam(initializer);
|
|
5271
|
+
if (paramName !== null) {
|
|
5272
|
+
assignments.push({ field, value: `param:${paramName}` });
|
|
5273
|
+
}
|
|
5274
|
+
}
|
|
5275
|
+
extractPayloadPropertyParam(initializer) {
|
|
5276
|
+
if (!Node2.isPropertyAccessExpression(initializer))
|
|
5277
|
+
return null;
|
|
5278
|
+
const parts = this.getPropertyPath(initializer).split(".");
|
|
5279
|
+
if (parts.length !== 2)
|
|
5280
|
+
return null;
|
|
5281
|
+
const [paramName, fieldName] = parts;
|
|
5282
|
+
if (paramName === undefined || fieldName === undefined)
|
|
5283
|
+
return null;
|
|
5284
|
+
if (!this.currentFunctionParams.includes(paramName))
|
|
5285
|
+
return null;
|
|
5286
|
+
return fieldName;
|
|
5287
|
+
}
|
|
5254
5288
|
extractElementAccessAssignment(left, right, assignments) {
|
|
5255
5289
|
if (!Node2.isElementAccessExpression(left))
|
|
5256
5290
|
return;
|
|
@@ -7659,4 +7693,4 @@ main().catch((error) => {
|
|
|
7659
7693
|
process.exit(1);
|
|
7660
7694
|
});
|
|
7661
7695
|
|
|
7662
|
-
//# debugId=
|
|
7696
|
+
//# debugId=BB9760A4D35CDBCE64756E2164756E21
|