-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a problem with Ruby's call graph (#2796)
Co-authored-by: Fabian Yamaguchi <fabs@joern.io>
- Loading branch information
Showing
7 changed files
with
35 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...i/frontends/rubysrc2cpg/src/test/scala/io/joern/rubysrc2cpg/querying/CallGraphTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.joern.rubysrc2cpg.querying | ||
|
||
import io.joern.rubysrc2cpg.testfixtures.RubyCode2CpgFixture | ||
import io.shiftleft.semanticcpg.language._ | ||
|
||
class CallGraphTests extends RubyCode2CpgFixture { | ||
|
||
val cpg = code(""" | ||
|def bar(content) | ||
|puts content | ||
|end | ||
| | ||
|def foo | ||
|bar( 1 ) | ||
|end | ||
|""".stripMargin) | ||
|
||
"should identify call from `foo` to `bar`" in { | ||
val List(callToBar) = cpg.call("bar").l | ||
callToBar.name shouldBe "bar" | ||
callToBar.lineNumber shouldBe Some(7) | ||
cpg.method("bar").caller.name.l shouldBe List("foo") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters