Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def code = { 123 }
- assert code() == 123
- assert code.call() == 123
- def isOdd = { i -> i%2 != 0 }
- assert isOdd(1) == true
- def greeting = { who -> "Hello, $who"}
- assert greeting("master") == "Hello, master"
- assert greeting("master")[1..-2] == "ello, maste"
- def concat1 = { ... args -> args.join(",")}
- assert concat1(1,2,3) == "1,2,3"
- def concat2 = { int[] args -> args.join(",") }
- assert concat2(1,2,3) == "1,2,3"
- assert (1..3).sum() == 6
- println new File("test.groovy").text
- def (passed, failed) = [49, 50, 51, 58, 60, 81, 83].split{it > 60}
- assert passed == [81, 83]
- TimeZone.getAvailableIDs().sort().take(5).each{ println it }
- println "${InetAddress.getLocalHost()}\n${InetAddress.getLocalHost().getLoopbackAddress()}"
- println new Date().getDateTimeString()
- System.getenv().each{println it}
- class Person
- {
- String name;
- int age;
- }
- def master = new Person()
- master.age = 100;
- master.name = "master"
- import groovy.util.GroovyTestSuite
- import junit.framework.Test
- import junit.textui.TestRunner
- class AllTests {
- static Test suite() {
- def allTests = new GroovyTestSuite()
- }
- }
- TestRunner.run(AllTests.suite())
- @Grab(group="org.springframework", module="spring-orm", version="3.2.5.RELEASE")
- import org.springframework.jdbc.core.JdbcTemplate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement