Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ScalaCheck
Search
Pedro Matiello
August 28, 2013
Programming
420
1
Share
ScalaCheck
Presented at Scaladores, August/2013
Pedro Matiello
August 28, 2013
More Decks by Pedro Matiello
See All by Pedro Matiello
Lazy Evaluation em Scala
pmatiello
0
400
Por que dizemos que Scala é uma linguagem funcional?
pmatiello
0
380
Pistache: A π-Calculus Internal Domain Specific Language for Scala
pmatiello
1
460
Other Decks in Programming
See All in Programming
Don't Prompt Harder, Structure Better
kitasuke
0
650
AWS re:Invent 2025の少し振り返り + DevOps AgentとBacklogを連携させてみた
satoshi256kbyte
3
150
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
370
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
1
160
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
350
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
190
実践CRDT
tamadeveloper
0
430
CDK Deployのための ”反響定位”
watany
4
640
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
2.3k
LM Linkで(非力な!)ノートPCでローカルLLM
seosoft
0
450
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
560
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
260
Deep Space Network (abreviated)
tonyrice
0
110
How to build a perfect <img>
jonoalderson
1
5.4k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
340
Game over? The fight for quality and originality in the time of robots
wayneb77
1
160
Building AI with AI
inesmontani
PRO
1
880
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
510
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
240
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Test your architecture with Archunit
thirion
1
2.2k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
91
Transcript
SCALACHECK
SCALACHECK Pedro Matiello
[email protected]
@pmatiello
SCALACHECK • Property-based testing • Scala
PROPERTIES
PROPERTIES def sum(x:Int, y:Int) = x + y
PROPERTIES def sum(x:Int, y:Int) = x + y # Property:
∀x,y : sum(x,y) = sum(y,x)
PROPERTIES def sum(x:Int, y:Int) = x + y # Property:
∀x,y : sum(x,y) = sum(y,x) val commutativity = forAll { (x:Int, y:Int) => sum(x,y) == sum(y,x) }
PROPERTIES def sum(x:Int, y:Int) = x + y # Property:
∀x,y : sum(x,y) = sum(y,x) val commutativity = forAll { (x:Int, y:Int) => sum(x,y) == sum(y,x) }
PROPERTIES def sum(x:Int, y:Int) = x + y # Property:
∀x,y : sum(x,y) = sum(y,x) val commutativity = forAll { (x:Int, y:Int) => sum(x,y) == sum(y,x) } org.scalacheck.Prop.forAll
PROPERTIES def sum(x:Int, y:Int) = x + y # Property:
∀x,y : sum(x,y) = sum(y,x) val commutativity = forAll { (x:Int, y:Int) => sum(x,y) == sum(y,x) } commutativity.check
PROPERTIES def sum(x:Int, y:Int) = x + y # Property:
∀x,y : sum(x,y) = sum(y,x) val commutativity = forAll { (x:Int, y:Int) => sum(x,y) == sum(y,x) } commutativity.check + OK, passed 100 tests
CONDITIONAL PROPERTIES
CONDITIONAL PROPERTIES def sum(x:Int, y:Int) = x + y #
Property: ∀x,y>0 : sum(x,y) > x
CONDITIONAL PROPERTIES def sum(x:Int, y:Int) = x + y #
Property: ∀x,y>0 : sum(x,y) > x val greater = forAll { (x:Int, y:Int) => y > 0 ==> sum(x,y) > x }
CONDITIONAL PROPERTIES def sum(x:Int, y:Int) = x + y #
Property: ∀x,y>0 : sum(x,y) > x val greater = forAll { (x:Int, y:Int) => y > 0 ==> sum(x,y) > x }
CONDITIONAL PROPERTIES def sum(x:Int, y:Int) = x + y #
Property: ∀x,y>0 : sum(x,y) > x val greater = forAll { (x:Int, y:Int) => y > 0 ==> sum(x,y) > x } greater.check
CONDITIONAL PROPERTIES def sum(x:Int, y:Int) = x + y #
Property: ∀x,y>0 : sum(x,y) > x val greater = forAll { (x:Int, y:Int) => y > 0 ==> sum(x,y) > x } greater.check ! Falsified after 2 passed tests. > ARG_0: 51047075 > ARG_1: 2096436573
CONDITIONAL PROPERTIES scala> 51047075 + 2096436573 res0: Int = -2147483648
CONDITIONAL PROPERTIES scala> 51047075 + 2096436573 res0: Int = -2147483648
scala> 51047075l + 2096436573l res1: Long = 2147483648
GENERATORS
GENERATORS def sum(x:Int, y:Int) = x + y # ∀x,y,
x%2=0,y%2=0 : sum(x,y)%2 = 0
GENERATORS def sum(x:Int, y:Int) = x + y # ∀x,y,
x%2=0,y%2=0 : sum(x,y)%2 = 0 val evenInt = arbitrary[Int] suchThat (_ % 2 == 0)
GENERATORS def sum(x:Int, y:Int) = x + y # ∀x,y,
x%2=0,y%2=0 : sum(x,y)%2 = 0 val evenInt = arbitrary[Int] suchThat (_ % 2 == 0) org.scalacheck.Arbitrary.arbitrary
GENERATORS def sum(x:Int, y:Int) = x + y # ∀x,y,
x%2=0,y%2=0 : sum(x,y)%2 = 0 val evenInt = arbitrary[Int] suchThat (_ % 2 == 0) forAll(evenInt, evenInt) { (x:Int, y:Int) => sum(x,y) % 2 == 0 }.check
GENERATORS def sum(x:Int, y:Int) = x + y # ∀x,y,
x%2=0,y%2=0 : sum(x,y)%2 = 0 val evenInt = arbitrary[Int] suchThat (_ % 2 == 0) forAll(evenInt, evenInt) { (x:Int, y:Int) => sum(x,y) % 2 == 0 }.check
GENERATORS def sum(x:Int, y:Int) = x + y # ∀x,y,
x%2=0,y%2=0 : sum(x,y)%2 = 0 val evenInt = arbitrary[Int] suchThat (_ % 2 == 0) forAll(evenInt, evenInt) { (x:Int, y:Int) => sum(x,y) % 2 == 0 }.check + OK, passed 100 tests
SCALACHECK Pedro Matiello
[email protected]
@pmatiello