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
// open groovysh | |
// execute :rc ls | |
import org.codehaus.groovy.tools.shell.CommandSupport | |
import org.codehaus.groovy.tools.shell.Groovysh | |
class Ls extends CommandSupport { | |
protected Ls(final Groovysh shell) { | |
super(shell, ':ls', ':dir') | |
} |
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
apply plugin: 'java' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'org.apache.commons:commons-lang3:3.4' | |
} |
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]) -> |
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
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
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
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
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"() { | |
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
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 |