Slide 1

Slide 1 text

Copyright (C) DeNA Co.,Ltd. All Rights Reserved. iOS Test Night #5 2017/07/26(Wed) 
 ࡉপ༞հ@DeNA 1SPQFSUZCBTFEUFTUJOH XJUI4XJGU$IFDL 1

Slide 2

Slide 2 text

˙:VTVLF)PTPOVNBʢ!UPCJʣ • ॴଐ ⁃ %F/"48&5άϧʔϓςετج൫νʔϜ • ܦྺ ⁃ J04ΤϯδχΞ⾣೥݄ʹ%F/"48&5άϧʔϓʹ+PJO • ීஈͷۀ຿ ⁃ όʔδϣϯɾΞοϓࣗಈݕূγεςϜʢϚεςΟϑʣͷ։ൃ ⁃ ΞϓϦͷςετʹ·ͭΘΔௐ͍ࠪΖ͍Ζ • ଞ ⁃ ͱ͔޷͖Ͱ͢ ࣗݾ঺հ Copyright (C) DeNA Co.,Ltd. All Rights Reserved. 2

Slide 3

Slide 3 text

ࠓ೔ɺ࿩͢͜ͱ 3 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 4

Slide 4 text

1SPQFSUZCBTFEUFTUJOH 4XJGU$IFDL 4 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 5

Slide 5 text

ΞδΣϯμ 5 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • 1SPQFSUZCBTFEUFTUJOHͱ͸ʁ • 4XJGU$IFDLͱ͸ʁ • ۩ମྫͰݟΔ • ྫ ଍͠ࢉ • ྫ ഑ྻͷ൓స • ༻ޠ • ࣮ફతͳϢʔεέʔε • ·ͱΊ

Slide 6

Slide 6 text

1SPQFSUZCBTFEUFTUJOH ͱ͸ʁ 6 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 7

Slide 7 text

Property-based testing ͱ͸ʁ 7 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ଟ਺ͳϥϯμϜ஋Λ'8ʹࣗಈੜ੒ͤ͞ɺ • ςετର৅ͷੑ࣭ʢ1SPQFSUZʣΛίʔυͰఆٛ͠ɺ • ͦͷੑ࣭͕ഁΒΕΔ஋͕ͳ͍͔ݕূ͢Δ • Ϣχοτςετख๏ͷͭ • ؔ਺ܕݴޠ)BTLFMMͷʮ2VJDL$IFDLʯ͕ݩ

Slide 8

Slide 8 text

4XJGU$IFDL 8 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 9

Slide 9 text

4XJGU$IFDLͱ͸ʁ 9 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • 2VJDL$IFDLͷ4XJGU࣮૷ • IUUQTHJUIVCDPNUZQFMJGU4XJGU$IFDL • 9$5FTUʹ૊ΈࠐΊΔ • 4XJGU[Λ࡞͍ͬͯΔ5ZQF-JGUͷϦϙδτϦ • 4XJGU[ͷςετʹ΋࢖ΘΕͯΔ • .*5MJDFOTF

Slide 10

Slide 10 text

10 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • 1SPQFSUZCBTFEUFTUJOHͱ͸ʁ • 4XJGU$IFDLͱ͸ʁ • ۩ମྫͰݟΔ • ྫ ଍͠ࢉ • ྫ ഑ྻͷ൓స • ༻ޠ • ࣮ફతͳϢʔεέʔε • ·ͱΊ

Slide 11

Slide 11 text

۩ମྫͱͯ͠ ଍͠ࢉͷςετΛߟ͑ͯΈΔ 11 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 12

Slide 12 text

9$5FTU &YBNQMFCBTFEUFTUJOH 12 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 13

Slide 13 text

// ϓϩμΫτίʔυ func add(_ x: UInt, _ y: UInt) -> UInt { return x + y } // ςετίʔυ func test_add_by_assert() { XCTAssertEqual(add(1, 2), 3) } XCTest Ͱͷ଍͠ࢉͷςετ 13 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. 1 + 2 ͷ݁Ռ͸ 3 Ͱ͋Δ͜ͱ • ҰൠతͳY6OJU͕ఏڙ͍ͯ͠Δํ๏ • 2VJDLͳͲͷ#%%ͳ'8΋ຊ࣭తʹ͸ಉ͡

Slide 14

Slide 14 text

ਤઆ 14 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. ̍ʴ̎ʹ̏ ೖྗ஋ ೖྗ஋ ظ଴஋ ςετର৅

Slide 15

Slide 15 text

ਤઆ 15 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. ̍ʴ̎ʹ̏ ೖྗ஋ ೖྗ஋ ظ଴஋ ςετର৅ ೖྗ஋ͱظ଴஋͸ɺ ։ൃऀ͕໌ࣔతʹબͿඞཁ͕͋Δ

Slide 16

Slide 16 text

Ͳ͏΍ͬͯೖྗ஋ΛબͿʁ 16 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 17

Slide 17 text

ςετ༻ͷೖྗ஋ΛબͿٕज़ 17 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ಉ஋෼ׂ๏ • ڥք஋෼ੳ • ΫϥγϑΟέʔγϣϯπϦʔ • 1BJSXJTF๏ • FUDʜ

Slide 18

Slide 18 text

ςετ༻ͷೖྗ஋ΛબͿٕज़ 18 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ಉ஋෼ׂ๏ • ڥք஋෼ੳ • ΫϥγϑΟέʔγϣϯπϦʔ • 1BJSXJTF๏ • FUDʜ ͲΕ΋֬཰తʹόάͷى͖΍͍͢σʔ λΛ༧ଌͯ͠ɺಛఆ஋ͷΈͰςετ

Slide 19

Slide 19 text

4XJGU$IFDL 1SPQFSUZCBTFEUFTUJOH 19 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 20

Slide 20 text

·ͣ଍͠ࢉͷੑ࣭Λߟ͑Δ 20 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 21

Slide 21 text

଍͠ࢉͷੑ࣭ 21 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ݁߹๏ଇΛຬͨ͢ • YZZY • Λճ଍ͨ͠΋ͷͱɺΛճ଍ͨ͠΋ͷ͸౳͍͠ • YY • ʢͪͳΈʹʣҾ͖ࢉ͸݁߹๏ଇΛຬͨ͞ͳ͍ • YZ㱠ZY

Slide 22

Slide 22 text

଍͠ࢉͷੑ࣭ 22 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ݁߹๏ଇΛຬͨ͢ • YZZY • Λճ଍ͨ͠΋ͷͱɺΛճ଍ͨ͠΋ͷ͸౳͍͠ • YY • ʢͪͳΈʹʣҾ͖ࢉ͸݁߹ੑ͋Γ • YZ㱠ZY ͜ΕΒ͕ͲΜͳೖྗ஋ʹରͯ͠΋ อͨΕΔ΂͖ੑ࣭Ͱ͋Δɺͱߟ͑Δ

Slide 23

Slide 23 text

4XJGU$IFDLͰॻ͍ͯΈΔ 23 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 24

Slide 24 text

4XJGU$IFDLͰͷ଍͠ࢉͷੑ࣭ςετ 24 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. // ;ͭ͏ͷXCTestͱಉ͡Α͏ʹ಄ʹ`test`Λ͚ͭΔ func test_add_property() { // x + y == y + x property("଍͠ࢉ͸݁߹๏ଇΛຬͨ͢") <- forAll { (x: UInt, y: UInt) in return add(x, y) == add(y, x) } // x + 1 + 1 == x + 2 property("1Λ2ճ଍ͨ͠ͷͱɺ2Λ1ճ଍ͨ͠΋ͷ͸౳͍͠") <- forAll { (x: UInt) in return add(add(x, 1), 1) == add(x, 2) } }

Slide 25

Slide 25 text

4XJGU$IFDLͰͷ଍͠ࢉͷੑ࣭ςετ 25 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. func test_add_property() { // x + y == y + x property("଍͠ࢉ͸݁߹๏ଇΛຬͨ͢") <- forAll { (x: UInt, y: UInt) in return add(x, y) == add(y, x) } } ᶃੑ࣭ͷએݴ

Slide 26

Slide 26 text

4XJGU$IFDLͰͷ଍͠ࢉͷੑ࣭ςετ 26 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. func test_add_property() { // x + y == y + x property("଍͠ࢉ͸݁߹๏ଇΛຬͨ͢") <- forAll { (x: UInt, y: UInt) in return add(x, y) == add(y, x) } } ᶄ೚ҙͷೖྗ஋

Slide 27

Slide 27 text

4XJGU$IFDLͰͷ଍͠ࢉͷੑ࣭ςετ 27 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. func test_add_property() { // x + y == y + x property("଍͠ࢉ͸݁߹๏ଇΛຬͨ͢") <- forAll { (x: UInt, y: UInt) in return add(x, y) == add(y, x) } } ᶅશͯʹର͠

Slide 28

Slide 28 text

4XJGU$IFDLͰͷ଍͠ࢉͷੑ࣭ςετ 28 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. func test_add_property() { // x + y == y + x property("଍͠ࢉ͸݁߹๏ଇΛຬͨ͢") <- forAll { (x: UInt, y: UInt) in return add(x, y) == add(y, x) } } ᶆ͜ͷ͕ࣜ੒Γཱͭ

Slide 29

Slide 29 text

4XJGU$IFDLͰͷ଍͠ࢉͷੑ࣭ςετ 29 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. func test_add_property() { // x + y == y + x property("଍͠ࢉ͸݁߹๏ଇΛຬͨ͢") <- forAll { (x: UInt, y: UInt) in return add(x, y) == add(y, x) } } ᶃੑ࣭ͷએݴ ᶄ೚ҙͷೖྗ஋ ᶅશͯʹର͠ ᶆ͜ͷ͕ࣜ੒Γཱͭ

Slide 30

Slide 30 text

͜ΕΛ࣮ߦ͢Δͱʁ 30 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 31

Slide 31 text

Test Case '-[SwiftCheckSampleTests.SwiftCheckSampleTests test_add_property]' started. *** Passed 100 tests . *** Passed 100 tests . Test Case '-[SwiftCheckSampleTests.SwiftCheckSampleTests test_add_property]' passed (0.009 seconds). 4XJGU$IFDLͰͷςετ͕੒ޭ 31 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. ίϯιʔϧ 1BTTFEUFTUT ݸ΋ͷϥϯμϜ஋Ͱςετ͕͞Ε͍ͯΔʂ

Slide 32

Slide 32 text

۩ମతʹͲΜͳ஋͕ બ͹Ε͍ͯΔͷ͔ʁ 32 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 33

Slide 33 text

۩ମతʹબ͹Ε͍ͯͨ஋ 33 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. Test Case '-[SwiftCheckSampleTests.SwiftCheckSampleTests test_add_property]' started. x: 0, y: 0 x: 1, y: 1 x: 0, y: 2 x: 3, y: 3 x: 0, y: 0 x: 1, y: 1 x: 0, y: 6 x: 4, y: 1 … x: 26, y: 19 x: 34, y: 51 x: 40, y: 18 x: 10, y: 13 x: 49, y: 22 x: 9, y: 14 x: 31, y: 65 x: 45, y: 15 x: 30, y: 32 x: 46, y: 54 x: 65, y: 34 x: 57, y: 41 … x: 58, y: 17 x: 67, y: 17 x: 41, y: 93 x: 21, y: 17 *** Passed 100 tests ϥϯμϜ͚ͩΕͲɺ খ͞Ίͷ஋͔Βςετ͞Ε͍ͯΔ

Slide 34

Slide 34 text

ͱ͜ΖͰࣦഊ͢Δͱʁ 34 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 35

Slide 35 text

*** Failed! Proposition: x + 1 + 1 == x + 2 Falsifiable (after 3 tests and 2 shrinks): 1 *** Passed 2 tests 4XJGU$IFDLͰͷςετ͕੒ޭ 35 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. ίϯιʔϧ ஋͕ʮʯͷέʔεͰɺ ςετ͕ύε͠ͳ͔ͬͨ͜ͱ͕ใࠂ͞Εͨ

Slide 36

Slide 36 text

࣮ࡍʹʮʯͷέʔεͰ ࢼͯ͠ΈΔͱɾɾɾ 36 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 37

Slide 37 text

9$5"TTFSU&RVBMͰݕূ 37 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. ͔֬ʹςετ͕ࣦഊͨ͠ʂ func add(_ x: UInt, _ y: UInt) -> UInt { return x * y } ݪҼ͸ֻ͚ࢉʹͳ͍ͬͯͨҝ

Slide 38

Slide 38 text

38 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • 1SPQFSUZCBTFEUFTUJOHͱ͸ʁ • 4XJGU$IFDLͱ͸ʁ • ۩ମྫͰݟΔ • ྫ ଍͠ࢉ • ྫ ഑ྻͷ൓స • ༻ޠ • ࣮ફతͳϢʔεέʔε • ·ͱΊ

Slide 39

Slide 39 text

഑ྻͷ൓స "SSBZSFWFSTFE 39 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 40

Slide 40 text

൓స SFWFSTF ͷੑ࣭ͱ͸ʁ 40 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 41

Slide 41 text

഑ྻͷ൓సͷੑ࣭ͱ͸ʁ 41 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. ˣ൓స SFWFSTF ˣ൓స SFWFSTF ճ൓సͤ͞Δͱݩʹ໭Δʂ

Slide 42

Slide 42 text

4XJGU$IFDLͰॻ͍ͯΈΔ 42 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 43

Slide 43 text

func test_reversed() { property("഑ྻͷ൓సͷ൓స͸ݩͷ഑ྻͱಉ͡") <- forAll { (xs: ArrayOf) in let ys = xs.getArray return ys.reversed().reversed() == ys } } 4XJGU$IFDLͰ഑ྻͷ൓సͷςετ 43 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. YT<5> ͱදݱͰ͖ͳ͍ͷ͸4XJGUͷ੍ݶɻ ୅ΘΓʹ"SSBZ0G5ͱ͍͏ϥούʔΛࢦఆ͠ɺ HFU"SSBZͰத਎ΛऔΓग़͠ɻ "SSBZ0G*OU

Slide 44

Slide 44 text

͜͜·Ͱͷ·ͱΊ 44 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 45

Slide 45 text

͜͜·Ͱͷ·ͱΊ 45 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • 1SPQFSUZCBTFEUFTUJOH • ςετͱͯ͠ੑ࣭ʢQSPQFSUZʣΛఆٛ • '8͕܁Γฦ͠ϥϯμϜ஋ͰςετΛ࣮ߦ • 4XJGU$IFDL • 9$5FTUͱ૊Έ߹Θͤͯ࢖͑Δ • ࣦഊͨ͠৔߹ɺͦͷ஋Λใࠂͯ͘͠ΕΔ • ͦͷ஋͸Ͱ͖Δ͚ͩখ͍͞஋͕બ͹Ε͍ͯΔ

Slide 46

Slide 46 text

46 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • 1SPQFSUZCBTFEUFTUJOHͱ͸ʁ • 4XJGU$IFDLͱ͸ʁ • ۩ମྫͰݟΔ • ྫ ଍͠ࢉ • ྫ ഑ྻͷ൓స • ༻ޠ • ࣮ફతͳϢʔεέʔε • ·ͱΊ

Slide 47

Slide 47 text

1SPQFSUZCBTFEUFTUJOH Ͱͷ༻ޠ 47 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 48

Slide 48 text

"SCJUSBSZ 48 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 49

Slide 49 text

Arbitrary 49 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ʮ೚ҙͷʯͱ͍ͬͨҙຯ • 4XJGU$IFDLͰ͸ϓϩτίϧͱͯ͠ఆٛ • ಛఆͷܕͷϥϯμϜ஋Λੜ੒͢Δ໾ׂ • 4XJGUඪ४ͷܕʹ͸σϑΥϧτ࣮૷͕ఏڙ͞ΕΔ • ͜Εʹ४ڌ͢Δ͜ͱͰϥϯμϜ஋͕ੜ੒Ͱ͖ΔΑ͏ʹ public protocol Arbitrary { public static var arbitrary: SwiftCheck.Gen { get } public static func shrink(_: Self) -> [Self] }

Slide 50

Slide 50 text

4ISJOLJOH 50 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 51

Slide 51 text

Shrinking 51 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ʮऩॖ͢Δʯͱ͍ͬͨҙຯ • ಉ͘͡"SCJUSBSZϓϩτίϧʹఆٛʢPQUJPOBMʣ • ΑΓখ͞ͳ஋ʹ͢Δ໾ׂ • ͜ΕʹΑΓࣦഊͨ͠ςετσʔλʹ͍ͭͯɺ
 ΑΓখ͞ͳࣦഊέʔεΛબग़͢Δ࢓૊Έ Int.shrink(10) // => [0, 1, 2, 5] String.shrink(“app") // => ["p", "pp", ... ,"apa", "apb"]

Slide 52

Slide 52 text

Shrinking 52 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ʢࣦഊʣ
 ˣTISJOL • ʢࣦഊʣ
 ˣTISJOL • ʢࣦഊʣ⾣ɹ͜ΕΛʢ࠷খͷʣࣦഊྫͱͯ͠ใࠂ
 ˣTISJOL • ʢ੒ޭʣ

Slide 53

Slide 53 text

53 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • 1SPQFSUZCBTFEUFTUJOHͱ͸ʁ • 4XJGU$IFDLͱ͸ʁ • ۩ମྫͰݟΔ • ྫ ଍͠ࢉ • ྫ ഑ྻͷ൓స • ༻ޠ • ࣮ફతͳϢʔεέʔε • ·ͱΊ

Slide 54

Slide 54 text

1SPQFSUZCBTFEUFTUJOH ͕༗ޮͳέʔε 54 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 55

Slide 55 text

Property-based testing ͕༗ޮͳέʔε 55 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ᶃ&ODPEF%FDPEF • ᶄ஗͘໌֬ͳΞϧΰϦζϜWTߴ଎ͳΞϧΰϦζϜ • ᶅϥϯμϜੑʹج͍ͮͨΞϧΰϦζϜ

Slide 56

Slide 56 text

ᶃ&ODPEF%FDPEF 56 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 57

Slide 57 text

Encode / Decode ͷϢχοτςετ 57 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ΘΓͱେม • ϓϩύςΟ͕ଟ͍ͱॻ͘ͷେม • ಉ͡ೖྗ஋Λ࢖͏ͱೖΕସ͑Λݕग़Ͱ͖ͳ͍ • ςετΛॻ͘࿑ྗʹݟ߹͍ͬͯΔ͔ʁ • ϦεΫ͕ߴ͍ • Ұݟਖ਼͘͠ಈ͍͍ͯΔΑ͏ʹΈ͑Δ • ͚ΕͲɺҰ෦ͷ߲໨͚͚͍ͩܽͯͨΓ

Slide 58

Slide 58 text

Encode / Decode ͷੑ࣭ 58 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • &ODPEF%FDPEFͨ͠΋ͷ͸ݩͱಉ͡ • EFDPEF FODPEF PCK PCK

Slide 59

Slide 59 text

Dogߏ଄ମ 59 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. public struct Dog: Equatable { let name: String let age: Int func encode() -> [String: String] { return [ "name": name, "age": "\(age)", ] } static func decode(_ encoded: [String: String]) -> Dog? { guard let name = encoded["name"], let age = (encoded["age"].flatMap{ Int($0) }) else { return nil } return Dog(name: name, age: age) } } public func == (a: Dog, b: Dog) -> Bool { return a.name == b.name && a.age == b.age }

Slide 60

Slide 60 text

Dog Λ Arbiratyϓϩτίϧʹ४ڌͤ͞Δ 60 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. extension Dog: Arbitrary { public static var arbitrary: SwiftCheck.Gen { return Gen<(String, Int)> .zip(String.arbitrary, Int.arbitrary) .map(Dog.init) } } ࠓճ͸TISJOLͷ࣮૷͸ׂѪ ʢͳͯ͘΋ಈ͖͸͢Δʣ

Slide 61

Slide 61 text

SwiftCheckͰͷςετίʔυ 61 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. func testDogEncodeDecode() { property(“DogΛencodeͯ͠decodeͨ͠΋ͷ͸ɺݩͱಉ͡") <- forAll { (dog: Dog) in guard let decoded = Dog.decode(dog.encode()) else { return false } return dog == decoded } } "SCJUSBSZʹ४ڌͨ͠ͷͰɺ ϥϯμϜ஋͕ੜ੒Ͱ͖ΔΑ͏ʹͳͬͨ

Slide 62

Slide 62 text

༷ʑͳσʔλͰςετ͞Ε͍ͯΔ 62 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. Dog(name: "", age: 0) Dog(name: "O", age: 1) Dog(name: "d", age: 1) Dog(name: "ÇÆØ", age: 3) Dog(name: "!\\-", age: -4) Dog(name: "0S=ä", age: 3) Dog(name: "¡¨sóø", age: 1) Dog(name: "Ü+_

Slide 63

Slide 63 text

ᶄ஗͘໌֬ͳΞϧΰϦζϜ WT ߴ଎ͳΞϧΰϦζϜ 63 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 64

Slide 64 text

஗͘໌֬ͳΞϧΰϦζϜ vs ߴ଎ͳΞϧΰϦζϜ 64 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ΞϧΰϦζϜ • ໌֬ͳॻ͖ํΛ͢Δͱʢ͍͍ͩͨʣ஗͍ • ߴ଎ʹ͢Δͱʢ͍͍ͩͨʣίʔυ͕ෳࡶʹͳΔ • ςετͷ೉͠͞ • +BWBͷ4%,ʹؚ·ΕΔೋ෼୳ࡧ͸ɺ
 ೥ؒ΋όάʹؾ͔ͮΕͳ͔ͬͨ

Slide 65

Slide 65 text

஗͘໌֬ͳΞϧΰϦζϜ vs ߴ଎ͳΞϧΰϦζϜ 65 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • ੑ࣭Λߟ͑Δ • ೖྗ஋͕ಉ͡Ͱ͋Ε͹ɺ྆ऀͷ݁Ռ͸ৗʹಉ͡

Slide 66

Slide 66 text

֊৐ΛٻΊΔίʔυ 66 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. // ֊৐Λ࠶ؼͰٻΊΔ func fact(_ n: Int) -> Int { if n == 1 { return 1 } return n * fact(n - 1) } // ֊৐ΛϧʔϓͰٻΊΔ func factFast(_ n: Int) -> Int { var r = n var i = n - 1 while i > 1 { r *= i i = i - 1 } return r } ࠶ؼ൛͸͍͕ٙͳ͍͘Β͍ʹ໌֬ɻ͚ΕͲίʔϧ ελοΫͷ෼ɺύϑΥʔϚϯε͸ѱ͍

Slide 67

Slide 67 text

SwiftCheckͰͷςετίʔυ 67 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. func test_fact() { // 1ʙ20ͷ஋ΛબͿʢେ͖͗͢ΔͱΤϥʔʹͳΔͨΊʣ let gen: Gen = Gen.choose((1, 20)) property("fact()ͱfactFast()͸ৗʹಉ݁͡ՌΛฦ͢͜ͱ") <- forAll(gen) { (n: Int) in return fact(n) == factFast(n) } } ໌֬ͳΞϧΰϦζϜͷ݁ՌͱҰக͍ͯ͠Ε͹ɺߴ ଎ͳΞϧΰϦζϜ΋ਖ਼͘͠ػೳ͍ͯ͠Δͱߟ͑Β ΕΔ DIPPTFͰ஋ͷൣғΛ੍ݶ

Slide 68

Slide 68 text

ᶅϥϯμϜੑʹج͍ͮͨ ΞϧΰϦζϜ 68 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 69

Slide 69 text

ϥϯμϜੑʹج͍ͮͨΞϧΰϦζϜ 69 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • έʔε • μϯδϣϯϚοϓͷੜ੒ • μΠεϩʔϧ • ੑ࣭Λߟ͑Δ • Ϛοϓ͸ඞͣΰʔϧʹͭͳ͕͍ͬͯΔ͜ͱ • Ϛοϓʹ౸ୡͰ͖ͳ͍෦԰͕ͳ͍͜ͱ • े෼ʹۉ౳ͳϥϯμϜੑ͕ಘΒΕΔ͜ͱ

Slide 70

Slide 70 text

ࠓ೔ͷ·ͱΊ 70 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.

Slide 71

Slide 71 text

·ͱΊ 71 Copyright (C) DeNA Co.,Ltd. All Rights Reserved. • 1SPQFSUZCBTFEUFTUJOH • ੑ࣭ʢQSPQFSUZʣʹண໨ͨ͠Ϣχοτςετख๏ • ଟ਺ͳϥϯμϜ஋Ͱςετ͞ΕΔ • 4XJGU$IFDLͰ9$5FTUͱ૊Έ߹Θͤͯ࢖͑Δ • ࢖͍Ͳ͜Ζ • ޻෉࣍ୈͰ͍Ζ͍Ζ͋Γͦ͏ • &YBNQMFCBTFEUFTUJOHͱ஥ྑ͘

Slide 72

Slide 72 text

&OKPZUIF5FTU 72 Copyright (C) DeNA Co.,Ltd. All Rights Reserved.