Skip to content

Conversation

Lipen
Copy link
Member

@Lipen Lipen commented Sep 10, 2025

This PR adds a comprehensive test suite for reachability analysis in TypeScript programs.

@Lipen Lipen requested a review from CaelmBleidd September 10, 2025 13:36
Base automatically changed from lipen/enums to main September 11, 2025 10:52
@Lipen Lipen force-pushed the lipen/reachability-2 branch from c1222a1 to 8ed53e5 Compare September 11, 2025 10:55
}
val arg = resolve(expr.args.single()) ?: return null

when (arg.sort) {

Check warning

Code scanning / detekt

Braces do not comply with the specified policy Warning

Inconsistent braces, make sure all branches either have or don't have braces.
.single { it.name == "callbackReachable" }

val initialTarget = TsReachabilityTarget.InitialPoint(method.cfg.stmts.first())
var target: TsTarget = initialTarget

Check warning

Code scanning / detekt

Var declaration could be val. Warning test

Variable 'target' could be val.
@Test
fun testInstanceofInheritanceReachable() {
// Test reachability through type-specific method call:
// const obj = new ConcreteA(value) -> const specificResult = obj.specificMethodA() -> if (specificResult === 1) -> return 1

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning test

Line detected, which is longer than the defined maximum line length in the code style.
target.addChild(TsReachabilityTarget.FinalPoint(returnStmt))

val results = machine.analyze(listOf(method), listOf(initialTarget))

Check warning

Code scanning / detekt

Detects trailing spaces Warning test

Trailing space(s)
@Test
fun testMutualRecursionReachable() {
// Test reachability through mutual recursion with depth limits:
// if (input > 0 && input < 5) -> const evenResult = this.isEven(input) -> if (evenResult && input === 4) -> return 1

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning test

Line detected, which is longer than the defined maximum line length in the code style.
@Test
fun testComplexTypeGuardReachable() {
// Test reachability through complex type guard combination:
// if (typeof value === "object" && value !== null) -> if (value instanceof Date) -> if (value.getFullYear() > 2020) -> return 1

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning test

Line detected, which is longer than the defined maximum line length in the code style.
@Lipen Lipen force-pushed the lipen/reachability-2 branch from 8ed53e5 to 35221de Compare September 11, 2025 11:14
@Lipen Lipen force-pushed the lipen/reachability-2 branch from 35221de to b3a41e1 Compare September 22, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants