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
import spock.lang.* | |
class MySpec extends Specification { | |
def "should return 1,2,3 respectively when calling size list"() { | |
given: | |
List list = Stub() | |
list.size() >>> [1,2,3] | |
expect: |
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
import spock.lang.* | |
class MySpec extends Specification { | |
def "should size list return always 3"() { | |
given: | |
List list = Stub() | |
list.size() >> 3 | |
expect: |
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
import spock.lang.* | |
class MySpec extends Specification { | |
def "maximum of two numbers"(int a, int b, int c) { | |
expect: | |
Math.max(a, b) == c | |
where: | |
a | b | c |
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
import spock.lang.* | |
class MySpec extends Specification { | |
def "should return 4 after list sum"() { | |
setup: | |
def list = [2, 2] | |
expect: | |
4 == list.sum() |
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
MySpec > should return 4 after list sum FAILED | |
Condition not satisfied: | |
4 == list.sum() | |
| | | | |
| [2] 2 | |
false | |
at MySpec.should return 4 after list sum(MySpec.groovy:15) | |
1 test completed, 1 failed |
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
import spock.lang.* | |
class MySpec extends Specification { | |
def "should return 4 after list sum"() { | |
given: | |
List<Integer> list = new ArrayList<>() | |
when: | |
list.add(2) | |
then: |
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
import spock.lang.* | |
class MySpec extends Specification { | |
// fields | |
// fixture methods | |
// feature methods | |
// helper methods | |
} |
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
beforeVisitMethod { methodNode -> | |
println "calling ${methodNode.name}(${methodNode.parameters.join(',')})" | |
} | |
afterMethodCall { call -> | |
if (getTargetMethod(call).name=='plus') { | |
addStaticTypeError('plus() not allowed',call) | |
handled = true | |
} |
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
package tdc.groovy.awesome | |
import groovy.transform.Immutable | |
import groovy.transform.ToString | |
// @TypeChecked | |
// @CompileStatic | |
@ToString | |
@Immutable |
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
-module (tdc). | |
-export ([printer/0, mysum/1, loop/0]). | |
printer() -> | |
io:format("~p~n", ["Bem vindos ao TDC 2016"]). | |
mysum([]) -> | |
0; | |
mysum([H|T]) -> |