diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index efec6bb..9833956 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,7 @@ jobs: - run: deno fmt --check - run: deno lint - run: deno test --coverage=cov/ + - run: deno doc --lint src/index.ts - run: deno coverage --lcov cov/ > cov.lcov - uses: coverallsapp/github-action@v2.3.6 diff --git a/deno.json b/deno.json index 65344b7..edcf891 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@voldemortas/flection", - "version": "0.0.5", + "version": "0.0.6", "exports": "./src/index.ts", "tasks": { "dev": "deno test --watch" diff --git a/readme.md b/readme.md index e587cad..489c802 100644 --- a/readme.md +++ b/readme.md @@ -18,7 +18,7 @@ endpoint shall be made public in the near future as well. ## Release notes -There is version 0.0.5 release which features Verb conjugation that includes +There is version 0.0.6 release which features Verb conjugation that includes inflection of the following: - infinitive @@ -36,7 +36,7 @@ all of them can be inflected for reflexivness, carry prefixes; the adjectival participles can also be pronominal. > [!NOTE]\ -> As this is version 0.0.5 nothing is yet set in stone and things may change! +> As this is version 0.0.6 nothing is yet set in stone and things may change! --- @@ -115,3 +115,25 @@ const soktiConjugated2 = Verb.pastFrequentativeIndicative .conjugateBasicPrefixed(['sokti', 'soka', 'soko'], 'ne') //both results are the same :) ``` + +### Helpers + +The library exposes some helpers that are useful when using the library. + +#### normaliseAccents()` + +The library operates using the +[combining unicode characters](https://en.wikipedia.org/wiki/Combining_character) +for stress marks, however, one may be tempted to use letters with diacritics +from different languages, such as a singel character `ñ` found in Spanish +instead of 2 characters: `n`+`u+0303` (`ñ`). Thus, if you aren't controlling the +user input, make sure to `normaliseAccents` + +```ts +import { normaliseAccents } from '@voldemortas/flection' + +const principalParts = `gésti-geñda-gẽdo` + +// single letters becomes simple letter + combining character +const normalisedPrincipalParts = normaliseAccents(principalParts) +``` diff --git a/src/Verb.ts b/src/Verb.ts index a502c2c..1dd125a 100644 --- a/src/Verb.ts +++ b/src/Verb.ts @@ -1,4 +1,3 @@ -import Verbal from './Verbal.ts' import type { ConjugationType, DeclinedType, @@ -33,6 +32,14 @@ import type { PadalyvisType } from '~conjugators/PadalyvisInflector.ts' import BudinysInflector from '~conjugators/BudinysInflector.ts' import type { BudinysType } from '~conjugators/BudinysInflector.ts' import NecessityParticipleDecliner from './flectors/conjugators/NecessityParticipleDecliner.ts' +import { + badFormatError, + parsingInputError, + threeRootsError, + unmatchingPrefixesError, + unmatchingReflexivesError, +} from './errors.ts' +import { isEverythingEqual } from './utils.ts' /** * Class which lets you derive various forms such as various moods, -imas action deverbal and various @@ -40,64 +47,134 @@ import NecessityParticipleDecliner from './flectors/conjugators/NecessityPartici * all the inflected forms to contain them. The derivation methods are also exposed *statically*. * **Respects accentuation and metatony.** */ -export default class Verb extends Verbal { +export default class Verb { + static readonly #PRINCIPAL_PARTS_COUNT = 3 + static readonly #WORD_DiLIMIER = '-' + + /** + * the 3 principal parts consisting of infinitive, 3rd person present indicative and 3rd person past simple indicative + */ + public readonly principalParts: PrincipalPartsType + /** + * the provided prefix(es) - optional + */ + public readonly prefix: string | undefined + /** + * whether the verb should be reflexive + */ + public readonly isReflexive: boolean + + /** + * static member for the past frequentative indicative + */ public static readonly pastFrequentativeIndicative: Inflector< ConjugationType > = new PastFrequentativeIndicativeConjugator() + /** + * static member for the future indicative + */ public static readonly futureIndicative: Inflector = new FutureIndicativeConjugator() + /** + * static member for the past simple indicative + */ public static readonly pastSimpleIndicative: Inflector = new PastSimpleIndicativeConjugator() + /** + * static member for the present indicative + */ public static readonly presentIndicative: Inflector = new PresentIndicativeConjugator() + /** + * static member for the conditional + */ public static readonly conditional: Inflector = new ConditionalConjugator() + /** + * static member for the imperative + */ public static readonly imperative: Inflector = new ImperativeConjugator() + /** + * static member for the infinitive + */ public static readonly infinitive: Inflector = new InfinitiveConjugator() + /** + * static member for the -imas noun + */ public static readonly imasNoun: Inflector = new ImasDecliner() + /** + * static member for the pusdalyvis + */ public static readonly pusdalyvis: Inflector = new PusdalyvisDecliner() + /** + * static member for the passive past participle + */ public static readonly passivePastParticiple: ParticipleDecliner = new PassivePastParticipleDecliner() + /** + * static member for the passive future participle + */ public static readonly passiveFutureParticiple: ParticipleDecliner = new PassiveFutureParticipleDecliner() + /** + * static member for the passive present participle + */ public static readonly passivePresentParticiple: ParticipleDecliner = new PassivePresentParticipleDecliner() + /** + * static member for the active past simple participle + */ public static readonly activePastSimpleParticiple: ParticipleDecliner = new ActivePastSimpleParticipleDecliner() + /** + * static member for the active past frequentative participle + */ public static readonly activePastFrequentativeParticiple: ParticipleDecliner = new ActivePastFrequentativeParticipleDecliner() + /** + * static member for the active future participle + */ public static readonly activeFutureParticiple: ParticipleDecliner = new ActiveFutureParticipleDecliner() + /** + * static member for the active present participle + */ public static readonly activePresentParticiple: ParticipleDecliner = new ActivePresentParticipleDecliner() + /** + * static member for the past simple padalyvis + */ public static readonly pastSimplePadalyvis: InflectorInterface< PadalyvisType > = new PadalyvisInflector(Verb.activePastSimpleParticiple) + /** + * static member for the past frequentative padalyvis + */ public static readonly pastFrequentativePadalyvis: InflectorInterface< PadalyvisType > = new PadalyvisInflector(Verb.activePastFrequentativeParticiple) + /** + * static member for the future padalyvis + */ public static readonly futurePadalyvis: InflectorInterface = new PadalyvisInflector(Verb.activeFutureParticiple) + /** + * static member for the present padalyvis + */ public static readonly presentPadalyvis: InflectorInterface = new PadalyvisInflector(Verb.activePresentParticiple) + /** + * static member for the budinys + */ public static readonly budinys: BudinysInflector = new BudinysInflector() - public static readonly necessityParticiple: ParticipleDecliner = - new NecessityParticipleDecliner() - /** - * Wrapper to call all the static methods with the same options - * @param {[string, string, string] | string} roots - single string with principal parts separated with a dash or array of 3 principal part strings - * @param {{reflexive?: boolean; prefix?: string}={}} options - options with optional prefix and optional reflexiveness + * static member for the necessity articiple */ - public constructor( - roots: string | PrincipalPartsType, - options: { reflexive?: boolean; prefix?: string | undefined } = {}, - ) { - super(roots, options) - } + public static readonly necessityParticiple: ParticipleDecliner = + new NecessityParticipleDecliner() /** * conjugates past frequentative tense based on the data passed to the verb's constructor @@ -394,6 +471,68 @@ export default class Verb extends Verbal { ) } + /** + * Wrapper to call all the static methods with the same options + * @param {[string, string, string] | string} roots - single string with principal parts separated with a dash or array of 3 principal part strings + * @param {{reflexive?: boolean; prefix?: string}={}} options - options with optional prefix and optional reflexiveness + * @example + * ```ts + * const firstVerb = new Verb([`dėti`, `deda`, `dėjo`])//same as secondVerb + * const secondVerb = new Verb(`dėti-deda-dėjo`)//same as firstVerb + * const thirdVerb = new Verb([`dėti`, `deda`, `dėjo`], {prefix: `pa`})//same as fourthVerb + * const fourthVerb = new Verb(`pa=dėti-pa=deda-pa=dėjo`)//same as thirdVerb + * const sixthVerb = new Verb([`dėti`, `deda`, `dėjo`], {prefix: `pa`, reflexive: true})//same as seventhVerb + * const seventhVerb = new Verb(`pasi=dėti-pasi=deda-pasi=dėjo`)//same as sixthVerb + * const eightVerb = new Verb([`dėti`, `deda`, `dėjo`], {reflexive: true})//same as ninthVerb + * const ninthVerb = new Verb(`dėtis-dedasi-dėjosi`)//same as eightVerb + * ``` + */ + public constructor( + roots: string | PrincipalPartsType, + options: { reflexive?: boolean; prefix?: string | undefined } = {}, + ) { + const rootArray = Array.isArray(roots) + ? roots + : roots.split(Verb.#WORD_DiLIMIER) + if (rootArray.length !== Verb.#PRINCIPAL_PARTS_COUNT) { + throw threeRootsError + } + const regexMagicGroup = rootArray.map((root) => { + const regexMatches = + /(^(?[^=]+?)=(?.+?)(?si?)?$|(^(?.+?)(?si?)?$))/ + .exec(root) + // deno-coverage-ignore-start + if (!regexMatches) { + throw badFormatError(root) + } + if (!regexMatches.groups) { + throw parsingInputError + } + // deno-coverage-ignore-stop + const groups = regexMatches.groups + return [ + trimReflexiveFromPrefix(groups['prefix'] ?? options.prefix), + groups['root']!, + !!options.reflexive || !!groups['reflexive'] || + /si$/.test(groups['prefix'] ?? options.prefix ?? ''), + ] as [string, string, boolean] + }) + + this.principalParts = regexMagicGroup.map((g) => g[1]) as [ + string, + string, + string, + ] + if (!isEverythingEqual(regexMagicGroup.map((g) => g[0]))) { + throw unmatchingPrefixesError + } + this.prefix = regexMagicGroup[0][0] + if (!isEverythingEqual(regexMagicGroup.map((g) => g[2]))) { + throw unmatchingReflexivesError + } + this.isReflexive = regexMagicGroup[0][2] + } + #inflectBasedOnOptions< T extends Record>, >( @@ -445,3 +584,10 @@ export default class Verb extends Verbal { ) as unknown as T } } + +function trimReflexiveFromPrefix(prefix: string | undefined) { + if (!prefix) { + return prefix + } + return prefix.replace(/si$/, '') +} diff --git a/src/Verbal.ts b/src/Verbal.ts deleted file mode 100644 index 412cb9f..0000000 --- a/src/Verbal.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { - badFormatError, - parsingInputError, - threeRootsError, - unmatchingPrefixesError, - unmatchingReflexivesError, -} from './errors.ts' -import { isEverythingEqual } from './utils.ts' -import type { PrincipalPartsType } from './types.ts' - -export default class Verbal { - static readonly #PRINCIPAL_PARTS_COUNT = 3 - static readonly #WORD_DiLIMIER = '-' - - public readonly principalParts: PrincipalPartsType - public readonly prefix: string | undefined - public readonly isReflexive: boolean - - public constructor( - roots: string | string[], - options: { reflexive?: boolean; prefix?: string | undefined } = {}, - ) { - const rootArray = Array.isArray(roots) - ? roots - : roots.split(Verbal.#WORD_DiLIMIER) - if (rootArray.length !== Verbal.#PRINCIPAL_PARTS_COUNT) { - throw threeRootsError - } - const regexMagicGroup = rootArray.map((root) => { - const regexMatches = - /(^(?[^=]+?)=(?.+?)(?si?)?$|(^(?.+?)(?si?)?$))/ - .exec(root) - // deno-coverage-ignore-start - if (!regexMatches) { - throw badFormatError(root) - } - if (!regexMatches.groups) { - throw parsingInputError - } - // deno-coverage-ignore-stop - const groups = regexMatches.groups - return [ - trimReflexiveFromPrefix(groups['prefix'] ?? options.prefix), - groups['root']!, - !!options.reflexive || !!groups['reflexive'] || - /si$/.test(groups['prefix'] ?? options.prefix ?? ''), - ] as [string, string, boolean] - }) - - this.principalParts = regexMagicGroup.map((g) => g[1]) as [ - string, - string, - string, - ] - if (!isEverythingEqual(regexMagicGroup.map((g) => g[0]))) { - throw unmatchingPrefixesError - } - this.prefix = regexMagicGroup[0][0] - if (!isEverythingEqual(regexMagicGroup.map((g) => g[2]))) { - throw unmatchingReflexivesError - } - this.isReflexive = regexMagicGroup[0][2] - } -} - -function trimReflexiveFromPrefix(prefix: string | undefined) { - if (!prefix) { - return prefix - } - return prefix.replace(/si$/, '') -} diff --git a/src/flectors/conjugators/BudinysInflector.ts b/src/flectors/conjugators/BudinysInflector.ts index bbdba8f..d306db4 100644 --- a/src/flectors/conjugators/BudinysInflector.ts +++ b/src/flectors/conjugators/BudinysInflector.ts @@ -6,6 +6,12 @@ import { } from '~src/utils.ts' import AccentedInflector from '~decliners/AccentedInflector.ts' +/** + * type for Padalyvis, it only has 1 type named `budinys` + * ```ts + * const eitiBudinys: BudinysType = {budinys: `eite`} + * ``` + */ export type BudinysType = { budinys: string } diff --git a/src/flectors/conjugators/InfinitiveConjugator.ts b/src/flectors/conjugators/InfinitiveConjugator.ts index 7ad74e9..054cbb1 100644 --- a/src/flectors/conjugators/InfinitiveConjugator.ts +++ b/src/flectors/conjugators/InfinitiveConjugator.ts @@ -3,6 +3,12 @@ import { getInfinitiveRoot } from '~src/utils.ts' import type { PrincipalPartsType } from '~src/types.ts' import { SECONDARY_FORM_SEPARATOR } from '~src/commons.ts' +/** + * type for Infinitive, it only has 1 type named `infinitive` + * ```ts + * const eitiInfinitive: InfinitiveType = {infinitive: `eite`} + * ``` + */ export type InfinitiveType = { infinitive: string } export default class InfinitiveConjugator extends Inflector { diff --git a/src/flectors/conjugators/PadalyvisInflector.ts b/src/flectors/conjugators/PadalyvisInflector.ts index 7369463..6c23820 100644 --- a/src/flectors/conjugators/PadalyvisInflector.ts +++ b/src/flectors/conjugators/PadalyvisInflector.ts @@ -1,6 +1,13 @@ import type { InflectorInterface } from '~conjugators/Inflector.ts' import type { PrincipalPartsType } from '~src/types.ts' +/** + * type for Padalyvis, it only has 1 type named `padalyvis` + * ```ts + * const einaPresentPadalyvis: PadalyvisType = {padalyvis: `einant`} + * const einaPastSimplePadalyvis: PadalyvisType = {padalyvis: `ėjus`} + * ``` + */ export type PadalyvisType = { padalyvis: string } diff --git a/src/flectors/conjugators/ParticipleDecliner.ts b/src/flectors/conjugators/ParticipleDecliner.ts index c5d9fa8..e79b18a 100644 --- a/src/flectors/conjugators/ParticipleDecliner.ts +++ b/src/flectors/conjugators/ParticipleDecliner.ts @@ -5,6 +5,11 @@ import Inflector, { import type { DeclinedType, PrincipalPartsType } from '~src/types.ts' import { stripAllAccents } from '~src/utils.ts' +/** + * type for adjectival participles, it has 3 genders: masculine, feminine, neuter + * the `neuter` gender only has itself: {neuter: string} + * `feminine` and `masculine` are {@link DeclinedType} declined nominal type + */ export type ParticipleType = { masculine: DeclinedType feminine: DeclinedType diff --git a/src/flectors/conjugators/PusdalyvisDecliner.ts b/src/flectors/conjugators/PusdalyvisDecliner.ts index 5e9c7fc..b07ff77 100644 --- a/src/flectors/conjugators/PusdalyvisDecliner.ts +++ b/src/flectors/conjugators/PusdalyvisDecliner.ts @@ -7,6 +7,17 @@ import { } from '~src/utils.ts' import Inflector from './Inflector.ts' +/** + * type for Pusdalyvis (-dam-), it has 4 members only: 2 gender for 2 numbers + * ```ts + * const eitiPusdalyvis: PusdalyvisType = { + * sgMasc: 'eidamas', + * sgFem: 'eidama', + * plMasc: 'eidami', + * plFem: 'eidamos', + * } + * ``` + */ export type PusdalyvisType = Record< 'sgMasc' | 'sgFem' | 'plMasc' | 'plFem', string diff --git a/src/index.ts b/src/index.ts index fcd38de..b8a87a2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,8 @@ import type { DeclinedType, PrincipalPartsType, } from './types.ts' +import type { InfinitiveType } from '~conjugators/InfinitiveConjugator.ts' +import type { ParticipleType } from '~conjugators/ParticipleDecliner.ts' import type { PadalyvisType } from '~conjugators/PadalyvisInflector.ts' import type { PusdalyvisType } from '~conjugators/PusdalyvisDecliner.ts' import type { BudinysType } from '~conjugators/BudinysInflector.ts' @@ -14,7 +16,9 @@ export type { BudinysType, ConjugationType, DeclinedType, + InfinitiveType, PadalyvisType, + ParticipleType, PrincipalPartsType, PusdalyvisType, } diff --git a/src/types.ts b/src/types.ts index 6dcd592..d4b237c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,6 +8,9 @@ */ export type PrincipalPartsType = [string, string, string] +/** + * type for all finite verbs: 3 persons for 2 numbers + */ export type ConjugationType = { sg1: string sg2: string @@ -17,6 +20,9 @@ export type ConjugationType = { pl3: string } +/** + * Type for all declined nominals: 7 cases for 2 numbers + */ export type DeclinedType = { sgNom: string sgGen: string diff --git a/test/Verb.test.ts b/test/Verb.test.ts index 0413f9a..73060a8 100644 --- a/test/Verb.test.ts +++ b/test/Verb.test.ts @@ -7,8 +7,73 @@ import type { InflectorInterface } from '~conjugators/Inflector.ts' import type ParticipleDecliner from '~conjugators/ParticipleDecliner.ts' import type { ParticipleType } from '~conjugators/ParticipleDecliner.ts' import type { BudinysType } from '~conjugators/BudinysInflector.ts' +import { + threeRootsError, + unmatchingPrefixesError, + unmatchingReflexivesError, +} from '~src/errors.ts' +import type { PrincipalPartsType } from '~src/types.ts' describe('Verb', () => { + describe('constructor', () => { + const principalParts: PrincipalPartsType = ['rinkti', 'renka', 'rinko'] + it('should get correct basic input', () => { + const verb = new Verb('rinkti-renka-rinko') + expect(verb.principalParts).toStrictEqual(principalParts) + expect(verb.isReflexive).toStrictEqual(false) + expect(verb.prefix).toStrictEqual(undefined) + assertEqualVerbs(new Verb(principalParts), verb) + }) + it('should get correct reflexive input', () => { + const verb = new Verb('rinktis-renkas-rinkosi') + expect(verb.principalParts).toStrictEqual(principalParts) + expect(verb.isReflexive).toStrictEqual(true) + expect(verb.prefix).toStrictEqual(undefined) + assertEqualVerbs(new Verb(principalParts, { reflexive: true }), verb) + }) + it('should get correct prefixed input', () => { + const verb = new Verb('ne=rinkti-ne=renka-ne=rinko') + expect(verb.principalParts).toStrictEqual(principalParts) + expect(verb.isReflexive).toStrictEqual(false) + expect(verb.prefix).toStrictEqual('ne') + assertEqualVerbs(new Verb(principalParts, { prefix: 'ne' }), verb) + }) + it('should get correct prefixed and reflexed input', () => { + const verb = new Verb('ne=rinktis-ne=renkasi-ne=rinkos') + expect(verb.principalParts).toStrictEqual(principalParts) + expect(verb.isReflexive).toStrictEqual(true) + expect(verb.prefix).toStrictEqual('ne') + assertEqualVerbs( + new Verb(principalParts, { prefix: 'ne', reflexive: true }), + verb, + ) + }) + it('should get correct prefix with reflexive input', () => { + const verb = new Verb('nesi=rinkti-nesi=renka-nesi=rinko') + expect(verb.principalParts).toStrictEqual(principalParts) + expect(verb.isReflexive).toStrictEqual(true) + expect(verb.prefix).toStrictEqual('ne') + assertEqualVerbs( + new Verb(principalParts, { prefix: 'ne', reflexive: true }), + verb, + ) + }) + it('should throw when prefixes mismatch', () => { + expect(() => new Verb('rinkti-ne=renka-ne=rinko')).toThrow( + unmatchingPrefixesError, + ) + }) + it('should throw when reflexive mismatches', () => { + expect(() => new Verb('rinktis-renka-rinko')).toThrow( + unmatchingReflexivesError, + ) + }) + it('it should throw when principal part count is not 3', () => { + expect(() => new Verb('')).toThrow(threeRootsError) + expect(() => new Verb('dėti-dedu')).toThrow(threeRootsError) + expect(() => new Verb('dėti-dedu-dėjo-dėdavo')).toThrow(threeRootsError) + }) + }) describe('conjugations', () => { assertTense( Verb.pastFrequentativeIndicative, @@ -298,3 +363,9 @@ describe('Verb', () => { } }) }) + +function assertEqualVerbs(a: Verb, b: Verb) { + expect(a.principalParts).toStrictEqual(b.principalParts) + expect(a.prefix).toStrictEqual(b.prefix) + expect(a.isReflexive).toStrictEqual(b.isReflexive) +} diff --git a/test/Verbal.test.ts b/test/Verbal.test.ts deleted file mode 100644 index b1c361d..0000000 --- a/test/Verbal.test.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { expect } from '@std/expect' -import { describe, it } from '@std/testing/bdd' -import Verbal from '~src/Verbal.ts' -import { - threeRootsError, - unmatchingPrefixesError, - unmatchingReflexivesError, -} from '~src/errors.ts' - -describe('Verbal', () => { - describe('constructor', () => { - const principalParts = ['rinkti', 'renka', 'rinko'] - it('should get correct basic input', () => { - const verb = new Verbal('rinkti-renka-rinko') - expect(verb.principalParts).toStrictEqual(principalParts) - expect(verb.isReflexive).toStrictEqual(false) - expect(verb.prefix).toStrictEqual(undefined) - assertEqualVerbals(new Verbal(principalParts), verb) - }) - it('should get correct reflexive input', () => { - const verb = new Verbal('rinktis-renkas-rinkosi') - expect(verb.principalParts).toStrictEqual(principalParts) - expect(verb.isReflexive).toStrictEqual(true) - expect(verb.prefix).toStrictEqual(undefined) - assertEqualVerbals(new Verbal(principalParts, { reflexive: true }), verb) - }) - it('should get correct prefixed input', () => { - const verb = new Verbal('ne=rinkti-ne=renka-ne=rinko') - expect(verb.principalParts).toStrictEqual(principalParts) - expect(verb.isReflexive).toStrictEqual(false) - expect(verb.prefix).toStrictEqual('ne') - assertEqualVerbals(new Verbal(principalParts, { prefix: 'ne' }), verb) - }) - it('should get correct prefixed and reflexed input', () => { - const verb = new Verbal('ne=rinktis-ne=renkasi-ne=rinkos') - expect(verb.principalParts).toStrictEqual(principalParts) - expect(verb.isReflexive).toStrictEqual(true) - expect(verb.prefix).toStrictEqual('ne') - assertEqualVerbals( - new Verbal(principalParts, { prefix: 'ne', reflexive: true }), - verb, - ) - }) - it('should get correct prefix with reflexive input', () => { - const verb = new Verbal('nesi=rinkti-nesi=renka-nesi=rinko') - expect(verb.principalParts).toStrictEqual(principalParts) - expect(verb.isReflexive).toStrictEqual(true) - expect(verb.prefix).toStrictEqual('ne') - assertEqualVerbals( - new Verbal(principalParts, { prefix: 'ne', reflexive: true }), - verb, - ) - }) - it('should throw when prefixes mismatch', () => { - expect(() => new Verbal('rinkti-ne=renka-ne=rinko')).toThrow( - unmatchingPrefixesError, - ) - }) - it('should throw when reflexive mismatches', () => { - expect(() => new Verbal('rinktis-renka-rinko')).toThrow( - unmatchingReflexivesError, - ) - }) - it('it should throw when principal part count is not 3', () => { - expect(() => new Verbal('')).toThrow(threeRootsError) - expect(() => new Verbal('dėti-dedu')).toThrow(threeRootsError) - expect(() => new Verbal('dėti-dedu-dėjo-dėdavo')).toThrow(threeRootsError) - }) - }) -}) - -export function assertEqualVerbals(a: Verbal, b: Verbal) { - expect(a.principalParts).toStrictEqual(b.principalParts) - expect(a.prefix).toStrictEqual(b.prefix) - expect(a.isReflexive).toStrictEqual(b.isReflexive) -}