Skip to content

Commit

Permalink
Merge pull request #520 from adpi2/unpickle-from-java-reflect
Browse files Browse the repository at this point in the history
Introduce binary abstraction in unpickler
  • Loading branch information
adpi2 authored Jul 20, 2023
2 parents fe18a6c + 661cd0f commit ffd691f
Show file tree
Hide file tree
Showing 27 changed files with 442 additions and 567 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ object Scala3UnpicklerBridge {
warnLogger,
testMode: java.lang.Boolean
)
val skipMethod = cls.getMethods.find(m => m.getName == "skipMethod").get
val formatMethod = cls.getMethods.find(m => m.getName == "formatMethod").get
val skipMethod = cls.getMethod("skipMethod", classOf[Any])
val formatMethod = cls.getMethod("formatMethod", classOf[Any])

new Scala3UnpicklerBridge(debuggee.scalaVersion, bridge, skipMethod, formatMethod, testMode)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,10 @@ object DebugStepAssert {
)(implicit location: Location): Unit = {
assertEquals(frames.head.source.path, expectedSource.toString)
assertEquals(frames.head.line, expectedLine)
expectedStackTrace match {
case None =>
case Some(expectedStackTrace) =>
assertEquals(expectedStackTrace, frames.map(frame => frame.name))

expectedStackTrace.foreach { expected =>
val obtained = frames.map(frame => frame.name)
assertEquals(obtained, expected)
}

}

def assertOnFrame(expectedName: String)(frames: List[StackFrame])(implicit loc: Location): Unit =
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
package ch.epfl.scala.debugadapter.testfmk

import ch.epfl.scala.debugadapter.testfmk.TestingDebuggee._

import java.io.{BufferedReader, File, InputStream, InputStreamReader}
import java.nio.file.{Files, Path, Paths}
import scala.concurrent.{Future, Promise}
import scala.util.Properties
import scala.util.control.NonFatal
import java.net.InetSocketAddress
import ch.epfl.scala.debugadapter.ScalaVersion
import ch.epfl.scala.debugadapter.Module
import ch.epfl.scala.debugadapter.ManagedEntry
import ch.epfl.scala.debugadapter.CancelableFuture
import ch.epfl.scala.debugadapter.Debuggee
import ch.epfl.scala.debugadapter.Library
import ch.epfl.scala.debugadapter.UnmanagedEntry
import ch.epfl.scala.debugadapter.DebuggeeListener
import ch.epfl.scala.debugadapter.CancelableFuture
import ch.epfl.scala.debugadapter.JavaRuntime
import ch.epfl.scala.debugadapter.StandaloneSourceFile
import ch.epfl.scala.debugadapter.Library
import ch.epfl.scala.debugadapter.ManagedEntry
import ch.epfl.scala.debugadapter.Module
import ch.epfl.scala.debugadapter.ScalaVersion
import ch.epfl.scala.debugadapter.SourceDirectory
import ch.epfl.scala.debugadapter.StandaloneSourceFile
import ch.epfl.scala.debugadapter.UnmanagedEntry
import ch.epfl.scala.debugadapter.testfmk.TestingDebuggee._

import java.io.BufferedReader
import java.io.File
import java.io.InputStream
import java.io.InputStreamReader
import java.net.InetSocketAddress
import java.net.URLClassLoader
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import scala.concurrent.Future
import scala.concurrent.Promise
import scala.util.Properties
import scala.util.control.NonFatal

case class TestingDebuggee(
scalaVersion: ScalaVersion,
Expand All @@ -43,6 +50,9 @@ case class TestingDebuggee(
val process = builder.start()
new MainProcess(process, listener)
}

lazy val classLoader: ClassLoader =
new URLClassLoader(classPathEntries.map(_.absolutePath.toUri.toURL).toArray)
}

object TestingDebuggee {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,27 +947,27 @@ abstract class ScalaEvaluationTests(scalaVersion: ScalaVersion) extends DebugTes
|object Main {
| def main(args: Array[String]): Unit = {
| val x = "x1"
| def m(): String = {
| def m1(): String = {
| println(x) // captures x = "x1"
| val y = {
| val x = "x2"
| val z = {
| val x = "x3"
| def m(): String = {
| def m2(): String = {
| x // captures x = "x3"
| }
| m()
| m2()
| }
| z
| }
| y
| }
| println(m())
| println(m1())
| }
|}
|""".stripMargin
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)
check(Breakpoint(15), Evaluation.success("x", "x3"), Evaluation.success("m()", "x3"))
check(Breakpoint(15), Evaluation.success("x", "x3"), Evaluation.success("m2()", "x3"))
}

test("read and write mutable variables whose type is a value class") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,34 +121,29 @@ class ScalaStackTraceTests extends DebugTestSuite {
)
}

test("lazy val") {
test("local method and lazy val") {
val source =
"""|package example
|object Main {
| def main(args: Array[String]): Unit = {
|
| def m(t: Int) = {
| lazy val m1 : Int = {
| def m(t: Int): Int = {
| t + 1
| }
| m(2)
| }
| m1
| val x = 1
| lazy val y : Int = {
| x + 1
| }
| m(4)
| def m(z: Int) = x + y + z
| m(1)
| }
|}
|""".stripMargin
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)

check(
Breakpoint(
8,
6,
List(
"Main.main.m.m1.m(t: Int): Int",
"Main.main.m.m1: Int",
"Main.main.m(t: Int): Int",
"Main.main.y: Int", // initializer
"Main.main.y: Int", // getter
"Main.main.m(z: Int): Int",
"Main.main(args: Array[String]): Unit"
)
)
Expand Down
Loading

0 comments on commit ffd691f

Please sign in to comment.