Skip to content

Commit

Permalink
test: add tests for isRecursive
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Nov 20, 2023
1 parent 7a9c389 commit c936338
Showing 1 changed file with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { describe, expect, it } from 'vitest';
import { EmptyFileSystem, isNamed } from 'langium';
import { isSdsBlockLambda, isSdsExpressionLambda, isSdsModule, SdsCall } from '../../../src/language/generated/ast.js';
import {
isSdsBlockLambda,
isSdsCall,
isSdsExpressionLambda,
isSdsModule,
SdsCall,
} from '../../../src/language/generated/ast.js';
import { createSafeDsServices } from '../../../src/language/index.js';
import { createCallGraphTests } from './creator.js';
import { getNodeOfType } from '../../helpers/nodeFinder.js';
Expand All @@ -12,7 +18,39 @@ const services = createSafeDsServices(EmptyFileSystem).SafeDs;
const callGraphComputer = services.flow.CallGraphComputer;

describe('SafeDsCallGraphComputer', () => {
describe('isRecursive', () => {});
describe('isRecursive', () => {
it('should return true for recursive calls', async () => {
const call = await getNodeOfType(
services,
`
segment a() {
b();
}
segment b() {
a();
}
`,
isSdsCall,
);
expect(callGraphComputer.isRecursive(call)).toBe(true);
});

it('should return false for non-recursive calls', async () => {
const call = await getNodeOfType(
services,
`
segment a() {
b();
}
segment b() {}
`,
isSdsCall,
);
expect(callGraphComputer.isRecursive(call)).toBe(false);
});
});

describe('getCallGraph', async () => {
it.each(await createCallGraphTests())('$testName', async (test) => {
Expand Down

0 comments on commit c936338

Please sign in to comment.