This file contains hidden or 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
| @Test | |
| fun shouldCalculateExpressionsCorrectly() { | |
| // arrange | |
| enterFormula("((515 + 87 x 311) - 302) ÷ 27") | |
| // act | |
| performCalculation() | |
| // assert | |
| assertResultIs("1010.0") |
This file contains hidden or 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
| class CalculatorScreenTest { | |
| @get:Rule | |
| val composeRule = createAndroidComposeRule(MainActivity::class.java) | |
| /** | |
| * type ((515 + 87 x 311) - 302) ÷ 27 | |
| * hit = | |
| * assert result is 1010.0 | |
| */ |
This file contains hidden or 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
| fun someFunction( | |
| lambda: (String) -> Unit | |
| ) { | |
| // TODO | |
| } | |
| fun main() { | |
| someFunction({ print(it) }) | |
| someFunction { |
This file contains hidden or 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
| A.() -> Unit // função que não recebe parâmetros e não tem retorno, no contexto de uma instância de A |
This file contains hidden or 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
| (String) -> Int // recebe uma String como parâmetro e retorna um Int | |
| () -> Unit // não recebe parâmetro e não retorna nada |
This file contains hidden or 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
| val user = user { | |
| name("Fulano") | |
| contactInfo { | |
| email("[email protected]") | |
| phoneNumber("11991234567") | |
| } | |
| +Role.User | |
| +Role.Admin | |
| } |
This file contains hidden or 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
| ... | |
| @UserDslScope | |
| class UserDsl { | |
| ... | |
| @UserDslScope | |
| class UserContactInfoDsl { | |
| ... |
This file contains hidden or 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
| val user = user { | |
| name = "Fulano" | |
| contactInfo { | |
| email = "[email protected]" | |
| phoneNumber = "11991234567" | |
| roles { | |
| +Role.User | |
| +Role.Admin | |
| } | |
| } |
This file contains hidden or 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
| fun user(init: UserDsl.() -> Unit): User { | |
| return UserDsl().apply(init).build() | |
| } |
This file contains hidden or 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
| class UserDsl { | |
| ... | |
| private val contactInfoDsl = UserContactInfoDsl() | |
| private val rolesDsl = UserRolesDsl() | |
| fun contactInfo(init: UserContactInfoDsl.() -> Unit) { | |
| contactInfoDsl.apply(init) | |
| } |