Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Peva Blanchard committed Feb 12, 2024
1 parent 61b6ef6 commit 46dbd18
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ test ::= 'test' testRef '{'
}
given ::= 'given' '{' technoInputExchange *'}'
assert ::= 'assert' '{' rangeAssertion* '}'
rangeAssertion ::= uid 'between' dataExpression 'and' dataExpression { pin=1 }
rangeAssertion ::= uid 'between' dataExpression 'and' dataExpression { pin=2 }

/*
Substance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package ch.kleis.lcaac.plugin.language.ide.insight

import ch.kleis.lcaac.core.lang.expression.EBioBlockEntry
import ch.kleis.lcaac.core.math.basic.BasicNumber
import ch.kleis.lcaac.plugin.language.psi.stub.process.ProcessStubKeyIndex
import ch.kleis.lcaac.plugin.psi.LcaTerminalBioExchange
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.lang.annotation.HighlightSeverity
import com.intellij.testFramework.fixtures.BasePlatformTestCase
Expand Down Expand Up @@ -50,7 +47,7 @@ class LcaBioExchangeAnnotatorTest : BasePlatformTestCase() {
"""unresolved substance co2(compartment="air")"""
)
}
verify { mock.builder.range(element.substanceSpec) }
verify { mock.builder.range(element.substanceSpec!!) }
verify { mock.builder.highlightType(ProblemHighlightType.WARNING) }
verify { mock.builder.create() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class LcaDocumentGeneratorTest : BasePlatformTestCase() {
val ref = file
.getProcesses().first()
.getProducts().first()
.outputProductSpec
.outputProductSpec!!
// When
val actual = generateProduct(ref)
// Then
Expand All @@ -428,4 +428,4 @@ class LcaDocumentGeneratorTest : BasePlatformTestCase() {
""".trimIndent(), actual
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LcaTerminalTechnoInputExchangeAnnotatorTest : BasePlatformTestCase() {

// then
verify { mock.holder.newAnnotation(HighlightSeverity.WARNING, "Could not resolve carrot") }
verify { mock.builder.range(element.inputProductSpec) }
verify { mock.builder.range(element.inputProductSpec!!) }
verify { mock.builder.highlightType(ProblemHighlightType.WARNING) }
verify { mock.builder.create() }
}
Expand Down Expand Up @@ -86,7 +86,7 @@ class LcaTerminalTechnoInputExchangeAnnotatorTest : BasePlatformTestCase() {

// then
verify { mock.holder.newAnnotation(HighlightSeverity.WARNING, "Multiple candidates found for carrot") }
verify { mock.builder.range(element.inputProductSpec) }
verify { mock.builder.range(element.inputProductSpec!!) }
verify { mock.builder.highlightType(ProblemHighlightType.WARNING) }
verify { mock.builder.create() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,30 +379,4 @@ test t4 {
"between"
)
}

@Test
fun lookup_whenInRangeAssertion_forAnd() {
// Given
val filename = "${{}.javaClass.enclosingMethod.name}.lca"
fixture.configureByText(
filename, """
test t4 {
assert {
GWP between 20 kg <caret>
}
}
"""
)
fixture.complete(CompletionType.BASIC)

// When
val lookupElementStrings = fixture.lookupElementStrings

// Then
assertNotNull(lookupElementStrings)
assertSameElements(
lookupElementStrings!!,
"and"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DefaultRefFileResolverTest : BasePlatformTestCase() {
.getInputs().first().terminalTechnoInputExchange!!
val target = element
.inputProductSpec
.getProcessTemplateSpec()!!
?.getProcessTemplateSpec()!!
myFixture.createFile(
"$pkgName.left.lca", """
package $pkgName.left
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class DataRefExactNameMatcherScopeProcessorTest : ParsingTestCase("", "lca", Lca
val assignment = process.getLabelsList().first().labelAssignmentList.first()
val element = process.getInputs().first().terminalTechnoInputExchange!!
val dataRef = element
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getMatchLabels()!!
.labelSelectorList.first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class DataReferenceTest : BasePlatformTestCase() {
val element = process
.getInputs().first().terminalTechnoInputExchange!!
val ref = element
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.argumentList.first()
.parameterRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class LabelReferenceTest : BasePlatformTestCase() {
project, "$pkgName.p",
).first().getInputs().first().terminalTechnoInputExchange!!
val ref = element
.inputProductSpec.getProcessTemplateSpec()!!
.inputProductSpec!!.getProcessTemplateSpec()!!
.getMatchLabels()!!.labelSelectorList.first()
.labelRef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ParameterReferenceTest : BasePlatformTestCase() {
val process = ProcessStubKeyIndex.findProcesses(project, fqn).first()
val element = process.getInputs().first().terminalTechnoInputExchange!!
val ref = element
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.argumentList.first()
.parameterRef
Expand Down Expand Up @@ -100,7 +100,7 @@ class ParameterReferenceTest : BasePlatformTestCase() {
val process = ProcessStubKeyIndex.findProcesses(project, fqn).first()
val first = process.getInputs().first().terminalTechnoInputExchange!!
val ref = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.argumentList.first()
.parameterRef
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ch.kleis.lcaac.plugin.language.psi.reference

import ch.kleis.lcaac.plugin.language.psi.stub.process.ProcessStubKeyIndex
import ch.kleis.lcaac.plugin.psi.LcaTerminalTechnoInputExchange
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import junit.framework.TestCase
Expand Down Expand Up @@ -62,7 +61,7 @@ class ProcessReferenceFromPsiProcessRefTest : BasePlatformTestCase() {
val element = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val ref = element
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getProcessRef()

Expand Down Expand Up @@ -140,7 +139,7 @@ class ProcessReferenceFromPsiProcessRefTest : BasePlatformTestCase() {
val first = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val ref = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getProcessRef()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ch.kleis.lcaac.plugin.language.psi.reference

import ch.kleis.lcaac.plugin.language.psi.stub.process.ProcessStubKeyIndex
import ch.kleis.lcaac.plugin.psi.LcaTerminalTechnoInputExchange
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import junit.framework.TestCase
Expand Down Expand Up @@ -61,7 +60,7 @@ class ProcessReferenceFromPsiProcessTemplateSpecTest : BasePlatformTestCase() {
val element = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val ref = element
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!

// when
Expand Down Expand Up @@ -139,7 +138,7 @@ class ProcessReferenceFromPsiProcessTemplateSpecTest : BasePlatformTestCase() {
val first = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val ref = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ch.kleis.lcaac.plugin.language.psi.reference
import ch.kleis.lcaac.core.lang.expression.SubstanceType
import ch.kleis.lcaac.plugin.language.psi.stub.process.ProcessStubKeyIndex
import ch.kleis.lcaac.plugin.language.psi.stub.substance.SubstanceKeyIndex
import ch.kleis.lcaac.plugin.psi.LcaTerminalBioExchange
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -68,7 +67,7 @@ class SubstanceReferenceFromPsiSubstanceRefTest : BasePlatformTestCase() {
val element = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getEmissions().first().terminalBioExchange!!
val ref = element
.substanceSpec
.substanceSpec!!
.getSubstanceRef()

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ch.kleis.lcaac.plugin.language.psi.reference

import ch.kleis.lcaac.plugin.language.psi.stub.process.ProcessStubKeyIndex
import ch.kleis.lcaac.plugin.language.psi.stub.substance.SubstanceKeyIndex
import ch.kleis.lcaac.plugin.psi.LcaTerminalBioExchange
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import junit.framework.TestCase
Expand Down Expand Up @@ -64,7 +63,7 @@ class SubstanceReferenceFromPsiSubstanceSpecTest : BasePlatformTestCase() {
.getSubstanceSpec()

// when
val actual = substanceSpec.reference?.resolve()
val actual = substanceSpec?.reference?.resolve()

// then
val expected = SubstanceKeyIndex.Util.findSubstances(
Expand Down Expand Up @@ -122,7 +121,7 @@ class SubstanceReferenceFromPsiSubstanceSpecTest : BasePlatformTestCase() {
.getSubstanceSpec()

// when
val actual = substanceSpec.reference?.resolve()
val actual = substanceSpec?.reference?.resolve()

// then
assertNull(actual)
Expand Down Expand Up @@ -174,7 +173,7 @@ class SubstanceReferenceFromPsiSubstanceSpecTest : BasePlatformTestCase() {
.getSubstanceSpec()

// when
val actual = substanceSpec.reference?.resolve()
val actual = substanceSpec?.reference?.resolve()

// then
val expected = SubstanceKeyIndex.Util.findSubstances(
Expand Down Expand Up @@ -232,7 +231,7 @@ class SubstanceReferenceFromPsiSubstanceSpecTest : BasePlatformTestCase() {
.getSubstanceSpec()

// when
val actual = spec.reference
val actual = spec?.reference
?.variants?.map { (it as LookupElementBuilder).lookupString }
?.sorted() ?: emptyList()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package ch.kleis.lcaac.plugin.language.type_checker

import ch.kleis.lcaac.plugin.language.psi.stub.process.ProcessStubKeyIndex
import ch.kleis.lcaac.plugin.psi.LcaTerminalTechnoInputExchange
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import kotlin.test.assertFailsWith

@RunWith(JUnit4::class)
class LcaMatchLabelsEvaluatorTest : BasePlatformTestCase() {
override fun getTestDataPath(): String {
return ""
Expand All @@ -29,7 +31,7 @@ class LcaMatchLabelsEvaluatorTest : BasePlatformTestCase() {
val element = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val labels = element
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getMatchLabels()!!
val sut = LcaMatchLabelsEvaluator()
Expand Down Expand Up @@ -63,7 +65,7 @@ class LcaMatchLabelsEvaluatorTest : BasePlatformTestCase() {
val first = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val labels = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getMatchLabels()!!
val sut = LcaMatchLabelsEvaluator()
Expand Down Expand Up @@ -97,7 +99,7 @@ class LcaMatchLabelsEvaluatorTest : BasePlatformTestCase() {
val first = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val labels = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getMatchLabels()!!
val sut = LcaMatchLabelsEvaluator()
Expand Down Expand Up @@ -135,7 +137,7 @@ class LcaMatchLabelsEvaluatorTest : BasePlatformTestCase() {
).first()
.getInputs().first().terminalTechnoInputExchange!!
val labels = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getMatchLabels()!!
val sut = LcaMatchLabelsEvaluator()
Expand Down Expand Up @@ -173,7 +175,7 @@ class LcaMatchLabelsEvaluatorTest : BasePlatformTestCase() {
).first()
.getInputs().first().terminalTechnoInputExchange!!
val labels = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getMatchLabels()!!
val sut = LcaMatchLabelsEvaluator()
Expand Down Expand Up @@ -213,7 +215,7 @@ class LcaMatchLabelsEvaluatorTest : BasePlatformTestCase() {
).first()
.getInputs().first().terminalTechnoInputExchange!!
val labels = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getMatchLabels()!!
val sut = LcaMatchLabelsEvaluator()
Expand Down Expand Up @@ -248,7 +250,7 @@ class LcaMatchLabelsEvaluatorTest : BasePlatformTestCase() {
).first()
.getInputs().first().terminalTechnoInputExchange!!
val labels = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getMatchLabels()!!
val sut = LcaMatchLabelsEvaluator()
Expand Down Expand Up @@ -279,7 +281,7 @@ class LcaMatchLabelsEvaluatorTest : BasePlatformTestCase() {
).first()
.getInputs().first().terminalTechnoInputExchange!!
val labels = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getMatchLabels()!!
val sut = LcaMatchLabelsEvaluator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ch.kleis.lcaac.plugin.fixture.DimensionFixture
import ch.kleis.lcaac.plugin.language.psi.stub.global_assignment.GlobalAssigmentStubKeyIndex
import ch.kleis.lcaac.plugin.language.psi.stub.process.ProcessStubKeyIndex
import ch.kleis.lcaac.plugin.language.psi.stub.unit.UnitStubKeyIndex
import ch.kleis.lcaac.plugin.psi.LcaTerminalTechnoInputExchange
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import junit.framework.TestCase
import org.junit.Test
Expand Down Expand Up @@ -253,11 +252,11 @@ class PsiLcaTypeCheckerTest : BasePlatformTestCase() {
.findProcesses(project, "$pkgName.p", mapOf("geo" to "FR")).first()
.getInputs().first().terminalTechnoInputExchange!!
val target = first
.inputProductSpec
.inputProductSpec!!
.getProcessTemplateSpec()!!
.getMatchLabels()!!
.labelSelectorList.first()
.dataExpression
.dataExpression!!
val checker = PsiLcaTypeChecker()

// when
Expand Down

0 comments on commit 46dbd18

Please sign in to comment.