-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up ExprFunction test #529
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fe7c204
Changed Path AST node to use its root node source location
lziq 2e00c05
removed unnecesary files
lziq aef18ad
Added test case
lziq 9c6e0f9
Added another test case for list reference
lziq 3ca8278
Clean up ExprFunction tests
lziq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
lang/test/org/partiql/lang/eval/builtins/BuiltInFunctionTestExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.partiql.lang.eval.builtins | ||
|
||
import com.amazon.ion.Timestamp | ||
import org.partiql.lang.ION | ||
import org.partiql.lang.eval.Bindings | ||
import org.partiql.lang.eval.EvaluationSession | ||
import org.partiql.lang.eval.ExprValue | ||
import org.partiql.lang.eval.ExprValueFactory | ||
import org.partiql.lang.util.newFromIonText | ||
|
||
/** | ||
* Internal function used by ExprFunctionTest to test invalid argument type. | ||
*/ | ||
internal val invalidArgTypeChecker = InvalidArgTypeChecker() | ||
internal fun checkInvalidArgType(funcName: String, syntaxSuffix: String = "(", args: List<Argument>) = | ||
invalidArgTypeChecker.checkInvalidArgType(funcName, syntaxSuffix, args) | ||
|
||
/** | ||
* Internal function used by ExprFunctionTest to test invalid arity. | ||
*/ | ||
internal val invalidArityChecker = InvalidArityChecker() | ||
internal fun checkInvalidArity(funcName: String, minArity: Int, maxArity: Int) = | ||
invalidArityChecker.checkInvalidArity(funcName, minArity, maxArity) | ||
|
||
private val valueFactory = ExprValueFactory.standard(ION) | ||
|
||
private fun String.toExprValue(): ExprValue = valueFactory.newFromIonText(this) | ||
|
||
private fun Map<String, String>.toBindings(): Bindings<ExprValue> = Bindings.ofMap(mapValues { it.value.toExprValue() }) | ||
|
||
/** | ||
* Internal function used by ExprFunctionTest to build EvaluationSession. | ||
*/ | ||
internal fun Map<String, String>.toSession() = EvaluationSession.build { globals(this@toSession.toBindings()) } | ||
|
||
/** | ||
* Internal function used by ExprFunctionTest to build EvaluationSession with now. | ||
*/ | ||
internal fun buildSessionWithNow(numMillis: Long, localOffset: Int) = | ||
EvaluationSession.build { now(Timestamp.forMillis(numMillis, localOffset)) } | ||
|
||
/** | ||
* Used by ExprFunctionTest to represent a test case. | ||
*/ | ||
data class ExprFunctionTestCase( | ||
val source: String, | ||
val expected: String, | ||
val session: EvaluationSession = EvaluationSession.standard() | ||
) |
19 changes: 0 additions & 19 deletions
19
lang/test/org/partiql/lang/eval/builtins/CharLengthEvaluationTest.kt
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
lang/test/org/partiql/lang/eval/builtins/ConcatEvaluationTest.kt
This file was deleted.
Oops, something went wrong.
83 changes: 0 additions & 83 deletions
83
lang/test/org/partiql/lang/eval/builtins/DateAddEvaluationTest.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: for future PRs, it would be helpful to start with a clean commit history (i.e. not including commits from other PRs). GitHub shows this as a changed file even though your target branch,
main
, already has this change, which can be confusing for the reviewer.You could start by creating the branch directly off of
main
:If the origin GitHub branch already has the commits, you can rebase and force push to the origin branch.