Created
November 22, 2017 10:03
-
-
Save JavierCane/bd26d3a6bcabbbffff4d29978dea6911 to your computer and use it in GitHub Desktop.
Scala standard class visibilities example for the CodelyTV Pro Scala course π https://pro.codely.tv/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Full repo: https://github.com/CodelyTV/scala-intro-examples/ | |
package tv.codely.scala_intro_examples.lesson_09_oop | |
import org.scalatest.{Matchers, WordSpec} | |
final class StandardClassVisibilitiesSpec extends WordSpec with Matchers { | |
private val randomText = "some text" | |
private val standardClass = new StandardClass(attributeInConstruct = randomText) | |
"Standard Class" should { | |
"set as public the attributes defined in the constructor by default" in { | |
standardClass.attributeInConstruct shouldBe randomText | |
} | |
"not compile if we try to access private attributes defined in the constructor" in { | |
"standardClass.privateAttributeInConstruct" shouldNot compile | |
} | |
"set as public the attributes defined in the class body by default" in { | |
val bodyAttributeValue = "public body attribute value" | |
standardClass.attributeInBody shouldBe bodyAttributeValue | |
} | |
"not compile if we try to access private attributes defined in the body" in { | |
"standardClass.privateAttributeInBody" shouldNot compile | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment