-
Notifications
You must be signed in to change notification settings - Fork 2
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
bindings support #5
Comments
See the last example in https://eed3si9n.com/eval/.
eval/src/main/scala-3/com/eed3si9n/eval/Eval.scala Lines 268 to 269 in fc91162
I don't see a big upside to implementing binding feature that would effectively to emulate the object creation, which depends on having some specific classpath. |
I am not a Scala programmer actually. I only need to pass some code to my Gatling-based performance tests, and this code requires access to objects in the scope in which it is executed. Below is a "model" of the use case:
This code throws |
To be more specific. This is a hardcoded
To be able to inject the code from a Jenkins job parameter I need access to the |
An example from Groovy:
I believe something like this was possible in Scala 2 via the Script Engine, but Scala 3 does not support bindings (I hope it is a temporary issue). |
Here's what I mean: build.sbtThisBuild / scalaVersion := "3.2.0"
libraryDependencies += ("com.eed3si9n.eval" % "eval" % "0.2.0").cross(CrossVersion.full)
run / fork := true Test.scalaimport com.eed3si9n.eval.Eval
object Binding:
val name = "evaluation"
@main
def main(): Unit =
val code=s"""
import Binding.*
"Hello " + name
"""
val eval = Eval()
val result = eval.evalInfer(code)
println(result.getValue(this.getClass.getClassLoader)) outputsbt:foo> run
[info] compiling 1 Scala source to /private/tmp/bar/target/scala-3.2.0/classes ...
[info] running (fork) main
[info] Hello evaluation |
Thank you! I will try to use it in my test code. |
Do you have any plans to add bindings support so that it is possible to pass values in addition to the simple code evaluation?
Originally posted by @krakadzeyau-clarabridge in #4 (comment)
The text was updated successfully, but these errors were encountered: