diff --git a/joern-cli/frontends/rubysrc2cpg/src/test/scala/io/joern/rubysrc2cpg/querying/ConditionalTests.scala b/joern-cli/frontends/rubysrc2cpg/src/test/scala/io/joern/rubysrc2cpg/querying/ConditionalTests.scala index 8159757c2395..92841f3e2366 100644 --- a/joern-cli/frontends/rubysrc2cpg/src/test/scala/io/joern/rubysrc2cpg/querying/ConditionalTests.scala +++ b/joern-cli/frontends/rubysrc2cpg/src/test/scala/io/joern/rubysrc2cpg/querying/ConditionalTests.scala @@ -39,4 +39,24 @@ class ConditionalTests extends RubyCode2CpgFixture { } } + "`f(x ? y : z)` is lowered into conditional operator" in { + val cpg = code(""" + |f(x ? y : z) + |""".stripMargin) + val List(cond) = cpg.call(Operators.conditional).l + val List(x,y,z) = cond.argument.l + x.code shouldBe "x" + List(y,z).isBlock.astChildren.isIdentifier.code.l shouldBe List("y","z") + } + + "`f(unless x then y else z end)` is lowered into conditional operator" in { + val cpg = code(""" + |f(unless x then y else z end) + |""".stripMargin) + val List(cond) = cpg.call(Operators.conditional).l + val List(x,y,z) = cond.argument.l + List(x).isCall.name(Operators.logicalNot).argument.code.l shouldBe List("x") + List(y,z).isBlock.astChildren.isIdentifier.code.l shouldBe List("y","z") + } + }