2024-04-05 15:53:05 +03:00
|
|
|
|
import { extractGlobals, isSimpleExpression, splitTemplateDefinition } from './rslangAPI';
|
2023-11-06 22:21:36 +03:00
|
|
|
|
|
|
|
|
|
const globalsData = [
|
|
|
|
|
['', ''],
|
|
|
|
|
['X1', 'X1'],
|
|
|
|
|
['X11 X1 X11', 'X11 X1'],
|
2023-12-28 14:04:44 +03:00
|
|
|
|
['∀α∈S1 ∀β∈F1[α] Pr1,1(β)∩β=∅', 'S1 F1']
|
|
|
|
|
];
|
2023-11-06 22:21:36 +03:00
|
|
|
|
describe('Testing extract globals', () => {
|
2023-12-28 14:04:44 +03:00
|
|
|
|
it.each(globalsData)('Extract globals %p', (input: string, expected: string) => {
|
2023-11-06 22:21:36 +03:00
|
|
|
|
const result = extractGlobals(input);
|
|
|
|
|
expect([...result].join(' ')).toBe(expected);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-05 15:53:05 +03:00
|
|
|
|
const simpleExpressionData = [
|
|
|
|
|
['', 'true'],
|
|
|
|
|
['Pr1(S1)', 'true'],
|
|
|
|
|
['pr1(S1)', 'true'],
|
|
|
|
|
['red(S1)', 'true'],
|
|
|
|
|
['red(Pr1(F1[α,σ]))', 'true'],
|
|
|
|
|
['D{(α,β)∈D6×D6 | α≠β & α∩β≠∅}', 'false'],
|
|
|
|
|
['I{(β,α) | α:∈D2; σ:=F5[α]; β:∈σ}', 'false'],
|
|
|
|
|
['∀σ∈S1 (F1[σ]×F1[σ])∩D11=∅', 'false']
|
|
|
|
|
];
|
|
|
|
|
describe('Testing simple expression', () => {
|
|
|
|
|
it.each(simpleExpressionData)('isSimpleExpression %p', (input: string, expected: string) => {
|
|
|
|
|
const result = isSimpleExpression(input);
|
|
|
|
|
expect(String(result)).toBe(expected);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2023-11-06 22:21:36 +03:00
|
|
|
|
const splitData = [
|
|
|
|
|
['', '||'],
|
|
|
|
|
['[α∈ℬ(R1)] α⊆red(σ)', 'α∈ℬ(R1)||α⊆red(σ)'],
|
|
|
|
|
['[α∈ℬ(R1)] α⊆red(σ) ', 'α∈ℬ(R1)||α⊆red(σ)'],
|
|
|
|
|
[' [α∈ℬ(R1)] α⊆red(σ)', 'α∈ℬ(R1)||α⊆red(σ)'],
|
|
|
|
|
['[α∈ℬ(R1)]α⊆red(σ)', 'α∈ℬ(R1)||α⊆red(σ)'],
|
2023-12-28 14:04:44 +03:00
|
|
|
|
['[α∈ℬ(R1), σ∈ℬℬ(R1)] α⊆red(σ)', 'α∈ℬ(R1), σ∈ℬℬ(R1)||α⊆red(σ)']
|
|
|
|
|
];
|
2023-11-06 22:21:36 +03:00
|
|
|
|
describe('Testing split template', () => {
|
2023-12-28 14:04:44 +03:00
|
|
|
|
it.each(splitData)('Split %p', (input: string, expected: string) => {
|
2023-11-06 22:21:36 +03:00
|
|
|
|
const result = splitTemplateDefinition(input);
|
|
|
|
|
expect(`${result.head}||${result.body}`).toBe(expected);
|
|
|
|
|
});
|
2023-12-28 14:04:44 +03:00
|
|
|
|
});
|