SHARE
TWEET

Untitled

a guest Aug 14th, 2019 36 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def code = { 123 }
  2. assert code() == 123
  3. assert code.call() == 123
  4.  
  5.  
  6. def isOdd = { i -> i%2 != 0 }
  7. assert isOdd(1) == true
  8.  
  9. def greeting = { who -> "Hello, $who"}
  10. assert greeting("master") == "Hello, master"
  11. assert greeting("master")[1..-2] == "ello, maste"
  12.  
  13. def concat1 = { ... args -> args.join(",")}
  14. assert concat1(1,2,3) == "1,2,3"
  15.  
  16. def concat2 = { int[] args -> args.join(",") }
  17. assert concat2(1,2,3) == "1,2,3"
  18.  
  19. assert (1..3).sum() == 6
  20.  
  21. println new File("test.groovy").text
  22.  
  23. def (passed, failed) = [49, 50, 51, 58, 60, 81, 83].split{it > 60}
  24. assert passed == [81, 83]
  25.  
  26. TimeZone.getAvailableIDs().sort().take(5).each{ println it }
  27.  
  28. println "${InetAddress.getLocalHost()}\n${InetAddress.getLocalHost().getLoopbackAddress()}"
  29.  
  30. println new Date().getDateTimeString()
  31.  
  32. System.getenv().each{println it}
  33.  
  34. class Person
  35. {
  36.     String name;
  37.     int age;
  38. }
  39.  
  40. def master = new Person()
  41. master.age = 100;
  42. master.name = "master"
  43.  
  44. import groovy.util.GroovyTestSuite
  45. import junit.framework.Test
  46. import junit.textui.TestRunner
  47.  
  48. class AllTests {
  49.     static Test suite() {
  50.         def allTests = new GroovyTestSuite()
  51.     }
  52. }
  53.  
  54. TestRunner.run(AllTests.suite())
  55.  
  56. @Grab(group="org.springframework", module="spring-orm", version="3.2.5.RELEASE")
  57. import org.springframework.jdbc.core.JdbcTemplate
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top