[test framework] utility method for temporary setting a registry value

GitOrigin-RevId: dcfd782b7546cd4ff1948f20fe3b89f76c802a0f
This commit is contained in:
Roman Shevchenko
2019-07-24 22:03:18 +03:00
committed by intellij-monorepo-bot
parent ac3046b828
commit b846a86e9e
@@ -0,0 +1,14 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
@file:JvmName("RegistryTestUtil")
package com.intellij.openapi.util.registry
fun RegistryValue.withValue(tempValue: Boolean, block: () -> Unit) {
val currentValue = asBoolean()
try {
setValue(tempValue)
block()
}
finally {
setValue(currentValue)
}
}