Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Jan 17, 2024
1 parent 5e9bb10 commit 677088b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ class TypeRecoveryPassTests extends DataFlowCodeToCpgSuite {
"resolve 'foo.x' and 'foo.y' field access primitive types correctly" in {
val List(z1, z2) = cpg.file.name(".*Bar.*").ast.isIdentifier.nameExact("z").l
z1.typeFullName shouldBe "__ecma.String"
z1.dynamicTypeHintFullName shouldBe Seq()
z1.dynamicTypeHintFullName shouldBe Seq("__ecma.Number")
z2.typeFullName shouldBe "__ecma.String"
z2.dynamicTypeHintFullName shouldBe Seq()
z2.dynamicTypeHintFullName shouldBe Seq("__ecma.Number")
}

"resolve 'foo.d' field access object types correctly" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class TypeRecoveryPassTests extends PySrc2CpgFixture(withOssDataflow = false) {

"resolve 'x' identifier types despite shadowing" in {
val List(xOuterScope, xInnerScope) = cpg.identifier("x").take(2).l
xOuterScope.dynamicTypeHintFullName shouldBe Seq("__builtin.int", "__builtin.str")
xInnerScope.dynamicTypeHintFullName shouldBe Seq("__builtin.int", "__builtin.str")
xOuterScope.dynamicTypeHintFullName shouldBe Seq("__builtin.int")
xInnerScope.dynamicTypeHintFullName shouldBe Seq("__builtin.int")
}

"resolve 'y' and 'z' identifier collection types" in {
Expand Down Expand Up @@ -241,10 +241,10 @@ class TypeRecoveryPassTests extends PySrc2CpgFixture(withOssDataflow = false) {
.isIdentifier
.name("z")
.l
z1.typeFullName shouldBe "ANY"
z1.dynamicTypeHintFullName shouldBe Seq("__builtin.int", "__builtin.str")
z2.typeFullName shouldBe "ANY"
z2.dynamicTypeHintFullName shouldBe Seq("__builtin.int", "__builtin.str")
z1.typeFullName shouldBe "__builtin.str"
z1.dynamicTypeHintFullName shouldBe Seq("__builtin.int")
z2.typeFullName shouldBe "__builtin.str"
z2.dynamicTypeHintFullName shouldBe Seq("__builtin.int")
}

"resolve 'foo.d' field access object types correctly" in {
Expand Down Expand Up @@ -460,7 +460,7 @@ class TypeRecoveryPassTests extends PySrc2CpgFixture(withOssDataflow = false) {

"correctly determine that, despite being unable to resolve the correct method full name, that it is an internal method" in {
val Some(selfFindFound) = cpg.typeDecl(".*InstallationsDAO.*").ast.isCall.name("find_one").headOption: @unchecked
selfFindFound.callee.isExternal.toSeq shouldBe Seq(true, true)
selfFindFound.callee.isExternal.toSeq shouldBe Seq(true, true, true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ abstract class RecoverForXCompilationUnit[CompilationUnitType <: AstNode](
builder.setNodeProperty(n, PropertyNames.DYNAMIC_TYPE_HINT_FULL_NAME, Seq.empty)
else if types.size == 2 then
builder.setNodeProperty(n, PropertyNames.TYPE_FULL_NAME, types.last)
builder.setNodeProperty(n, PropertyNames.DYNAMIC_TYPE_HINT_FULL_NAME, Seq.empty)
builder.setNodeProperty(n, PropertyNames.DYNAMIC_TYPE_HINT_FULL_NAME, Seq(types.head))
else builder.setNodeProperty(n, PropertyNames.DYNAMIC_TYPE_HINT_FULL_NAME, types)

/** Allows one to modify the types assigned to locals.
Expand Down

0 comments on commit 677088b

Please sign in to comment.