diff --git a/package.json b/package.json index 0047fe377..8876ab8bb 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "@babel/preset-env": "^7.20.2", "@types/antlr4": "~4.11.2", "@types/color-string": "^1.5.2", + "@types/jest": "^29.5.14", "@types/lodash": "^4.14.191", "@types/node": "latest", "@typescript-eslint/eslint-plugin": "^6.7.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 714d68587..d0b975ebd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -83,6 +83,9 @@ importers: "@types/color-string": specifier: ^1.5.2 version: 1.5.2 + "@types/jest": + specifier: ^29.5.14 + version: 29.5.14 "@types/lodash": specifier: ^4.14.191 version: 4.14.191 @@ -1421,6 +1424,27 @@ packages: integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==, } + "@jest/expect-utils@29.7.0": + resolution: + { + integrity: sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + + "@jest/schemas@29.6.3": + resolution: + { + integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + + "@jest/types@29.6.3": + resolution: + { + integrity: sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + "@jimp/bmp@0.10.3": resolution: { @@ -1805,6 +1829,12 @@ packages: } engines: { node: ^12.20.0 || ^14.18.0 || >=16.0.0 } + "@sinclair/typebox@0.27.8": + resolution: + { + integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==, + } + "@tootallnate/once@2.0.0": resolution: { @@ -1891,6 +1921,30 @@ packages: integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==, } + "@types/istanbul-lib-coverage@2.0.6": + resolution: + { + integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==, + } + + "@types/istanbul-lib-report@3.0.3": + resolution: + { + integrity: sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==, + } + + "@types/istanbul-reports@3.0.4": + resolution: + { + integrity: sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==, + } + + "@types/jest@29.5.14": + resolution: + { + integrity: sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==, + } + "@types/json-schema@7.0.11": resolution: { @@ -1927,10 +1981,10 @@ packages: integrity: sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==, } - "@types/node@22.7.3": + "@types/node@22.9.0": resolution: { - integrity: sha512-qXKfhXXqGTyBskvWEzJZPUxSslAiLaB6JGP1ic/XTH9ctGgzdgYguuLP1C601aRTSDNlLb0jbKqXjZ48GNraSA==, + integrity: sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==, } "@types/ramda@0.28.20": @@ -1957,6 +2011,24 @@ packages: integrity: sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==, } + "@types/stack-utils@2.0.3": + resolution: + { + integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==, + } + + "@types/yargs-parser@21.0.3": + resolution: + { + integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==, + } + + "@types/yargs@17.0.33": + resolution: + { + integrity: sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==, + } + "@types/yauzl@2.10.3": resolution: { @@ -2296,6 +2368,7 @@ packages: { integrity: sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==, } + deprecated: package has been renamed to acorn-import-attributes peerDependencies: acorn: ^8 @@ -2442,6 +2515,13 @@ packages: } engines: { node: ">=8" } + ansi-styles@5.2.0: + resolution: + { + integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==, + } + engines: { node: ">=10" } + ansi-styles@6.2.1: resolution: { @@ -3340,6 +3420,13 @@ packages: integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==, } + diff-sequences@29.6.3: + resolution: + { + integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + diff2html@2.12.2: resolution: { @@ -3756,6 +3843,13 @@ packages: } engines: { node: ">=0.8.0" } + escape-string-regexp@2.0.0: + resolution: + { + integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==, + } + engines: { node: ">=8" } + escape-string-regexp@4.0.0: resolution: { @@ -3980,6 +4074,13 @@ packages: integrity: sha512-c2bQfLNbMzLPmzQuOr8fy0csy84WmwnER81W88DzTp9CYNPJ6yzOj2EZAh9pywYpqHnshVLHQJ8WzldAyfY+Iw==, } + expect@29.7.0: + resolution: + { + integrity: sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + extend@3.0.2: resolution: { @@ -4772,6 +4873,41 @@ packages: integrity: sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==, } + jest-diff@29.7.0: + resolution: + { + integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + + jest-get-type@29.6.3: + resolution: + { + integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + + jest-matcher-utils@29.7.0: + resolution: + { + integrity: sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + + jest-message-util@29.7.0: + resolution: + { + integrity: sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + + jest-util@29.7.0: + resolution: + { + integrity: sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + jest-worker@26.6.2: resolution: { @@ -5902,6 +6038,13 @@ packages: } engines: { node: ">=6" } + pretty-format@29.7.0: + resolution: + { + integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==, + } + engines: { node: ^14.15.0 || ^16.10.0 || >=18.0.0 } + process-warning@2.1.0: resolution: { @@ -6001,6 +6144,12 @@ packages: integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==, } + react-is@18.3.1: + resolution: + { + integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==, + } + read-cache@1.0.0: resolution: { @@ -6454,6 +6603,13 @@ packages: } engines: { node: ">= 8" } + stack-utils@2.0.6: + resolution: + { + integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==, + } + engines: { node: ">=10" } + string-argv@0.3.2: resolution: { @@ -8214,7 +8370,7 @@ snapshots: "@babel/template@7.22.15": dependencies: - "@babel/code-frame": 7.22.13 + "@babel/code-frame": 7.24.6 "@babel/parser": 7.23.0 "@babel/types": 7.23.0 @@ -8394,6 +8550,23 @@ snapshots: "@humanwhocodes/object-schema@1.2.1": {} + "@jest/expect-utils@29.7.0": + dependencies: + jest-get-type: 29.6.3 + + "@jest/schemas@29.6.3": + dependencies: + "@sinclair/typebox": 0.27.8 + + "@jest/types@29.6.3": + dependencies: + "@jest/schemas": 29.6.3 + "@types/istanbul-lib-coverage": 2.0.6 + "@types/istanbul-reports": 3.0.4 + "@types/node": 22.9.0 + "@types/yargs": 17.0.33 + chalk: 4.1.2 + "@jimp/bmp@0.10.3(@jimp/custom@0.10.3)": dependencies: "@babel/runtime": 7.20.6 @@ -8744,6 +8917,8 @@ snapshots: picocolors: 1.0.0 tslib: 2.6.2 + "@sinclair/typebox@0.27.8": {} + "@tootallnate/once@2.0.0": {} "@trysound/sax@0.2.0": {} @@ -8780,6 +8955,21 @@ snapshots: "@types/estree@1.0.5": {} + "@types/istanbul-lib-coverage@2.0.6": {} + + "@types/istanbul-lib-report@3.0.3": + dependencies: + "@types/istanbul-lib-coverage": 2.0.6 + + "@types/istanbul-reports@3.0.4": + dependencies: + "@types/istanbul-lib-report": 3.0.3 + + "@types/jest@29.5.14": + dependencies: + expect: 29.7.0 + pretty-format: 29.7.0 + "@types/json-schema@7.0.11": {} "@types/json-schema@7.0.13": {} @@ -8794,7 +8984,7 @@ snapshots: dependencies: undici-types: 5.26.5 - "@types/node@22.7.3": + "@types/node@22.9.0": dependencies: undici-types: 6.19.8 @@ -8808,6 +8998,14 @@ snapshots: "@types/sizzle@2.3.3": {} + "@types/stack-utils@2.0.3": {} + + "@types/yargs-parser@21.0.3": {} + + "@types/yargs@17.0.33": + dependencies: + "@types/yargs-parser": 21.0.3 + "@types/yauzl@2.10.3": dependencies: "@types/node": 20.14.9 @@ -9161,6 +9359,8 @@ snapshots: dependencies: color-convert: 2.0.1 + ansi-styles@5.2.0: {} + ansi-styles@6.2.1: {} antlr4@4.11.0: {} @@ -9696,6 +9896,8 @@ snapshots: didyoumean@1.2.2: {} + diff-sequences@29.6.3: {} + diff2html@2.12.2: dependencies: diff: 4.0.2 @@ -9920,6 +10122,8 @@ snapshots: escape-string-regexp@1.0.5: {} + escape-string-regexp@2.0.0: {} + escape-string-regexp@4.0.0: {} escodegen@2.0.0: @@ -10101,6 +10305,14 @@ snapshots: exif-parser@0.1.12: {} + expect@29.7.0: + dependencies: + "@jest/expect-utils": 29.7.0 + jest-get-type: 29.6.3 + jest-matcher-utils: 29.7.0 + jest-message-util: 29.7.0 + jest-util: 29.7.0 + extend@3.0.2: {} extract-zip@2.0.1(supports-color@8.1.1): @@ -10502,6 +10714,43 @@ snapshots: isstream@0.1.2: {} + jest-diff@29.7.0: + dependencies: + chalk: 4.1.2 + diff-sequences: 29.6.3 + jest-get-type: 29.6.3 + pretty-format: 29.7.0 + + jest-get-type@29.6.3: {} + + jest-matcher-utils@29.7.0: + dependencies: + chalk: 4.1.2 + jest-diff: 29.7.0 + jest-get-type: 29.6.3 + pretty-format: 29.7.0 + + jest-message-util@29.7.0: + dependencies: + "@babel/code-frame": 7.24.6 + "@jest/types": 29.6.3 + "@types/stack-utils": 2.0.3 + chalk: 4.1.2 + graceful-fs: 4.2.11 + micromatch: 4.0.8 + pretty-format: 29.7.0 + slash: 3.0.0 + stack-utils: 2.0.6 + + jest-util@29.7.0: + dependencies: + "@jest/types": 29.6.3 + "@types/node": 22.9.0 + chalk: 4.1.2 + ci-info: 3.7.0 + graceful-fs: 4.2.11 + picomatch: 2.3.1 + jest-worker@26.6.2: dependencies: "@types/node": 20.14.9 @@ -10510,7 +10759,7 @@ snapshots: jest-worker@27.5.1: dependencies: - "@types/node": 22.7.3 + "@types/node": 22.9.0 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -11130,6 +11379,12 @@ snapshots: pretty-bytes@5.6.0: {} + pretty-format@29.7.0: + dependencies: + "@jest/schemas": 29.6.3 + ansi-styles: 5.2.0 + react-is: 18.3.1 + process-warning@2.1.0: {} process@0.11.10: {} @@ -11168,6 +11423,8 @@ snapshots: dependencies: safe-buffer: 5.2.1 + react-is@18.3.1: {} + read-cache@1.0.0: dependencies: pify: 2.3.0 @@ -11456,6 +11713,10 @@ snapshots: dependencies: minipass: 3.3.6 + stack-utils@2.0.6: + dependencies: + escape-string-regexp: 2.0.0 + string-argv@0.3.2: {} string-width@4.2.3: diff --git a/test/unit/positioning/MessageContextListener.spec.ts b/test/unit/positioning/MessageContextListener.spec.ts index 2eb13bf2b..867a5b586 100644 --- a/test/unit/positioning/MessageContextListener.spec.ts +++ b/test/unit/positioning/MessageContextListener.spec.ts @@ -1,9 +1,9 @@ -import antlr4 from 'antlr4'; -import { MessageContextListener } from '../../../src/positioning/MessageContextListener'; -import { RootContext } from '../../../src/parser/index'; +import antlr4 from "antlr4"; +import { MessageContextListener } from "../../../src/positioning/MessageContextListener"; +import { RootContext } from "../../../src/parser/index"; -describe('MessageListener', () => { - it('can handle Message and Creation', () => { +describe("MessageListener", () => { + it("can handle Message and Creation", () => { const code = ` A.method(E.m) { B->C.method @@ -11,7 +11,7 @@ describe('MessageListener', () => { new B C->D: message `; - let rootContext = RootContext(code); + const rootContext = RootContext(code); const walker = antlr4.tree.ParseTreeWalker.DEFAULT; const messageContextListener = new MessageContextListener(); @@ -19,36 +19,40 @@ describe('MessageListener', () => { expect(messageContextListener.result()).toStrictEqual([ { - from: '_STARTER_', - signature: 'method(E.m)', - to: 'A', + from: "_STARTER_", + label: "method(E.m)", + signature: "method(E.m)", + to: "A", type: 0, }, { - from: 'B', - signature: 'method', - to: 'C', + from: "B", + label: "method", + signature: "method", + to: "C", type: 0, }, { - from: '_STARTER_', - signature: '«create»', - to: 'B', + from: "_STARTER_", + label: "«create»", + signature: "«create»", + to: "B", type: 2, }, { - from: 'C', - signature: ' message', - to: 'D', + from: "C", + label: " message", + signature: " message", + to: "D", type: 1, }, ]); }); - it('ignores expression in parameters', () => { + it("ignores expression in parameters", () => { const code = `A.m(new B, C.m)`; - let rootContext = RootContext(code); + const rootContext = RootContext(code); const walker = antlr4.tree.ParseTreeWalker.DEFAULT; const messageContextListener = new MessageContextListener(); @@ -56,17 +60,18 @@ describe('MessageListener', () => { expect(messageContextListener.result()).toStrictEqual([ { - from: '_STARTER_', - signature: 'm(new B,C.m)', - to: 'A', + from: "_STARTER_", + signature: "m(new B,C.m)", + label: "m(new B,C.m)", + to: "A", type: 0, }, ]); }); - it('ignores expression in conditions', () => { + it("ignores expression in conditions", () => { const code = `if(A.isGood()) {B.m}`; - let rootContext = RootContext(code); + const rootContext = RootContext(code); const walker = antlr4.tree.ParseTreeWalker.DEFAULT; const messageContextListener = new MessageContextListener(); @@ -74,9 +79,10 @@ describe('MessageListener', () => { expect(messageContextListener.result()).toStrictEqual([ { - from: '_STARTER_', - signature: 'm', - to: 'B', + from: "_STARTER_", + signature: "m", + label: "m", + to: "B", type: 0, }, ]);