Skip to content

Commit a1334cc

Browse files
committed
refactor: CLEARDS01 to DSPERF02
1 parent 4a8675f commit a1334cc

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/DSPerformanceTest.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ package com.smeup.rpgparser.evaluation
1818

1919
import com.smeup.rpgparser.AbstractTest
2020
import com.smeup.rpgparser.PerformanceTest
21+
import com.smeup.rpgparser.execution.Configuration
2122
import com.smeup.rpgparser.jvminterop.JavaSystemInterface
2223
import org.junit.Test
2324
import org.junit.experimental.categories.Category
25+
import java.time.Duration
26+
import java.util.*
2427
import kotlin.test.assertTrue
28+
import kotlin.time.Duration.Companion.milliseconds
29+
import kotlin.time.DurationUnit
2530

2631
open class DSPerformanceTest : AbstractTest() {
2732

@@ -45,4 +50,24 @@ open class DSPerformanceTest : AbstractTest() {
4550
assertTrue(performanceRatio > 10,
4651
"performanceRatio must be at least 10")
4752
}
53+
54+
@Test
55+
@Category(PerformanceTest::class)
56+
fun executeDSPERF02() {
57+
lateinit var start: Date
58+
lateinit var end: Date
59+
val configuration = Configuration().apply {
60+
jarikoCallback.onEnterPgm = { _, _ ->
61+
start = Date()
62+
}
63+
jarikoCallback.onExitPgm = { _, _, _ ->
64+
end = Date()
65+
}
66+
}
67+
"DSPERF02".outputOf(configuration = configuration)
68+
val duration = Duration.between(start.toInstant(), end.toInstant()).toMillis().milliseconds
69+
println(duration)
70+
// Currently the assertion is really empirical
71+
assertTrue(duration.toLong(DurationUnit.MILLISECONDS) < 1000, "Duration must be less than 1 second")
72+
}
4873
}

rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
15+
*
1516
*/
1617

1718
package com.smeup.rpgparser.evaluation
@@ -30,12 +31,10 @@ import org.junit.Test
3031
import org.junit.experimental.categories.Category
3132
import java.math.BigDecimal
3233
import java.text.SimpleDateFormat
33-
import java.time.Duration
3434
import java.time.LocalDate
3535
import java.time.format.DateTimeFormatter
3636
import java.util.*
3737
import kotlin.test.*
38-
import kotlin.time.Duration.Companion.milliseconds
3938

4039
open class InterpreterTest : AbstractTest() {
4140

@@ -2626,20 +2625,4 @@ Test 6
26262625
// Test that the program does not throw a NullPointerException
26272626
"NULLPTR01".outputOf()
26282627
}
2629-
2630-
@Test
2631-
fun executeCLEARDS01() {
2632-
lateinit var start: Date
2633-
lateinit var end: Date
2634-
val configuration = Configuration().apply {
2635-
jarikoCallback.onEnterPgm = { _, _ ->
2636-
start = Date()
2637-
}
2638-
jarikoCallback.onExitPgm = { _, _, _ ->
2639-
end = Date()
2640-
}
2641-
}
2642-
"CLEARDS01".outputOf(configuration = configuration)
2643-
println(Duration.between(start.toInstant(), end.toInstant()).toMillis().milliseconds)
2644-
}
26452628
}

0 commit comments

Comments
 (0)