diff --git a/packages/safe-ds-lang/tests/language/flow/safe-ds-call-graph-computer.test.ts b/packages/safe-ds-lang/tests/language/flow/safe-ds-call-graph-computer.test.ts index 6e3ca14ff..0993e59a8 100644 --- a/packages/safe-ds-lang/tests/language/flow/safe-ds-call-graph-computer.test.ts +++ b/packages/safe-ds-lang/tests/language/flow/safe-ds-call-graph-computer.test.ts @@ -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'; @@ -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) => {