UNPKG

@informalsystems/quint

Version:

Core tool for the Quint specification language

68 lines 2.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const mocha_1 = require("mocha"); const IRFinder_1 = require("../../src/ir/IRFinder"); const ir_1 = require("../builders/ir"); (0, mocha_1.describe)('findExpressionWithId', () => { const modules = [(0, ir_1.buildModuleWithExpressions)(['Nat'])]; (0, mocha_1.it)('finds expression for existing id', () => { const expr = (0, IRFinder_1.findExpressionWithId)(modules, 1n); chai_1.assert.isDefined(expr); chai_1.assert.deepEqual(expr, { id: 1n, kind: 'name', name: 'Nat' }); }); (0, mocha_1.it)('returns undefined for inexisting id', () => { const expr = (0, IRFinder_1.findExpressionWithId)(modules, 99n); chai_1.assert.isUndefined(expr); }); }); (0, mocha_1.describe)('findTypeWithId', () => { const modules = [(0, ir_1.buildModuleWithDecls)(['const N: MY_TYPE'])]; (0, mocha_1.it)('finds type for existing id', () => { const type = (0, IRFinder_1.findTypeWithId)(modules, 1n); chai_1.assert.isDefined(type); chai_1.assert.deepEqual(type, { id: 1n, kind: 'const', name: 'MY_TYPE' }); }); (0, mocha_1.it)('returns undefined for inexisting id', () => { const type = (0, IRFinder_1.findTypeWithId)(modules, 99n); chai_1.assert.isUndefined(type); }); }); (0, mocha_1.describe)('findDefinitionWithId', () => { const modules = [(0, ir_1.buildModuleWithDecls)(['val a = 1'])]; (0, mocha_1.it)('finds definition for existing id', () => { const def = (0, IRFinder_1.findDefinitionWithId)(modules, 2n); chai_1.assert.isDefined(def); chai_1.assert.deepEqual(def, { id: 2n, kind: 'def', qualifier: 'val', name: 'a', expr: { id: 1n, kind: 'int', value: 1n }, }); }); (0, mocha_1.it)('returns undefined for inexisting id', () => { const def = (0, IRFinder_1.findDefinitionWithId)(modules, 99n); chai_1.assert.isUndefined(def); }); }); (0, mocha_1.describe)('findParameterWithId', () => { const modules = [(0, ir_1.buildModuleWithDecls)(['pure def x(a: int): int = a'])]; (0, mocha_1.it)('finds definition for existing id', () => { const def = (0, IRFinder_1.findParameterWithId)(modules, 2n); chai_1.assert.isDefined(def); chai_1.assert.deepEqual(def, { id: 2n, name: 'a', typeAnnotation: { id: 1n, kind: 'int', }, }); }); (0, mocha_1.it)('returns undefined for inexisting id', () => { const def = (0, IRFinder_1.findDefinitionWithId)(modules, 99n); chai_1.assert.isUndefined(def); }); }); //# sourceMappingURL=IRFinder.test.js.map