diff --git a/src/jmh/scala/com/virtuslab/stacktraces/parser/StacktraceParserTest.scala b/src/jmh/scala/com/virtuslab/stacktraces/parser/StacktraceParserTest.scala deleted file mode 100644 index 0a30b92..0000000 --- a/src/jmh/scala/com/virtuslab/stacktraces/parser/StacktraceParserTest.scala +++ /dev/null @@ -1,45 +0,0 @@ -package org.virtuslab.stacktraces -package parser - -import org.virtuslab.stacktraces.parser.StacktraceParser -import org.virtuslab.stacktraces.core.Stacktraces -import org.virtuslab.stacktraces.printer.PrettyExceptionPrinter - -val stacktraceRaw = """Test org.virtuslab.stacktraces.tests.BasicTest.nestedLambdas failed: java.lang.RuntimeException: error, took 0.002 sec - at org.virtuslab.stacktraces.tests.BasicTest$package$.$bang(BasicTest.scala:23) - at org.virtuslab.stacktraces.tests.BasicTest.$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1(BasicTest.scala:35) - at scala.collection.immutable.List.map(List.scala:246) - at org.virtuslab.stacktraces.tests.BasicTest.$anonfun$2$$anonfun$2$$anonfun$2(BasicTest.scala:35) - at org.virtuslab.stacktraces.tests.BasicTest.$anonfun$3$$anonfun$3$$anonfun$adapted$1(BasicTest.scala:36) - at scala.collection.immutable.List.flatMap(List.scala:293) - at org.virtuslab.stacktraces.tests.BasicTest.$anonfun$4$$anonfun$4(BasicTest.scala:36) - at org.virtuslab.stacktraces.tests.BasicTest.$anonfun$5$$anonfun$adapted$1(BasicTest.scala:37) - at scala.collection.immutable.List.map(List.scala:246) - at org.virtuslab.stacktraces.tests.BasicTest.$anonfun$6(BasicTest.scala:37) - at org.virtuslab.stacktraces.tests.BasicTest.$anonfun$adapted$1(BasicTest.scala:38) - at scala.collection.StrictOptimizedIterableOps.flatMap(StrictOptimizedIterableOps.scala:117) - at scala.collection.StrictOptimizedIterableOps.flatMap$(StrictOptimizedIterableOps.scala:104) - at scala.collection.immutable.Range.flatMap(Range.scala:59) - at org.virtuslab.stacktraces.tests.BasicTest.nestedLambdas$$anonfun$1(BasicTest.scala:38) - at org.virtuslab.stacktraces.util.TestExecutor$.executeTest(TestExecutor.scala:13) - at org.virtuslab.stacktraces.tests.BasicTest.nestedLambdas(BasicTest.scala:40) - at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) - at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) - at java.lang.reflect.Method.invoke(Method.java:566) -""" - -object StacktraceParserTest: - - @main - def parserTest = - val errorOrStacktrace = StacktraceParser.parse(stacktraceRaw) - errorOrStacktrace match - case Left(msg) => throw AssertionError(msg) - case Right(stacktrace) => - val prettyStackTrace = convertToPrettyStackTraceWithStdlib(stacktrace) - /* - * This stacktrace is subject to Tasty files generated for BasicTest.scala, if you see some weird output, probably BasicTest.scala diverged. - * Nonetheless, we can count test as passing correctly if it hits Right branch. - */ - PrettyExceptionPrinter.printStacktrace(prettyStackTrace) diff --git a/src/jmh/scala/com/virtuslab/stacktraces/tests/BasicTest.scala b/src/jmh/scala/com/virtuslab/stacktraces/tests/BasicTest.scala deleted file mode 100644 index 0689602..0000000 --- a/src/jmh/scala/com/virtuslab/stacktraces/tests/BasicTest.scala +++ /dev/null @@ -1,70 +0,0 @@ -package org.virtuslab.stacktraces -package tests - -import org.virtuslab.stacktraces.core.Stacktraces -import org.virtuslab.stacktraces.printer.PrettyExceptionPrinter - - -trait A: - def doSthA = doSthAInlined - - @inline def doSthAInlined = throw IllegalStateException("doSthAInlined") - - def doSth = doSthInlined - - inline def doSthInlined = throw IllegalStateException("doSthInlined") - -class B extends A - - -extension (n: Int) - def !(n2: Int): Int = - if math.random < n/10.0 then throw RuntimeException("error") - n + n2 - -object BasicTests: - - @main - def nestedLambdas = TestExecutor.executeTest { () => - val y = 1 - val x = (0 to 10).flatMap { - n => List(n).map { - n => (if n > 5 then List(true) else List(false)).flatMap { - n => (if n then List("0") else List("5")).map { n => n.toInt ! n.toInt ! n.toInt } - } - } - } - val z = 1 - } - - @main - def nestedLambdasRec = TestExecutor.executeTest { () => - def rec(int: Int, string: String): IterableOnce[Any] = - val y = 1 - val x = (0 to 10).flatMap { - n => - if int == 1 then - throw new RuntimeException("abc") - else if int > 0 then - rec(int - 1, "ASD") - else - def rec(n: Int): IterableOnce[Any] = List(n).map { - n => (if n > 5 then List(true) else List(false)).flatMap { - n => (if n then List("0") else List("5")).map { n => - 22 - } - } - } - rec(n) - } - x - rec(3, "ASD") - } - - @main - def BdoSth = - TestExecutor.executeTest(() => B().doSth) - - @main - def BdoSthA = - TestExecutor.executeTest(() => B().doSthA) diff --git a/src/jmh/scala/com/virtuslab/stacktraces/util/TestExecutor.scala b/src/jmh/scala/com/virtuslab/stacktraces/util/TestExecutor.scala deleted file mode 100644 index 363add4..0000000 --- a/src/jmh/scala/com/virtuslab/stacktraces/util/TestExecutor.scala +++ /dev/null @@ -1,17 +0,0 @@ -package org.virtuslab.stacktraces - -import org.virtuslab.stacktraces.core.Stacktraces -import org.virtuslab.stacktraces.printer.PrettyExceptionPrinter - - -object TestExecutor: - def executeTest(test: () => Unit) = - try - test() - catch - case e: Exception => - val prettyStackTrace = convertToPrettyStackTraceWithStdlib(e) - PrettyExceptionPrinter.printStacktrace(prettyStackTrace) - -def convertToPrettyStackTraceWithStdlib(e: Exception) = - Stacktraces.convertToPrettyStackTrace(e, Seq("scala-library_3-3.1.0-RC1-bin-SNAPSHOT.jar")) diff --git a/src/jmh/scala/com/virtuslab/stacktraces/benchmarks/Main.scala b/src/jmh/scala/org/virtuslab/stacktraces/benchmarks/Main.scala similarity index 100% rename from src/jmh/scala/com/virtuslab/stacktraces/benchmarks/Main.scala rename to src/jmh/scala/org/virtuslab/stacktraces/benchmarks/Main.scala diff --git a/src/main/scala/com/virtuslab/stacktraces/core/LambdaUnraveler.scala b/src/main/scala/org/virtuslab/stacktraces/core/LambdaUnraveler.scala similarity index 100% rename from src/main/scala/com/virtuslab/stacktraces/core/LambdaUnraveler.scala rename to src/main/scala/org/virtuslab/stacktraces/core/LambdaUnraveler.scala diff --git a/src/main/scala/com/virtuslab/stacktraces/core/Stacktraces.scala b/src/main/scala/org/virtuslab/stacktraces/core/Stacktraces.scala similarity index 100% rename from src/main/scala/com/virtuslab/stacktraces/core/Stacktraces.scala rename to src/main/scala/org/virtuslab/stacktraces/core/Stacktraces.scala diff --git a/src/main/scala/com/virtuslab/stacktraces/core/StacktracesInspector.scala b/src/main/scala/org/virtuslab/stacktraces/core/StacktracesInspector.scala similarity index 100% rename from src/main/scala/com/virtuslab/stacktraces/core/StacktracesInspector.scala rename to src/main/scala/org/virtuslab/stacktraces/core/StacktracesInspector.scala diff --git a/src/main/scala/com/virtuslab/stacktraces/io/TastyFilesLocator.scala b/src/main/scala/org/virtuslab/stacktraces/io/TastyFilesLocator.scala similarity index 100% rename from src/main/scala/com/virtuslab/stacktraces/io/TastyFilesLocator.scala rename to src/main/scala/org/virtuslab/stacktraces/io/TastyFilesLocator.scala diff --git a/src/main/scala/com/virtuslab/stacktraces/model/model.scala b/src/main/scala/org/virtuslab/stacktraces/model/model.scala similarity index 100% rename from src/main/scala/com/virtuslab/stacktraces/model/model.scala rename to src/main/scala/org/virtuslab/stacktraces/model/model.scala diff --git a/src/main/scala/com/virtuslab/stacktraces/parser/StacktraceParser.scala b/src/main/scala/org/virtuslab/stacktraces/parser/StacktraceParser.scala similarity index 100% rename from src/main/scala/com/virtuslab/stacktraces/parser/StacktraceParser.scala rename to src/main/scala/org/virtuslab/stacktraces/parser/StacktraceParser.scala diff --git a/src/main/scala/com/virtuslab/stacktraces/printer/PrettyExceptionBuilder.scala b/src/main/scala/org/virtuslab/stacktraces/printer/PrettyExceptionBuilder.scala similarity index 83% rename from src/main/scala/com/virtuslab/stacktraces/printer/PrettyExceptionBuilder.scala rename to src/main/scala/org/virtuslab/stacktraces/printer/PrettyExceptionBuilder.scala index 9a9f245..7db0862 100644 --- a/src/main/scala/com/virtuslab/stacktraces/printer/PrettyExceptionBuilder.scala +++ b/src/main/scala/org/virtuslab/stacktraces/printer/PrettyExceptionBuilder.scala @@ -11,9 +11,9 @@ val LIGHT_PURPLE = "\u001b[38;5;141m" val GRAY = "\u001b[38;5;248m" class PrettyStackTrace: - val stackTraceBuilder = new StringBuilder - def build = stackTraceBuilder.toString - def ++=(s: String): Unit = stackTraceBuilder ++= s + val stackTraceBuilder = new StringBuilder + def build = stackTraceBuilder.toString + def ++=(s: String): Unit = stackTraceBuilder ++= s def prettyStackTrace(init: PrettyStackTrace ?=> Unit): PrettyStackTrace = given p: PrettyStackTrace = PrettyStackTrace() diff --git a/src/main/scala/com/virtuslab/stacktraces/printer/PrettyExceptionPrinter.scala b/src/main/scala/org/virtuslab/stacktraces/printer/PrettyExceptionPrinter.scala similarity index 92% rename from src/main/scala/com/virtuslab/stacktraces/printer/PrettyExceptionPrinter.scala rename to src/main/scala/org/virtuslab/stacktraces/printer/PrettyExceptionPrinter.scala index 7198ce8..2ae7b7a 100644 --- a/src/main/scala/com/virtuslab/stacktraces/printer/PrettyExceptionPrinter.scala +++ b/src/main/scala/org/virtuslab/stacktraces/printer/PrettyExceptionPrinter.scala @@ -8,8 +8,8 @@ import Console.RESET object PrettyExceptionPrinter: - def printStacktrace(pe: PrettyException, withJarName: Boolean = false): Unit = - val pst = prettyStackTrace { + def prettyStacktrace(pe: PrettyException, withJarName: Boolean = false): PrettyStackTrace = + prettyStackTrace { addWithColor(LIGHT_ORANGE)(s"Exception in thread ${Thread.currentThread.getName}: ") addWithColor(RED)(s"${pe.original.getClass.getName}: ${pe.original.getMessage}") add("\n") @@ -53,4 +53,7 @@ object PrettyExceptionPrinter: add(s" - ${er.msg}") } } + + def printStacktrace(pe: PrettyException, withJarName: Boolean = false): Unit = + val pst = prettyStacktrace(pe, withJarName) println(pst.build) diff --git a/src/main/scala/com/virtuslab/stacktraces/tasty/TypesSupport.scala b/src/main/scala/org/virtuslab/stacktraces/tasty/TypesSupport.scala similarity index 100% rename from src/main/scala/com/virtuslab/stacktraces/tasty/TypesSupport.scala rename to src/main/scala/org/virtuslab/stacktraces/tasty/TypesSupport.scala diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/inline/BdoSth b/src/test/resources/org/virtuslab/stacktraces/tests/inline/BdoSth new file mode 100644 index 0000000..c4df215 --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/inline/BdoSth @@ -0,0 +1,56 @@ +java.lang.IllegalStateException: doSthInlined + at method doSthInlined in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:14 + at method in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:17 + at lambda () => Unit of test in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:22 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:21 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/inline/BdoSthA b/src/test/resources/org/virtuslab/stacktraces/tests/inline/BdoSthA new file mode 100644 index 0000000..1c00b44 --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/inline/BdoSthA @@ -0,0 +1,58 @@ +java.lang.IllegalStateException: doSthAInlined + at method doSthAInlined in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:12 + at method in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:17 + at method doSthA in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:11 + at method in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:17 + at lambda () => Unit of test in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:26 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:25 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/nestedLambdas/NestedLambdas b/src/test/resources/org/virtuslab/stacktraces/tests/nestedLambdas/NestedLambdas new file mode 100644 index 0000000..4313a25 --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/nestedLambdas/NestedLambdas @@ -0,0 +1,65 @@ +java.lang.RuntimeException: NestedLambdas + at extension method ! in src/test/scala/org/virtuslab/stacktraces/tests/NestedLambdasTests.scala:12 + at lambda (String) => Int of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/NestedLambdasTests.scala:23 + at method map in scala/collection/immutable/List.scala:246 + at lambda (Boolean) => IterableOnce[Int] of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/NestedLambdasTests.scala:23 + at method flatMap in scala/collection/immutable/List.scala:293 + at lambda (Int) => List[Int] of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/NestedLambdasTests.scala:24 + at method map in scala/collection/immutable/List.scala:246 + at lambda (Int) => IterableOnce[List[Int]] of x in src/test/scala/org/virtuslab/stacktraces/tests/NestedLambdasTests.scala:25 + at method strictOptimizedFlatMap in scala/collection/StrictOptimizedIterableOps.scala:117 + at method flatMap in scala/collection/StrictOptimizedIterableOps.scala:104 + at method in scala/collection/immutable/Range.scala:59 + at lambda () => Unit of test in src/test/scala/org/virtuslab/stacktraces/tests/NestedLambdasTests.scala:25 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/NestedLambdasTests.scala:17 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec new file mode 100644 index 0000000..c311930 --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec @@ -0,0 +1,69 @@ +java.lang.RuntimeException: NestedLambdasRec + at lambda (Int) => IterableOnce[Any] of x in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:26 + at method strictOptimizedFlatMap in scala/collection/StrictOptimizedIterableOps.scala:117 + at method flatMap in scala/collection/StrictOptimizedIterableOps.scala:104 + at method in scala/collection/immutable/Range.scala:59 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:26 + at lambda (Int) => IterableOnce[Any] of x in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:26 + at method strictOptimizedFlatMap in scala/collection/StrictOptimizedIterableOps.scala:117 + at method flatMap in scala/collection/StrictOptimizedIterableOps.scala:104 + at method in scala/collection/immutable/Range.scala:59 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:26 + at lambda (Int) => IterableOnce[Any] of x in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:26 + at method strictOptimizedFlatMap in scala/collection/StrictOptimizedIterableOps.scala:117 + at method flatMap in scala/collection/StrictOptimizedIterableOps.scala:104 + at method in scala/collection/immutable/Range.scala:59 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:26 + at lambda (Int, String) => IterableOnce[Any] of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:29 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:8 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec2 b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec2 new file mode 100644 index 0000000..0175d7d --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec2 @@ -0,0 +1,55 @@ +java.lang.RuntimeException: NestedLambdasRec2 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:35 + at lambda (Int) => Nothing of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:36 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:32 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec3 b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec3 new file mode 100644 index 0000000..2ad99a7 --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec3 @@ -0,0 +1,59 @@ +java.lang.RuntimeException: NestedLambdasRec3 + at lambda (String) => Int of rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:44 + at method map in scala/collection/immutable/List.scala:246 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:45 + at lambda (String) => List[Int] of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:48 + at method map in scala/collection/immutable/List.scala:246 + at lambda (Int) => List[Int] of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:48 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:39 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec4 b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec4 new file mode 100644 index 0000000..38936ce --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec4 @@ -0,0 +1,57 @@ +java.lang.RuntimeException: NestedLambdasRec4 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:55 + at lambda (String) => Nothing of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:57 + at method map in scala/collection/immutable/List.scala:246 + at lambda (Int) => Nothing of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:57 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:52 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec5 b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec5 new file mode 100644 index 0000000..0d48e46 --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec5 @@ -0,0 +1,57 @@ +java.lang.RuntimeException: NestedLambdasRec5 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:64 + at lambda (String) => Nothing of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:65 + at method map in scala/collection/immutable/List.scala:246 + at lambda (Int) => Double of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:65 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:61 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec6 b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec6 new file mode 100644 index 0000000..42b817e --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec6 @@ -0,0 +1,59 @@ +java.lang.RuntimeException: NestedLambdasRec6 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:71 + at lambda (String) => Nothing of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:72 + at method map in scala/collection/immutable/List.scala:246 + at lambda (Int) => Double of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:72 + at method map in scala/collection/immutable/List.scala:246 + at lambda (Int) => List[Nothing] of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:72 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:68 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec7 b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec7 new file mode 100644 index 0000000..2afc46d --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec7 @@ -0,0 +1,58 @@ +java.lang.RuntimeException: NestedLambdasRec7 + at lambda (String) => Nothing of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:79 + at method map in scala/collection/immutable/List.scala:246 + at lambda (Int) => List[Nothing] of some outer lambda in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:80 + at method map in scala/collection/immutable/List.scala:246 + at lambda () => Unit of test in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:80 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:75 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec8 b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec8 new file mode 100644 index 0000000..83d7621 --- /dev/null +++ b/src/test/resources/org/virtuslab/stacktraces/tests/recursion/NestedLambdasRec8 @@ -0,0 +1,70 @@ +java.lang.RuntimeException: NestedLambdasRec8 + at lambda (Int) => Int of rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:89 + at method apply in scala/runtime/java8/JFunction1$mcII$sp.scala:17 + at method map in scala/collection/immutable/List.scala:246 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:90 + at lambda (Int) => Int of rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:90 + at method apply in scala/runtime/java8/JFunction1$mcII$sp.scala:17 + at method map in scala/collection/immutable/List.scala:246 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:90 + at lambda (Int) => Int of rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:90 + at method apply in scala/runtime/java8/JFunction1$mcII$sp.scala:17 + at method map in scala/collection/immutable/List.scala:246 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:90 + at lambda (Int) => Int of rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:90 + at method apply in scala/runtime/java8/JFunction1$mcII$sp.scala:17 + at method map in scala/collection/immutable/List.scala:246 + at method rec in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:90 + at lambda () => Unit of test in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:93 + at method executeTest in src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala:27 + at method in src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala:84 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 + at method runReflectiveCall in org.junit.runners.model.FrameworkMethod$1:47 + at method run in org.junit.internal.runners.model.ReflectiveCallable:12 + at method invokeExplosively in org.junit.runners.model.FrameworkMethod:44 + at method evaluate in org.junit.internal.runners.statements.InvokeMethod:17 + at method runLeaf in org.junit.runners.ParentRunner:271 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:70 + at method runChild in org.junit.runners.BlockJUnit4ClassRunner:50 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method runChild in org.junit.runners.Suite:127 + at method runChild in org.junit.runners.Suite:26 + at method run in org.junit.runners.ParentRunner$3:238 + at method schedule in org.junit.runners.ParentRunner$1:63 + at method runChildren in org.junit.runners.ParentRunner:236 + at method access$000 in org.junit.runners.ParentRunner:53 + at method evaluate in org.junit.runners.ParentRunner$2:229 + at method run in org.junit.runners.ParentRunner:309 + at method run in org.junit.runner.JUnitCore:160 + at method run in org.junit.runner.JUnitCore:138 + at method execute in com.novocode.junit.JUnitRunner$1:132 + at method runTest$1 in sbt.TestRunner:140 + at method run in sbt.TestRunner:155 + at method $anonfun$apply$1 in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method sbt$TestFramework$$withContextLoader in sbt.TestFramework$:278 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1:318 + at method apply in sbt.TestFunction:330 + at method $anonfun$toTask$1 in sbt.Tests$:435 + at method $anonfun$apply$2 in sbt.std.Transform$$anon$3:46 + at method work in sbt.std.Transform$$anon$4:68 + at method $anonfun$submit$2 in sbt.Execute:282 + at method wideConvert in sbt.internal.util.ErrorHandling$:23 + at method work in sbt.Execute:291 + at method $anonfun$submit$1 in sbt.Execute:282 + at method $anonfun$submitValid$1 in sbt.ConcurrentRestrictions$$anon$4:265 + at method call in sbt.CompletionService$$anon$2:64 + at method run in java.util.concurrent.FutureTask:264 + at method call in java.util.concurrent.Executors$RunnableAdapter:515 + at method run in java.util.concurrent.FutureTask:264 + at method runWorker in java.util.concurrent.ThreadPoolExecutor:1128 + at method run in java.util.concurrent.ThreadPoolExecutor$Worker:628 + at method run in java.lang.Thread:829 diff --git a/src/test/scala/org/virtuslab/stacktraces/parser/StacktraceParserTest.scala b/src/test/scala/org/virtuslab/stacktraces/parser/StacktraceParserTest.scala new file mode 100644 index 0000000..00c6218 --- /dev/null +++ b/src/test/scala/org/virtuslab/stacktraces/parser/StacktraceParserTest.scala @@ -0,0 +1,65 @@ +package org.virtuslab.stacktraces +package parser + +import org.virtuslab.stacktraces.parser.StacktraceParser +import org.virtuslab.stacktraces.core.Stacktraces +import org.virtuslab.stacktraces.printer.PrettyExceptionPrinter + +import org.junit.Test +import org.junit.Assert.assertTrue +import org.junit.Assume.assumeTrue + +val stacktraceRaw = """Test org.virtuslab.stacktraces.parser.TestInput.test failed: java.lang.RuntimeException: TestInput, took 0.004 sec + at org.virtuslab.stacktraces.parser.TestInput$package$.$bang(TestInput.scala:7) + at org.virtuslab.stacktraces.parser.TestInput.$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1(TestInput.scala:18) + at scala.collection.immutable.List.map(List.scala:246) + at org.virtuslab.stacktraces.parser.TestInput.$anonfun$2$$anonfun$2$$anonfun$2(TestInput.scala:18) + at org.virtuslab.stacktraces.parser.TestInput.$anonfun$3$$anonfun$3$$anonfun$adapted$1(TestInput.scala:18) + at scala.collection.immutable.List.flatMap(List.scala:293) + at org.virtuslab.stacktraces.parser.TestInput.$anonfun$4$$anonfun$4(TestInput.scala:18) + at org.virtuslab.stacktraces.parser.TestInput.$anonfun$5$$anonfun$adapted$1(TestInput.scala:19) + at scala.collection.immutable.List.map(List.scala:246) + at org.virtuslab.stacktraces.parser.TestInput.$anonfun$6(TestInput.scala:19) + at org.virtuslab.stacktraces.parser.TestInput.$anonfun$adapted$1(TestInput.scala:20) + at scala.collection.StrictOptimizedIterableOps.flatMap(StrictOptimizedIterableOps.scala:117) + at scala.collection.StrictOptimizedIterableOps.flatMap$(StrictOptimizedIterableOps.scala:104) + at scala.collection.immutable.Range.flatMap(Range.scala:59) + at org.virtuslab.stacktraces.parser.TestInput.test(TestInput.scala:20) + at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:566) +""" + +val prettifiedStacktrace = """ at extension method ! in src/test/scala/org/virtuslab/stacktraces/parser/TestInput.scala:7 + at lambda (String) => Int of some outer lambda in src/test/scala/org/virtuslab/stacktraces/parser/TestInput.scala:18 + at method map in scala/collection/immutable/List.scala:246 + at lambda (Boolean) => IterableOnce[Int] of some outer lambda in src/test/scala/org/virtuslab/stacktraces/parser/TestInput.scala:18 + at method flatMap in scala/collection/immutable/List.scala:293 + at lambda (Int) => List[Int] of some outer lambda in src/test/scala/org/virtuslab/stacktraces/parser/TestInput.scala:19 + at method map in scala/collection/immutable/List.scala:246 + at lambda (Int) => IterableOnce[List[Int]] of x in src/test/scala/org/virtuslab/stacktraces/parser/TestInput.scala:20 + at method strictOptimizedFlatMap in scala/collection/StrictOptimizedIterableOps.scala:117 + at method flatMap in scala/collection/StrictOptimizedIterableOps.scala:104 + at method in scala/collection/immutable/Range.scala:59 + at method test in src/test/scala/org/virtuslab/stacktraces/parser/TestInput.scala:20 + at method invoke0 in jdk.internal.reflect.NativeMethodAccessorImpl:(Native method) + at method invoke in jdk.internal.reflect.NativeMethodAccessorImpl:62 + at method invoke in jdk.internal.reflect.DelegatingMethodAccessorImpl:43 + at method invoke in java.lang.reflect.Method:566 +""" + +class StacktraceParserTest: + + @Test + def parserTest = + assumeTrue(System.getProperty("java.version").startsWith("11.")) + val errorOrStacktrace = StacktraceParser.parse(stacktraceRaw) + errorOrStacktrace match + case Left(msg) => throw AssertionError(msg) + case Right(stacktrace) => + val prettyStackTrace = Stacktraces.convertToPrettyStackTrace(stacktrace, Seq("scala-library_3-3.1.0-RC1-bin-SNAPSHOT.jar")) + /* + * This stacktrace is subject to Tasty files generated for TestInput.scala, if you see some weird output, probably TestInput.scala diverged. + */ + assertTrue(PrettyExceptionPrinter.prettyStacktrace(prettyStackTrace).build.replaceAll("\u001b\\[[;\\d]*m", "").endsWith(prettifiedStacktrace)) diff --git a/src/test/scala/org/virtuslab/stacktraces/parser/TestInput.scala b/src/test/scala/org/virtuslab/stacktraces/parser/TestInput.scala new file mode 100644 index 0000000..b16694c --- /dev/null +++ b/src/test/scala/org/virtuslab/stacktraces/parser/TestInput.scala @@ -0,0 +1,22 @@ +package org.virtuslab.stacktraces.parser + +import org.junit.Test + +extension (n: Int) + def !(n2: Int): Int = + if math.random < n/10.0 then throw RuntimeException("TestInput") + n + n2 + +class TestInput: + + //@Test + def test = + val y = 1 + val x = (0 to 10).flatMap { + n => List(n).map { + n => (if n > 5 then List(true) else List(false)).flatMap { + n => (if n then List("0") else List("5")).map { n => n.toInt ! n.toInt ! n.toInt } + } + } + } + val z = 1 diff --git a/src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala b/src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala new file mode 100644 index 0000000..3296ebc --- /dev/null +++ b/src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala @@ -0,0 +1,26 @@ +package org.virtuslab.stacktraces +package tests +package inline + +import org.virtuslab.stacktraces.core.Stacktraces +import org.virtuslab.stacktraces.printer.PrettyExceptionPrinter + +/* Inline test setup */ + +trait A: + def doSthA = doSthAInlined + @inline def doSthAInlined = throw IllegalStateException("doSthAInlined") + def doSth = doSthInlined + inline def doSthInlined = throw IllegalStateException("doSthInlined") + + +class B extends A + +/* Inline test suites */ + +class BdoSth extends TestExecutor: + override val test = () => B().doSth + + +class BdoSthA extends TestExecutor: + override val test = () => B().doSthA diff --git a/src/test/scala/org/virtuslab/stacktraces/tests/NestedLambdasTests.scala b/src/test/scala/org/virtuslab/stacktraces/tests/NestedLambdasTests.scala new file mode 100644 index 0000000..6c8dcd9 --- /dev/null +++ b/src/test/scala/org/virtuslab/stacktraces/tests/NestedLambdasTests.scala @@ -0,0 +1,27 @@ +package org.virtuslab.stacktraces +package tests +package nestedLambdas + +import org.virtuslab.stacktraces.core.Stacktraces +import org.virtuslab.stacktraces.printer.PrettyExceptionPrinter + +/* Nested lambdas test setup */ + +extension (n: Int) + def !(n2: Int): Int = + if math.random < n/10.0 then throw RuntimeException("NestedLambdas") + n + n2 + +/* Nested lambdas test suites */ + +class NestedLambdas extends TestExecutor: + override val test = () => + val y = 1 + val x = (0 to 10).flatMap { + n => List(n).map { + n => (if n > 5 then List(true) else List(false)).flatMap { + n => (if n then List("0") else List("5")).map { n => n.toInt ! n.toInt ! n.toInt } + } + } + } + val z = 1 diff --git a/src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala b/src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala new file mode 100644 index 0000000..ffe0bec --- /dev/null +++ b/src/test/scala/org/virtuslab/stacktraces/tests/RecursionTests.scala @@ -0,0 +1,93 @@ +package org.virtuslab.stacktraces +package tests +package recursion + +import org.virtuslab.stacktraces.core.Stacktraces +import org.virtuslab.stacktraces.printer.PrettyExceptionPrinter + +class NestedLambdasRec extends TestExecutor: + override val test = () => + def rec(int: Int, string: String): IterableOnce[Any] = + val y = 1 + val x = (0 to 10).flatMap { + n => + if int == 1 then + throw new RuntimeException("NestedLambdasRec") + else if int > 0 then + rec(int - 1, "ASD") + else + def rec(n: Int): IterableOnce[Any] = List(n).map { + n => (if n > 5 then List(true) else List(false)).flatMap { + n => (if n then List("0") else List("5")).map { n => + 22 + } + } + } + rec(n) + } + x + rec.apply(3, "ASD") + + +class NestedLambdasRec2 extends TestExecutor: + override val test = () => + def rec(int: Int) = + throw new RuntimeException("NestedLambdasRec2") + rec.apply(3) + + +class NestedLambdasRec3 extends TestExecutor: + override val test = () => + def rec(int: String) = + List("asv").map { x => + val aaa = 1 + 1 + throw new RuntimeException("NestedLambdasRec3") + 2 + 2 + } + List(1).map { n => + rec.apply("asd") + } + + +class NestedLambdasRec4 extends TestExecutor: + override val test = () => + def rec(int: String) = + throw new RuntimeException("NestedLambdasRec4") + List(1).map { n => + rec.apply("asd") + } + + +class NestedLambdasRec5 extends TestExecutor: + override val test = () => + def rec(int: String) = + throw new RuntimeException("NestedLambdasRec5") + List(1).map(n => {List(1).map(_ => 1.3); rec.apply("asd")}) + + +class NestedLambdasRec6 extends TestExecutor: + override val test = () => + def rec(int: String) = + throw new RuntimeException("NestedLambdasRec6") + List(1).map(n => {List(1).map(_ => 1.3); List("xd").map(rec)}) + + +class NestedLambdasRec7 extends TestExecutor: + override val test = () => + List(1).map { n => + List("xd").map { m => + throw new RuntimeException("NestedLambdasRec7") + } + } + + +class NestedLambdasRec8 extends TestExecutor: + override val test = () => + def rec(int: Int): Int = + List(2).map { x => + if int == 0 then + throw new RuntimeException("NestedLambdasRec8") + else rec(int - 1) + } + 1 + rec(3) diff --git a/src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala b/src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala new file mode 100644 index 0000000..745758b --- /dev/null +++ b/src/test/scala/org/virtuslab/stacktraces/util/TestExecutor.scala @@ -0,0 +1,34 @@ +package org.virtuslab.stacktraces + +import scala.io.Source + +import org.virtuslab.stacktraces.core.Stacktraces +import org.virtuslab.stacktraces.printer.PrettyExceptionPrinter + +import org.junit.Assert.assertTrue +import org.junit.Assume.assumeTrue +import org.junit.Test + +import java.nio.file.Paths + +trait TestExecutor: + + val test: () => Unit + + @Test + final def executeTest = + // Enable test only on JDK 11 + assumeTrue(System.getProperty("java.version").startsWith("11.")) + + val className = this.getClass.getName.split("\\.") + val expected = Source.fromResource(Paths.get(className.head, className.tail*).toString).mkString + + try + test() + catch + case e: Exception => + val prettyStackTrace = convertToPrettyStackTraceWithStdlib(e) + assertTrue(PrettyExceptionPrinter.prettyStacktrace(prettyStackTrace).build.replaceAll("\u001b\\[[;\\d]*m", "").endsWith(expected)) + + private def convertToPrettyStackTraceWithStdlib(e: Exception) = + Stacktraces.convertToPrettyStackTrace(e, Seq("scala-library_3-3.1.0-RC1-bin-SNAPSHOT.jar"))