Make the ScalaFiddle example copy-pastable, and runnable (#28530)
This commit is contained in:
parent
ef867f26d6
commit
efde1913bc
1 changed files with 13 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue