Skip to content

Commit

Permalink
Merge pull request #594 from smeup/bugfix/LS24003774/unlimited-string…
Browse files Browse the repository at this point in the history
…-duplications
  • Loading branch information
lanarimarco authored Aug 14, 2024
2 parents bbe79d8 + 9fe1104 commit 58a4998
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2224,6 +2224,7 @@ internal fun getProgramNameToCopyBlocks(): ProgramNameToCopyBlocks {
}

internal fun <T : AbstractDataDefinition> List<T>.removeDuplicatedDataDefinition(): List<T> {
// NOTE: With current logic when type matches on duplications the first definition wins
val dataDefinitionMap = mutableMapOf<String, AbstractDataDefinition>()
return removeUnnecessaryRecordFormat().filter {
val dataDefinition = dataDefinitionMap[it.name]
Expand All @@ -2241,14 +2242,17 @@ internal fun <T : AbstractDataDefinition> List<T>.removeDuplicatedDataDefinition

internal fun AbstractDataDefinition.matchType(dataDefinition: AbstractDataDefinition): Boolean {
fun Type.matchType(other: Any?): Boolean {
if (this is NumberType && other is NumberType) {
val resultDigits = this.entireDigits == other.entireDigits && this.decimalDigits == other.decimalDigits
if (rpgType?.isNotBlank()!! && other.rpgType?.isNotEmpty()!!) {
return resultDigits && rpgType == other.rpgType
// TODO: Improve logic for StringType/UnlimitedStringType matching
return when {
this is NumberType && other is NumberType -> {
val resultDigits = this.entireDigits == other.entireDigits && this.decimalDigits == other.decimalDigits
if (rpgType?.isNotBlank()!! && other.rpgType?.isNotEmpty()!!) {
return resultDigits && rpgType == other.rpgType
}
resultDigits
}
return resultDigits
} else {
return this == other
this is UnlimitedStringType && other is StringType -> true
else -> this == other
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,4 +548,10 @@ open class MULANGT02ConstAndDSpecTest : MULANGTTest() {
val expected = listOf("ok")
assertEquals(expected, "smeup/MUDRNRAPU00245".outputOf(configuration = smeupConfig))
}

@Test
fun executeMUDRNRAPU00246() {
val expected = listOf("ok")
assertEquals(expected, "smeup/MUDRNRAPU00246".outputOf(configuration = smeupConfig))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
D £DBG_Str S 2

********** PREPROCESSOR COPYSTART QILEGEN,£UIBDS
V* ==============================================================
V* MODIFICHE Ril. T Au Descrizione
V* gg/mm/aa nn.mm i xx Breve descrizione
V* ==============================================================
V* 10/05/21 V5R1 BONMAI Creazione
V* 18/05/24 V6R1 FORDAR Estensione
V* /COPY £UIBDS
V* ==============================================================
*--------------------------------------------------------------------------------------------*
*IF NOT DEFINED(UIBDS_INCLUDED)
*DEFINE UIBDS_INCLUDED
D £UIBDS DS 10
D £UIBME 0
*--------------------------------------------------------------------------------------------*
********** PREPROCESSOR COPYEND QILEGEN,£UIBDS

DXUIBME S LIKE(£UIBME)

*--------------------------------------------------------------*
RD* Impostazioni iniziali
*--------------------------------------------------------------*
C IMP0 BEGSR
C IF %SUBST(£UIBME:1:3)='STA'
C MOVEL(P) 'STA' XUIBME 10
C ELSE
C MOVEL(P) £UIBME XUIBME 10
C ENDIF
C ENDSR

C EVAL £DBG_Str='ok'
C £DBG_Str DSPLY

0 comments on commit 58a4998

Please sign in to comment.