This file contains 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
test fun `testing a simple add operation`() { | |
assertEquals(4, 2 + 2, "2 + 2 = 4") | |
} |
This file contains 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
class MySpeck extends Specification { | |
def "check sum of two integer"() { | |
given: "we have two integers, 10 and 20" | |
def a = 10 | |
def b = 20 | |
when: "we add these two numbers" | |
def c = a + b | |
This file contains 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
fun main(args: Array<String>) { | |
val vertx = Vertx.vertx() | |
vertx.createHttpServer().requestHandler { request -> | |
request.response().end("Hello World!") | |
}.listen(8080) { result -> | |
if (result.succeeded()) { | |
vertx.createHttpClient().getNow(8080, "localhost", "/") { response -> | |
response.bodyHandler { body -> println("Server Response: ${body.toString()}") } |
This file contains 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
class Address { | |
String number | |
String firstLine | |
String secondLine | |
String postCode | |
String City | |
String State | |
} |
This file contains 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
println person.getAddressFirstLine() | |
println person.getAddressSecondLine() |
This file contains 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
class Person { | |
String firstName | |
String lastName | |
Address address | |
} |
This file contains 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
println person.getAddress().getFirstLine() | |
println person.getAddress().getSecondLine() |
This file contains 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
class Person { | |
String firstName | |
String lastName | |
private Address address | |
String getAddressFirstLine() { | |
address.firstLine | |
} | |
String getAddressSecondLine() { |
This file contains 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
private static File generateFile(String prefix, String suffix, File dir) | |
throws IOException | |
{ | |
long n = LazyInitialization.random.nextLong(); | |
if (n == Long.MIN_VALUE) { | |
n = 0; // corner case | |
} else { | |
n = Math.abs(n); | |
} | |
return new File(dir, prefix + Long.toString(n) + suffix); |
This file contains 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
def mergeSort(list) { | |
def size = list.size() | |
if (size < 2) { | |
return list | |
} else { | |
def m = (int)(size / 2) | |
def left = list[0..<m] | |
def right = list[m..<size] |
OlderNewer