Skip to content

Commit

Permalink
fix testIf
Browse files Browse the repository at this point in the history
  • Loading branch information
maximiliankaul committed Sep 4, 2023
1 parent 79ecad6 commit 803ade6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ interface PythonAST {
*
* ast.expr = class expr(AST)
*/
abstract class ExprBase(pyObject: PyObject) : AST(pyObject)
abstract class ExprBase(pyObject: PyObject) : AST(pyObject), WithPythonLocation

/**
* ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class PythonLanguageFrontend(language: Language<PythonLanguageFrontend>, ctx: Tr
mutableLines[lastLineIdx].length + physicalLocation.region.startColumn -
physicalLocation.region.endColumn
mutableLines[lastLineIdx] = mutableLines[lastLineIdx].dropLast(toRemove)
return mutableLines.toString()
return mutableLines.joinToString(separator = "\n") // TODO
}
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,15 @@ class PythonFrontendTest : BaseTest() {
val body = main.body as? CompoundStatement
assertNotNull(body)

val sel =
(body.statements.first() as? DeclarationStatement)?.singleDeclaration
as? VariableDeclaration
val sel = (body.statements.first() as? AssignExpression)?.declarations?.first()
assertNotNull(sel)
assertLocalName("sel", sel)
assertEquals(tu.primitiveType("bool"), sel.type)

val initializer = sel.initializer as? Literal<*>
assertNotNull(initializer)
assertEquals(tu.primitiveType("bool"), initializer.type)
assertEquals("True", initializer.code)
val firstAssignment = sel.firstAssignment as? Literal<*>
assertNotNull(firstAssignment)
assertEquals(tu.primitiveType("bool"), firstAssignment.type)
assertEquals("True", firstAssignment.code)

val `if` = body.statements[1] as? IfStatement
assertNotNull(`if`)
Expand Down

0 comments on commit 803ade6

Please sign in to comment.