Skip to content

Commit c02998b

Browse files
rchowellalancai98
authored andcommitted
Clean up tests and get things passing
1 parent 01ed568 commit c02998b

File tree

12 files changed

+82
-79
lines changed

12 files changed

+82
-79
lines changed

examples/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ application {
2424

2525
dependencies {
2626
implementation(project(":partiql-lang"))
27+
implementation(project(":partiql-eval"))
2728
implementation(project(":partiql-types"))
2829
implementation(Deps.awsSdkS3)
2930
}

partiql-cli/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ plugins {
1919
}
2020

2121
dependencies {
22+
// EvaluatingCompiler / ExprValue
2223
implementation(project(":partiql-lang"))
24+
//
2325
implementation(project(":partiql-ast"))
26+
implementation(project(":partiql-eval"))
2427
implementation(project(":partiql-parser"))
2528
implementation(project(":partiql-plan"))
2629
implementation(project(":partiql-planner"))
2730
implementation(project(":partiql-types"))
28-
implementation(project(":plugins:partiql-local"))
2931
implementation(project(":partiql-spi"))
32+
implementation(project(":plugins:partiql-local"))
3033
implementation(Deps.csv)
3134
implementation(Deps.awsSdkBom)
3235
implementation(Deps.awsSdkDynamodb)
@@ -36,6 +39,7 @@ dependencies {
3639
implementation(Deps.joda)
3740
implementation(Deps.picoCli)
3841
implementation(Deps.kotlinReflect)
42+
3943
testImplementation(Deps.mockito)
4044
}
4145

Lines changed: 66 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.partiql.lang.eval
22

3-
import junitparams.Parameters
43
import org.junit.jupiter.api.Test
4+
import org.junit.jupiter.params.ParameterizedTest
5+
import org.junit.jupiter.params.provider.MethodSource
56
import org.partiql.errors.ErrorCode
67
import org.partiql.errors.Property
78
import org.partiql.lang.util.propertyValueMapOf
@@ -14,25 +15,10 @@ import java.math.BigInteger
1415
*/
1516
class EvaluatingCompilerIntTest : EvaluatorTestBase() {
1617

17-
private val closeToMaxLong = (Long.MAX_VALUE - 1)
18-
private val closeToMinLong = (Long.MIN_VALUE + 1)
19-
20-
private val bigInt = BigInteger.valueOf(Long.MAX_VALUE).times(BigInteger.valueOf(2))
21-
private val negativeBigInt = BigInteger.valueOf(Long.MIN_VALUE).times(BigInteger.valueOf(2))
22-
23-
@Test
24-
@Parameters
18+
@ParameterizedTest
19+
@MethodSource("parametersForValues")
2520
fun values(pair: Pair<String, String>) = assertPair(pair)
2621

27-
fun parametersForValues(): List<Pair<String, String>> {
28-
val parameters = mutableListOf<Pair<String, String>>()
29-
parameters.add("$closeToMaxLong" to "$closeToMaxLong")
30-
parameters.add("$closeToMinLong" to "$closeToMinLong")
31-
parameters.add("`0x00ffFFffFFffFFff`" to "72057594037927935")
32-
33-
return parameters
34-
}
35-
3622
@Test
3723
fun bigInt() = runEvaluatorErrorTestCase(
3824
"$bigInt",
@@ -47,15 +33,10 @@ class EvaluatingCompilerIntTest : EvaluatorTestBase() {
4733
expectedErrorContext = propertyValueMapOf(1, 2)
4834
)
4935

50-
@Test
51-
@Parameters
52-
fun plus(pair: Pair<String, String>) = assertPair(pair)
53-
54-
fun parametersForPlus(): List<Pair<String, String>> {
55-
val parameters = mutableListOf<Pair<String, String>>()
56-
// Deliberately kept in case we need to manually add test case in the future.
57-
return parameters
58-
}
36+
// EMPTY
37+
// @ParameterizedTest
38+
// @MethodSource("parametersForPlus")
39+
// fun plus(pair: Pair<String, String>) = assertPair(pair)
5940

6041
@Test
6142
fun plusOverflow() = runEvaluatorErrorTestCase(
@@ -65,15 +46,10 @@ class EvaluatingCompilerIntTest : EvaluatorTestBase() {
6546
expectedPermissiveModeResult = "MISSING"
6647
)
6748

68-
@Test
69-
@Parameters
70-
fun minus(pair: Pair<String, String>) = assertPair(pair)
71-
72-
fun parametersForMinus(): List<Pair<String, String>> {
73-
val parameters = mutableListOf<Pair<String, String>>()
74-
// Deliberately kept in case we need to manually add test case in the future.
75-
return parameters
76-
}
49+
// EMPTY
50+
// @ParameterizedTest
51+
// @MethodSource("parametersForMinus")
52+
// fun minus(pair: Pair<String, String>) = assertPair(pair)
7753

7854
@Test
7955
fun minusUnderflow() = runEvaluatorErrorTestCase(
@@ -83,18 +59,10 @@ class EvaluatingCompilerIntTest : EvaluatorTestBase() {
8359
expectedPermissiveModeResult = "MISSING"
8460
)
8561

86-
@Test
87-
@Parameters
62+
@ParameterizedTest
63+
@MethodSource("parametersForTimes")
8864
fun times(pair: Pair<String, String>) = assertPair(pair)
8965

90-
fun parametersForTimes(): List<Pair<String, String>> {
91-
val parameters = mutableListOf<Pair<String, String>>()
92-
93-
parameters.add("${Long.MAX_VALUE} * -1" to "-${Long.MAX_VALUE}")
94-
95-
return parameters
96-
}
97-
9866
@Test
9967
fun timesOverflow() = runEvaluatorErrorTestCase(
10068
"$closeToMaxLong * 2",
@@ -111,18 +79,10 @@ class EvaluatingCompilerIntTest : EvaluatorTestBase() {
11179
expectedPermissiveModeResult = "MISSING"
11280
)
11381

114-
@Test
115-
@Parameters
82+
@ParameterizedTest
83+
@MethodSource("parametersForDivision")
11684
fun division(pair: Pair<String, String>) = assertPair(pair)
11785

118-
fun parametersForDivision(): List<Pair<String, String>> {
119-
val parameters = mutableListOf<Pair<String, String>>()
120-
121-
parameters.add("${Long.MAX_VALUE} / -1" to "-${Long.MAX_VALUE}")
122-
123-
return parameters
124-
}
125-
12686
@Test
12787
fun divisionUnderflow() = runEvaluatorErrorTestCase(
12888
"${Long.MIN_VALUE} / -1",
@@ -131,27 +91,10 @@ class EvaluatingCompilerIntTest : EvaluatorTestBase() {
13191
expectedPermissiveModeResult = "MISSING"
13292
)
13393

134-
@Test
135-
@Parameters
94+
@ParameterizedTest
95+
@MethodSource("parametersForBitwiseAnd")
13696
fun bitwiseAnd(pair: Pair<String, String>) = assertPair(pair)
13797

138-
fun parametersForBitwiseAnd(): List<Pair<String, String>> {
139-
val parameters = mutableListOf<Pair<String, String>>()
140-
141-
parameters.add("1 & 2" to "0")
142-
parameters.add("3 & 5" to "1")
143-
parameters.add("5 & 7" to "5")
144-
parameters.add("31 & 15 & 7 & 3 & 1" to "1")
145-
parameters.add("1 + 5 & 5" to "4")
146-
parameters.add("(1 + 5) & 5" to "4")
147-
parameters.add("1 + (5 & 5)" to "6")
148-
parameters.add("5 & 5 + 1" to "4")
149-
parameters.add("(5 & 5) + 1" to "6")
150-
parameters.add("5 & (5 + 1)" to "4")
151-
152-
return parameters
153-
}
154-
15598
@Test
15699
fun castBigInt() = runEvaluatorErrorTestCase(
157100
"cast('$bigInt' as int)",
@@ -202,4 +145,52 @@ class EvaluatingCompilerIntTest : EvaluatorTestBase() {
202145
val (query, expected) = pair
203146
runEvaluatorTestCase(query, expectedResult = expected)
204147
}
148+
149+
companion object {
150+
151+
private val closeToMaxLong = (Long.MAX_VALUE - 1)
152+
private val closeToMinLong = (Long.MIN_VALUE + 1)
153+
154+
private val bigInt = BigInteger.valueOf(Long.MAX_VALUE).times(BigInteger.valueOf(2))
155+
private val negativeBigInt = BigInteger.valueOf(Long.MIN_VALUE).times(BigInteger.valueOf(2))
156+
157+
@JvmStatic
158+
fun parametersForValues(): List<Pair<String, String>> = listOf(
159+
"$closeToMaxLong" to "$closeToMaxLong",
160+
"$closeToMinLong" to "$closeToMinLong",
161+
"`0x00ffFFffFFffFFff`" to "72057594037927935",
162+
)
163+
164+
// Deliberately kept in case we need to manually add test case in the future.
165+
@JvmStatic
166+
fun parametersForPlus(): List<Pair<String, String>> = emptyList()
167+
168+
@JvmStatic
169+
fun parametersForTimes(): List<Pair<String, String>> = listOf(
170+
"${Long.MAX_VALUE} * -1" to "-${Long.MAX_VALUE}"
171+
)
172+
173+
@JvmStatic
174+
fun parametersForDivision(): List<Pair<String, String>> = listOf(
175+
"${Long.MAX_VALUE} / -1" to "-${Long.MAX_VALUE}",
176+
)
177+
178+
// Deliberately kept in case we need to manually add test case in the future.
179+
@JvmStatic
180+
fun parametersForMinus(): List<Pair<String, String>> = emptyList()
181+
182+
@JvmStatic
183+
fun parametersForBitwiseAnd(): List<Pair<String, String>> = listOf(
184+
"1 & 2" to "0",
185+
"3 & 5" to "1",
186+
"5 & 7" to "5",
187+
"31 & 15 & 7 & 3 & 1" to "1",
188+
"1 + 5 & 5" to "4",
189+
"(1 + 5) & 5" to "4",
190+
"1 + (5 & 5)" to "6",
191+
"5 & 5 + 1" to "4",
192+
"(5 & 5) + 1" to "6",
193+
"5 & (5 + 1)" to "4",
194+
)
195+
}
205196
}

partiql-eval/src/test/kotlin/org/partiql/lang/eval/EvaluatingCompilerNAryTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.amazon.ion.IonValue
44
import com.amazon.ionelement.api.toIonElement
55
import junitparams.JUnitParamsRunner
66
import junitparams.Parameters
7-
import org.junit.jupiter.api.Test
7+
import org.junit.Test
88
import org.junit.runner.RunWith
99
import org.partiql.lang.CompilerPipeline
1010
import org.partiql.lang.ION

partiql-eval/src/test/kotlin/org/partiql/lang/eval/EvaluatingCompilerSelectStarTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.partiql.lang.eval
22

33
import junitparams.Parameters
4-
import org.junit.jupiter.api.Test
4+
import org.junit.Test
55
import org.partiql.lang.eval.evaluatortestframework.EvaluatorTestCase
66
import org.partiql.lang.util.downcast
77

partiql-eval/src/test/kotlin/org/partiql/lang/eval/internal/FunctionManagerTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test
44
import org.junit.jupiter.api.assertThrows
55
import org.partiql.lang.eval.EvaluationException
66
import org.partiql.lang.eval.EvaluatorTestBase
7-
import org.partiql.lang.eval.FunctionNotFoundException
87
import org.partiql.lang.eval.internal.builtins.SCALAR_BUILTINS_DEFAULT
98
import org.partiql.types.StaticType
109

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
junit.jupiter.execution.parallel.enabled = true
2+
junit.jupiter.execution.parallel.mode.default = concurrent
3+
junit.jupiter.execution.parallel.mode.classes.default = concurrent

test/partiql-randomized-tests/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ plugins {
1818
}
1919

2020
dependencies {
21+
// partiql-lang + tests
2122
testImplementation project(':partiql-lang')
2223
testImplementation project(':partiql-lang').sourceSets.test.output
24+
testImplementation testFixtures(project(':partiql-lang'))
25+
// partiql-eval + tests
26+
testImplementation project(':partiql-eval')
27+
testImplementation project(':partiql-eval').sourceSets.test.output
2328
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5'
2429
testImplementation 'pl.pragmatists:JUnitParams:[1.0.0,1.1.0)'
2530
testImplementation 'org.junit.vintage:junit-vintage-engine:5.7.0'

0 commit comments

Comments
 (0)