mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-04-30 21:34:25 +02:00
refactor: rename helper methods for tests
This commit is contained in:
parent
43d6868d1f
commit
2a453d51a8
@ -41,7 +41,7 @@ private object InstructionExtensionsTest {
|
|||||||
).let { testMethod = it.toMutable() }
|
).let { testMethod = it.toMutable() }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addInstructionsToImplementationIndexed() = applyOnImplementation {
|
fun addInstructionsToImplementationIndexed() = applyToImplementation {
|
||||||
addInstructions(5, getTestInstructions(5..6)).also {
|
addInstructions(5, getTestInstructions(5..6)).also {
|
||||||
assertRegisterIs(5, 5)
|
assertRegisterIs(5, 5)
|
||||||
assertRegisterIs(6, 6)
|
assertRegisterIs(6, 6)
|
||||||
@ -51,7 +51,7 @@ private object InstructionExtensionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addInstructionsToImplementation() = applyOnImplementation {
|
fun addInstructionsToImplementation() = applyToImplementation {
|
||||||
addInstructions(getTestInstructions(10..11)).also {
|
addInstructions(getTestInstructions(10..11)).also {
|
||||||
assertRegisterIs(10, 10)
|
assertRegisterIs(10, 10)
|
||||||
assertRegisterIs(11, 11)
|
assertRegisterIs(11, 11)
|
||||||
@ -59,19 +59,19 @@ private object InstructionExtensionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun removeInstructionsFromImplementationIndexed() = applyOnImplementation {
|
fun removeInstructionsFromImplementationIndexed() = applyToImplementation {
|
||||||
removeInstructions(5, 5).also { assertRegisterIs(4, 4) }
|
removeInstructions(5, 5).also { assertRegisterIs(4, 4) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun removeInstructionsFromImplementation() = applyOnImplementation {
|
fun removeInstructionsFromImplementation() = applyToImplementation {
|
||||||
removeInstructions(0).also { assertRegisterIs(9, 9) }
|
removeInstructions(0).also { assertRegisterIs(9, 9) }
|
||||||
removeInstructions(1).also { assertRegisterIs(1, 0) }
|
removeInstructions(1).also { assertRegisterIs(1, 0) }
|
||||||
removeInstructions(2).also { assertRegisterIs(3, 0) }
|
removeInstructions(2).also { assertRegisterIs(3, 0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun replaceInstructionsInImplementationIndexed() = applyOnImplementation {
|
fun replaceInstructionsInImplementationIndexed() = applyToImplementation {
|
||||||
replaceInstructions(5, getTestInstructions(0..1)).also {
|
replaceInstructions(5, getTestInstructions(0..1)).also {
|
||||||
assertRegisterIs(0, 5)
|
assertRegisterIs(0, 5)
|
||||||
assertRegisterIs(1, 6)
|
assertRegisterIs(1, 6)
|
||||||
@ -80,27 +80,27 @@ private object InstructionExtensionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addInstructionToMethodIndexed() = applyOnMethod {
|
fun addInstructionToMethodIndexed() = applyToMethod {
|
||||||
addInstruction(5, TestInstruction(0)).also { assertRegisterIs(0, 5) }
|
addInstruction(5, TestInstruction(0)).also { assertRegisterIs(0, 5) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addInstructionToMethod() = applyOnMethod {
|
fun addInstructionToMethod() = applyToMethod {
|
||||||
addInstruction(TestInstruction(0)).also { assertRegisterIs(0, 10) }
|
addInstruction(TestInstruction(0)).also { assertRegisterIs(0, 10) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addSmaliInstructionToMethodIndexed() = applyOnMethod {
|
fun addSmaliInstructionToMethodIndexed() = applyToMethod {
|
||||||
addInstruction(5, getTestSmaliInstruction(0)).also { assertRegisterIs(0, 5) }
|
addInstruction(5, getTestSmaliInstruction(0)).also { assertRegisterIs(0, 5) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addSmaliInstructionToMethod() = applyOnMethod {
|
fun addSmaliInstructionToMethod() = applyToMethod {
|
||||||
addInstruction(getTestSmaliInstruction(0)).also { assertRegisterIs(0, 10) }
|
addInstruction(getTestSmaliInstruction(0)).also { assertRegisterIs(0, 10) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addInstructionsToMethodIndexed() = applyOnMethod {
|
fun addInstructionsToMethodIndexed() = applyToMethod {
|
||||||
addInstructions(5, getTestInstructions(0..1)).also {
|
addInstructions(5, getTestInstructions(0..1)).also {
|
||||||
assertRegisterIs(0, 5)
|
assertRegisterIs(0, 5)
|
||||||
assertRegisterIs(1, 6)
|
assertRegisterIs(1, 6)
|
||||||
@ -110,7 +110,7 @@ private object InstructionExtensionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addInstructionsToMethod() = applyOnMethod {
|
fun addInstructionsToMethod() = applyToMethod {
|
||||||
addInstructions(getTestInstructions(0..1)).also {
|
addInstructions(getTestInstructions(0..1)).also {
|
||||||
assertRegisterIs(0, 10)
|
assertRegisterIs(0, 10)
|
||||||
assertRegisterIs(1, 11)
|
assertRegisterIs(1, 11)
|
||||||
@ -120,7 +120,7 @@ private object InstructionExtensionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addSmaliInstructionsToMethodIndexed() = applyOnMethod {
|
fun addSmaliInstructionsToMethodIndexed() = applyToMethod {
|
||||||
addInstructionsWithLabels(5, getTestSmaliInstructions(0..1)).also {
|
addInstructionsWithLabels(5, getTestSmaliInstructions(0..1)).also {
|
||||||
assertRegisterIs(0, 5)
|
assertRegisterIs(0, 5)
|
||||||
assertRegisterIs(1, 6)
|
assertRegisterIs(1, 6)
|
||||||
@ -130,7 +130,7 @@ private object InstructionExtensionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addSmaliInstructionsToMethod() = applyOnMethod {
|
fun addSmaliInstructionsToMethod() = applyToMethod {
|
||||||
addInstructions(getTestSmaliInstructions(0..1)).also {
|
addInstructions(getTestSmaliInstructions(0..1)).also {
|
||||||
assertRegisterIs(0, 10)
|
assertRegisterIs(0, 10)
|
||||||
assertRegisterIs(1, 11)
|
assertRegisterIs(1, 11)
|
||||||
@ -140,7 +140,7 @@ private object InstructionExtensionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addSmaliInstructionsWithExternalLabelToMethodIndexed() = applyOnMethod {
|
fun addSmaliInstructionsWithExternalLabelToMethodIndexed() = applyToMethod {
|
||||||
val label = ExternalLabel("testLabel", getInstruction(5))
|
val label = ExternalLabel("testLabel", getInstruction(5))
|
||||||
|
|
||||||
addInstructionsWithLabels(
|
addInstructionsWithLabels(
|
||||||
@ -160,7 +160,7 @@ private object InstructionExtensionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun removeInstructionFromMethodIndexed() = applyOnMethod {
|
fun removeInstructionFromMethodIndexed() = applyToMethod {
|
||||||
removeInstruction(5).also {
|
removeInstruction(5).also {
|
||||||
assertRegisterIs(4, 4)
|
assertRegisterIs(4, 4)
|
||||||
assertRegisterIs(6, 5)
|
assertRegisterIs(6, 5)
|
||||||
@ -168,24 +168,24 @@ private object InstructionExtensionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun removeInstructionsFromMethodIndexed() = applyOnMethod {
|
fun removeInstructionsFromMethodIndexed() = applyToMethod {
|
||||||
removeInstructions(5, 5).also { assertRegisterIs(4, 4) }
|
removeInstructions(5, 5).also { assertRegisterIs(4, 4) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun removeInstructionsFromMethod() = applyOnMethod {
|
fun removeInstructionsFromMethod() = applyToMethod {
|
||||||
removeInstructions(0).also { assertRegisterIs(9, 9) }
|
removeInstructions(0).also { assertRegisterIs(9, 9) }
|
||||||
removeInstructions(1).also { assertRegisterIs(1, 0) }
|
removeInstructions(1).also { assertRegisterIs(1, 0) }
|
||||||
removeInstructions(2).also { assertRegisterIs(3, 0) }
|
removeInstructions(2).also { assertRegisterIs(3, 0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun replaceInstructionInMethodIndexed() = applyOnMethod {
|
fun replaceInstructionInMethodIndexed() = applyToMethod {
|
||||||
replaceInstruction(5, TestInstruction(0)).also { assertRegisterIs(0, 5) }
|
replaceInstruction(5, TestInstruction(0)).also { assertRegisterIs(0, 5) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun replaceInstructionsInMethodIndexed() = applyOnMethod {
|
fun replaceInstructionsInMethodIndexed() = applyToMethod {
|
||||||
replaceInstructions(5, getTestInstructions(0..1)).also {
|
replaceInstructions(5, getTestInstructions(0..1)).also {
|
||||||
assertRegisterIs(0, 5)
|
assertRegisterIs(0, 5)
|
||||||
assertRegisterIs(1, 6)
|
assertRegisterIs(1, 6)
|
||||||
@ -194,7 +194,7 @@ private object InstructionExtensionsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun replaceSmaliInstructionsInMethodIndexed() = applyOnMethod {
|
fun replaceSmaliInstructionsInMethodIndexed() = applyToMethod {
|
||||||
replaceInstructions(5, getTestSmaliInstructions(0..1)).also {
|
replaceInstructions(5, getTestSmaliInstructions(0..1)).also {
|
||||||
assertRegisterIs(0, 5)
|
assertRegisterIs(0, 5)
|
||||||
assertRegisterIs(1, 6)
|
assertRegisterIs(1, 6)
|
||||||
@ -204,11 +204,11 @@ private object InstructionExtensionsTest {
|
|||||||
|
|
||||||
// region Helper methods
|
// region Helper methods
|
||||||
|
|
||||||
private fun applyOnImplementation(block: MutableMethodImplementation.() -> Unit) {
|
private fun applyToImplementation(block: MutableMethodImplementation.() -> Unit) {
|
||||||
testMethodImplementation.apply(block)
|
testMethodImplementation.apply(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun applyOnMethod(block: MutableMethod.() -> Unit) {
|
private fun applyToMethod(block: MutableMethod.() -> Unit) {
|
||||||
testMethod.apply(block)
|
testMethod.apply(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user