1
mirror of https://github.com/revanced/revanced-patcher synced 2025-09-10 05:30:49 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
semantic-release-bot
5eb8b428b9 chore(release): 3.2.1 [skip ci]
## [3.2.1](https://github.com/revanced/revanced-patcher/compare/v3.2.0...v3.2.1) (2022-08-02)

### Bug Fixes

* check if patch option requirement is met ([14a73bf](14a73bfcaf))
2022-08-02 20:43:26 +00:00
Sculas
3a118d9b9d Merge remote-tracking branch 'origin/main' into main 2022-08-02 22:41:41 +02:00
Sculas
14a73bfcaf fix: check if patch option requirement is met 2022-08-02 22:41:34 +02:00
4 changed files with 21 additions and 3 deletions

View File

@@ -1,3 +1,10 @@
## [3.2.1](https://github.com/revanced/revanced-patcher/compare/v3.2.0...v3.2.1) (2022-08-02)
### Bug Fixes
* check if patch option requirement is met ([14a73bf](https://github.com/revanced/revanced-patcher/commit/14a73bfcafac36bce2b8466788d460edde7a14fd))
# [3.2.0](https://github.com/revanced/revanced-patcher/compare/v3.1.0...v3.2.0) (2022-08-02)

View File

@@ -1,2 +1,2 @@
kotlin.code.style = official
version = 3.2.0
version = 3.2.1

View File

@@ -6,6 +6,7 @@ class NoSuchOptionException(val option: String) : Exception("No such option: $op
class IllegalValueException(val value: Any?) : Exception("Illegal value: $value")
class InvalidTypeException(val got: String, val expected: String) :
Exception("Invalid option value type: $got, expected $expected")
class RequirementNotMetException : Exception("null was passed into an option that requires a value")
/**
* A registry for an array of [PatchOption]s.
@@ -72,6 +73,9 @@ sealed class PatchOption<T>(
) {
var value: T? = default
set(value) {
if (value == null && required) {
throw RequirementNotMetException()
}
if (!validator(value)) {
throw IllegalValueException(value)
}

View File

@@ -39,10 +39,10 @@ internal class PatchOptionsTest {
@Test
fun `should be able to set value to null`() {
// Sadly, doing:
// > options["key1"] = null
// > options["key2"] = null
// is not possible because Kotlin
// cannot reify the type "Nothing?".
options.nullify("key1")
options.nullify("key2")
}
@Test
@@ -65,4 +65,11 @@ internal class PatchOptionsTest {
options["key3"] = "this value is not an allowed option"
}
}
@Test
fun `should fail because of the requirement is not met`() {
assertThrows<RequirementNotMetException> {
options.nullify("key1")
}
}
}