Spock Web Console Subscribe Tweet

OperationsSpec Published 1 year ago by Eric
```@Narrative("""
Take a look at these math questions.

Make the tests pass by putting in the right operation or answer
""")
class OperationsSpec extends Specification {
def "Fix the operations to get expected results"() {
expect:"Basic Math operations"
1 + 2 == null
5 - 2 == null
6 / 2 == null
7 % 2 == null
2 * 100 == null

and:"Little more complex, order of operations"
1 + 2 - 3     == null
7 + 2 * 3 / 1 == null

and:"Explicit ordering with `()`'s"
((2 + 2) * 3) / 2 == null

and:"increment & decrement"
++1 == null
--1 == null
}

@See("Stop when you get to this")
def "Comparison"() {
expect: "Boolean comparison"
true == true
true != false

and: "other types too"
2 != 1
"Erin" != "Aaron"
"ABC" * 2 == "ABCABC"

and: "operators"
true || false == true    // Or
true && false == false   // And
true && !false == true   // And Not

and: "gt, lt"
1 < 2 == true
3 >= 1 == true
3 <= 1 == false

and: "put many together"
3 >= 1 && 4 > 3 == true
}
}```