Skip to content

Commit

Permalink
Merge pull request #16 from VirtusLab/add-unit-tests
Browse files Browse the repository at this point in the history
Add unit tests
  • Loading branch information
BarkingBad authored Sep 14, 2021
2 parents 72a0587 + ad09cf3 commit 95a26f9
Show file tree
Hide file tree
Showing 30 changed files with 938 additions and 137 deletions.

This file was deleted.

70 changes: 0 additions & 70 deletions src/jmh/scala/com/virtuslab/stacktraces/tests/BasicTest.scala

This file was deleted.

17 changes: 0 additions & 17 deletions src/jmh/scala/com/virtuslab/stacktraces/util/TestExecutor.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
56 changes: 56 additions & 0 deletions src/test/resources/org/virtuslab/stacktraces/tests/inline/BdoSth
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
java.lang.IllegalStateException: doSthInlined
at method doSthInlined in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:14
at method <init> 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 <init> 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
58 changes: 58 additions & 0 deletions src/test/resources/org/virtuslab/stacktraces/tests/inline/BdoSthA
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
java.lang.IllegalStateException: doSthAInlined
at method doSthAInlined in src/test/scala/org/virtuslab/stacktraces/tests/InlineTests.scala:12
at method <init> 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 <init> 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 <init> 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
Original file line number Diff line number Diff line change
@@ -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 <init> 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 <init> 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
Loading

0 comments on commit 95a26f9

Please sign in to comment.