Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hacks similar to contest 2023 ones #2676

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}'"
}