Fixed tests.

This commit is contained in:
Chris Hodges 2021-07-19 13:35:45 +02:00
parent c13e488ab8
commit b966623765
3 changed files with 21 additions and 11 deletions

View File

@ -63,10 +63,8 @@ class M68kLocalLabelReference(element: M68kSymbolReference) : PsiPolyVariantRefe
}
override fun getVariants(): Array<Any> {
return findLocalLabels(element) { true }.asSequence()
.distinct()
return findLocalLabels(element) { true }
.map { LookupElementBuilder.createWithIcon(it) }
.toList()
.toTypedArray()
}
}

View File

@ -1,5 +1,6 @@
package de.platon42.intellij.plugins.m68k.refs
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.psi.PsiElement
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import de.platon42.intellij.jupiter.LightCodeInsightExtension
@ -8,6 +9,7 @@ import de.platon42.intellij.jupiter.TestDataPath
import de.platon42.intellij.jupiter.TestDataSubPath
import de.platon42.intellij.plugins.m68k.AbstractM68kTest
import de.platon42.intellij.plugins.m68k.psi.M68kLocalLabel
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolReference
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@ -18,20 +20,20 @@ import org.junit.jupiter.api.extension.ExtendWith
internal class M68kReferenceContributorTest : AbstractM68kTest() {
@Test
internal fun reference_to_dot_local_label(@MyFixture myFixture: CodeInsightTestFixture) {
// val reference = myFixture.getReferenceAtCaretPositionWithAssertion("dot_local_label.asm")
// assertThat(reference.element).isInstanceOf(M68kSym)
internal fun reference_to_dot_local_label_can_be_renamed(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByFile("dot_local_label.asm")
assertThat(myFixture.elementAtCaret).isInstanceOf(M68kLocalLabel::class.java)
.extracting(PsiElement::getText).isEqualTo(".loop")
myFixture.renameElementAtCaret(".narf")
myFixture.checkResultByFile("dot_local_label_after_rename.asm")
}
@Test
internal fun reference_to_multiple_conditional_local_label_dollar(@MyFixture myFixture: CodeInsightTestFixture) {
internal fun reference_to_multiple_conditional_local_label_dollar_and_variants(@MyFixture myFixture: CodeInsightTestFixture) {
val reference = myFixture.getReferenceAtCaretPositionWithAssertion("multiple_conditional_local_label_dollar.asm")
assertThat(reference.element).isInstanceOf(M68kLocalLabel::class.java)
myFixture.configureByFile("multiple_conditional_local_label_dollar.asm")
assertThat(myFixture.elementAtCaret).isInstanceOf(M68kLocalLabel::class.java)
.extracting(PsiElement::getText).isEqualTo("loop$")
assertThat(reference.element).isInstanceOf(M68kSymbolReference::class.java)
assertThat(reference.variants).hasOnlyElementsOfType(LookupElementBuilder::class.java)
.extracting<String> { (it as LookupElementBuilder).lookupString }
.containsExactlyInAnyOrderElementsOf(listOf("loop$", "loop$", ".skip"))
}
}

View File

@ -0,0 +1,10 @@
main
tst.w d1
beq.s .skip
moveq.l #42,d0
.narf move.l d0,(a0)+
dbra d0,.narf
.skip subq.w #1,d1
beq.s .narf
rts