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
// Case #1 | |
// 数値によるソート(昇順)。 | |
def numList=[5, 2, 0, 3, 4] | |
assert numList.sort() == [0, 2, 3, 4, 5] | |
// Case #2 | |
// 数値によるソート(降順)。 | |
numList=[5, 2, 0, 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
// Case #1 | |
// リストの要素数を取得する | |
def list = ['a', 'b', 'c', 'b', 'c'] | |
assert list.size() == 5 |
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
// Case #1 | |
// リスト内の要素の重複を排除したリストを作る | |
def list = ['a', 'b', 'c', 'b', 'c'] | |
assert list.unique() == ['a', 'b', 'c'] | |
// 少し関連して注意すべき点。 | |
// PowerAssertの結果について、少し注意すべき。 | |
// 下記のアサートを実行すると、 |
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
// Case #1 | |
// リストの集合演算的な和をとる | |
def list1 = ['a' ,'b', 'c'] | |
def list2 = ['b', 'c', 'd', 'e'] | |
assert (list1 + list2).unique() == ['a', 'b', 'c', 'd', 'e'] | |
// Case #2 | |
// リストの集合演算的な積をとる(リストの共通部分をとる) |
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
// Case #1 | |
// リストのリストをフラットなリストにする | |
assert ['a', ['b', 'c',['d', 'e']]].flatten() == ['a', 'b', 'c', 'd', 'e'] | |
// Case #2 | |
// リスト展開演算子を用いて、リストを展開する | |
assert ['a', 'b', *['c', 'd']] == ['a', 'b', 'c', 'd'] |
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
// Case #1 | |
// リストの任意の要素をインデックス指定で削除する | |
def list1 = ['a', 'b', 'c', 'd'] | |
list1.remove(2) | |
assert list1 == ['a', 'b', 'd'] | |
// Case #2 |
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
// Case #1 | |
// 自然対数を計算する | |
assert Math.log(72) ==4.276666119016055 | |
assert Math.log(Math.E) == 1 | |
// Case #2 | |
// 10を底とした対数を計算する |
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
// Case #1 | |
// 数値の2進数、8進数、16進数、n進数表現 | |
// 2進数(00001111) | |
assert 0b00001111 == 15 | |
// 8進数(0100) | |
assert 0100 == 64 | |
// 16進数(ff) |
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
// Case #1 | |
// 数値の2進数、8進数、16進数、n進数表現(n進数以外はリテラル) | |
// 2進数(00001111) | |
assert 0b00001111 == 15 | |
// 8進数(0100) | |
assert 0100 == 64 | |
// 16進数(ff) |
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 org.junit.Test | |
import org.junit.experimental.runners.Enclosed | |
import org.junit.runner.RunWith; | |
import spock.lang.Specification | |
@RunWith(Enclosed.class) | |
class SpockJUnitMixTest { | |
static class Spockテストグループ1 extends Specification{ | |
def "Spockテスト1-1"() { | |
when: |