-
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.
rubysrc2cpg: fixing call-related .code, .line and .column properties (#…
…2813) * Switching RUBY's node builder to take ParserRuleContexts instead of TerminalNodes * Fixing call-related .code, .line and .column properties
- Loading branch information
1 parent
7767514
commit c4aae96
Showing
2 changed files
with
66 additions
and
39 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
25 changes: 25 additions & 0 deletions
25
...ubysrc2cpg/src/test/scala/io/joern/rubysrc2cpg/passes/ast/SimpleAstCreationPassTest.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.passes.ast | ||
|
||
import io.joern.rubysrc2cpg.testfixtures.RubyCode2CpgFixture | ||
import io.shiftleft.semanticcpg.language._ | ||
|
||
class SimpleAstCreationPassTest extends RubyCode2CpgFixture { | ||
|
||
"AST generation for simple fragments" should { | ||
|
||
"have correct structure for a single command call" in { | ||
val cpg = code("""puts 123""") | ||
|
||
val List(commandCall) = cpg.call.l | ||
val List(arg) = commandCall.argument.isLiteral.l | ||
|
||
commandCall.code shouldBe "puts 123" | ||
commandCall.lineNumber shouldBe Some(1) | ||
|
||
arg.code shouldBe "123" | ||
arg.lineNumber shouldBe Some(1) | ||
arg.columnNumber shouldBe Some(5) | ||
} | ||
} | ||
|
||
} |