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
package main | |
import ( | |
"errors" | |
"fmt" | |
"os" | |
) | |
func main() { | |
test1() |
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
package main | |
import "fmt" | |
func main() { | |
l1 := make([]string, 0, 0) | |
fmt.Println(append(l1, "1")) | |
fmt.Println(append(l1, "2")) | |
fmt.Println(append(l1, "3")) | |
fmt.Println(append(l1, "4"), append(l1, "5"), append(l1, "6")) |
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
import org.apache.commons.lang3.RandomUtils | |
import org.junit.Rule | |
import org.junit.rules.TemporaryFolder | |
import org.junit.rules.TestName | |
import org.springframework.util.StopWatch | |
import spock.lang.Shared | |
import spock.lang.Specification | |
class FileIOSpec extends Specification { |
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
package main | |
import "fmt" | |
func main() { | |
fmt.Println("-----") | |
if err := hoge(); err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println("-----") |
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 f = new File("/tmp/test.dat") | |
f.text = "1234567890" * 2 | |
def tryRead(ins) { | |
def buff = new byte[9] | |
println ins.read(buff) | |
println new String(buff) | |
} | |
f.withInputStream { ins -> |
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
// | |
// Helpers | |
// | |
void log(String message, boolean linefeed = true) { | |
if (linefeed) { | |
System.err.println message | |
} else { | |
System.err.print message | |
} |
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 ApacheCollectionsSpec extends Specification { | |
def "BoundedFifoBuffer"() { | |
given: | |
def buffer = new BoundedFifoBuffer(3) | |
when: | |
buffer.add(1) | |
buffer.add(2) | |
buffer.add(3) |
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
import org.spockframework.runtime.SpockTimeoutError | |
import spock.lang.FailsWith | |
import spock.lang.Specification | |
import spock.lang.Timeout | |
import java.util.concurrent.CopyOnWriteArrayList | |
class PipedStreamsSpec extends Specification { | |
PipedOutputStream pout = new PipedOutputStream() |
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
// in Groovy 2.4.14 | |
import groovy.transform.CompileStatic | |
// このようなprivate staticメソッドを使うメソッドをもつtraitに対して... | |
@CompileStatic | |
trait Trait { | |
String traitMethod() { _traitMethod() } | |
private static String _traitMethod() { "TRAIT" } | |
} |
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
// Groovy 3.0.0からラムダ記法が使えます。 | |
//def twice = (int num) -> { num * 2 } | |
//def twice = (num) -> { num * 2 } | |
def twice = num -> num * 2 | |
twice(100) | |
assert twice instanceof Closure | |
def hoge = () -> "HOGE" | |
assert hoge() == "HOGE" |
NewerOlder