Skip to content

Instantly share code, notes, and snippets.

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