From efde1913bc871a062f264d39f6932aaca3203a65 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Mon, 10 Feb 2020 15:32:09 +0100 Subject: [PATCH] Make the ScalaFiddle example copy-pastable, and runnable (#28530) --- .../test/scala/docs/akka/typed/IntroSpec.scala | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/IntroSpec.scala b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/IntroSpec.scala index 174684ad07..0c075a2888 100644 --- a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/IntroSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/IntroSpec.scala @@ -86,8 +86,21 @@ object IntroSpec { Behaviors.same } } + + //#hello-world-main + def main(args: Array[String]): Unit = { + val system: ActorSystem[HelloWorldMain.SayHello] = + ActorSystem(HelloWorldMain(), "hello") + + system ! HelloWorldMain.SayHello("World") + system ! HelloWorldMain.SayHello("Akka") + } + //#hello-world-main } //#hello-world-main + + // This is run by ScalaFiddle + HelloWorldMain.main(Array.empty) //#fiddle_code //format: ON @@ -229,7 +242,6 @@ class IntroSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with LogC "Intro sample" must { "say hello" in { - //#fiddle_code //#hello-world val system: ActorSystem[HelloWorldMain.SayHello] = @@ -239,7 +251,6 @@ class IntroSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with LogC system ! HelloWorldMain.SayHello("Akka") //#hello-world - //#fiddle_code Thread.sleep(500) // it will not fail if too short ActorTestKit.shutdown(system)