This is an automated email from the ASF dual-hosted git repository.
fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko.git
The following commit(s) were added to refs/heads/main by this push:
new 3775a18c2e update ActorSystemSpec to use property based testing for
its name (#575)
3775a18c2e is described below
commit 3775a18c2eec1abd46355b656109f282d4115b40
Author: Dongxu Wang <[email protected]>
AuthorDate: Thu Aug 17 16:17:57 2023 +0800
update ActorSystemSpec to use property based testing for its name (#575)
---
.../org/apache/pekko/actor/ActorSystemSpec.scala | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git
a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorSystemSpec.scala
b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorSystemSpec.scala
index 021861f0ce..a5c25b9ee9 100644
--- a/actor-tests/src/test/scala/org/apache/pekko/actor/ActorSystemSpec.scala
+++ b/actor-tests/src/test/scala/org/apache/pekko/actor/ActorSystemSpec.scala
@@ -22,6 +22,7 @@ import scala.language.postfixOps
import scala.annotation.nowarn
import com.typesafe.config.{ Config, ConfigFactory }
+import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
import org.apache.pekko
import pekko.actor.setup.ActorSystemSetup
@@ -125,23 +126,34 @@ object ActorSystemSpec {
}
@nowarn
-class ActorSystemSpec extends PekkoSpec(ActorSystemSpec.config) with
ImplicitSender {
+class ActorSystemSpec extends PekkoSpec(ActorSystemSpec.config) with
ImplicitSender with ScalaCheckPropertyChecks {
import ActorSystemSpec.FastActor
"An ActorSystem" must {
- "reject invalid names" in {
- for (n <- Seq(
+ "reject common invalid names" in {
+ val invalidNamesCombos =
+ Table(
"-hallowelt",
"_hallowelt",
+ "hallo welt",
"hallo*welt",
"hallo@welt",
"hallo#welt",
"hallo$welt",
"hallo%welt",
- "hallo/welt")) intercept[IllegalArgumentException] {
- ActorSystem(n)
+ "hallo/welt")
+ forAll(invalidNamesCombos) { (name: String) =>
+ an[IllegalArgumentException] should be thrownBy ActorSystem(name)
+ }
+ }
+
+ "reject all invalid names" in {
+ forAll { (name: String) =>
+ whenever(!name.matches("""^[a-zA-Z0-9][a-zA-Z0-9-_]*$""")) {
+ an[IllegalArgumentException] should be thrownBy ActorSystem(name)
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]