UNPKG

@informalsystems/quint

Version:

Core tool for the Quint specification language

52 lines 2.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const mocha_1 = require("mocha"); const chai_1 = require("chai"); const printing_1 = require("../../src/types/printing"); const simplification_1 = require("../../src/types/simplification"); const base_1 = require("../../src/types/base"); (0, mocha_1.describe)('simplify', () => { (0, mocha_1.it)('flattens nested row tails', () => { // { a: int | { b: bool | { c: str | v } } } const type = { kind: 'rec', fields: { kind: 'row', fields: [{ fieldName: 'a', fieldType: { kind: 'int' } }], other: { kind: 'row', fields: [{ fieldName: 'b', fieldType: { kind: 'bool' } }], other: { kind: 'row', fields: [{ fieldName: 'c', fieldType: { kind: 'str' } }], other: { kind: 'var', name: 'v' }, }, }, }, }; const simplifiedType = (0, simplification_1.simplify)((0, base_1.toScheme)(type)); chai_1.assert.deepEqual((0, printing_1.typeSchemeToString)(simplifiedType), '{ a: int, b: bool, c: str | v }'); }); (0, mocha_1.it)('simplifies rows with empty fields', () => { // { | { b: bool | { c: str | v } } } const type = { kind: 'rec', fields: { kind: 'row', fields: [], other: { kind: 'row', fields: [{ fieldName: 'b', fieldType: { kind: 'bool' } }], other: { kind: 'row', fields: [{ fieldName: 'c', fieldType: { kind: 'str' } }], other: { kind: 'var', name: 'v' }, }, }, }, }; const simplifiedType = (0, simplification_1.simplify)((0, base_1.toScheme)(type)); chai_1.assert.deepEqual((0, printing_1.typeSchemeToString)(simplifiedType), '{ b: bool, c: str | v }'); }); }); //# sourceMappingURL=simplification.test.js.map