Skip to content

Commit

Permalink
Hacks similar to contest 2023 ones (#2676)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorkaKulikov authored Nov 7, 2023
1 parent 79cf54b commit d5cdd8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ enum class RuntimeExceptionTestsBehaviour(
// Get is mandatory because of the initialization order of the inheritors.
// Otherwise, in some cases we could get an incorrect value
companion object : CodeGenerationSettingBox {
override val defaultItem: RuntimeExceptionTestsBehaviour get() = FAIL
override val defaultItem: RuntimeExceptionTestsBehaviour get() = PASS
override val allItems: List<RuntimeExceptionTestsBehaviour> = values().toList()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,14 @@ abstract class CgAbstractRenderer(

val isBlockTooLarge = workaround(LONG_CODE_FRAGMENTS) { block.size > LARGE_CODE_BLOCK_SIZE }

if (isBlockTooLarge) {
print("/*")
println(" This block of code is ${block.size} lines long and could lead to compilation error")
}

withIndent {
for (statement in block) {
statement.accept(this)
if (!isBlockTooLarge) {
withIndent {
for (statement in block) {
statement.accept(this)
}
}
}

if (isBlockTooLarge) println("*/")

print("}")

if (printNextLine) println()
Expand Down Expand Up @@ -982,6 +977,6 @@ abstract class CgAbstractRenderer(
/**
* @see [LONG_CODE_FRAGMENTS]
*/
private const val LARGE_CODE_BLOCK_SIZE: Int = 1000
private const val LARGE_CODE_BLOCK_SIZE: Int = 150
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ import java.nio.file.FileSystems


fun String.toRelativeRawPath(): String {
return "os.path.dirname(__file__) + r'${FileSystems.getDefault().separator}${this}'"
val dirname = "os.path.dirname(__file__)"
if (this.isEmpty()) {
return dirname
}
return "$dirname + r'${FileSystems.getDefault().separator}${this}'"
}

0 comments on commit d5cdd8a

Please sign in to comment.