SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Clojure Example Functions

                        ilegra - LDC
By Jackson dos Santos
areduce
Apply an expression for each array element


user => (defn asum [numbers]
        (areduce numbers i ret (float 0)
              (+ ret (aget numbers i))))


user=> (asum (float-array [1 2 3]))
6
with-precision
Set a precision and rounding to work with point decimal values


user => (with-precision 20 (/ 1M 3))
0.33333333333333333333M
with-redefs
Mock temporally a value for a function or a variable. Available just in
  clojure 1.3


(defn address-lookup []
 (does some processing))


user> (with-redefs [address-lookup (fn [] "123 Main St.")]
       (println (address-lookup)))
"123 Main St.”
nill
4Clojure Problems Solved
4Clojure Problem
4Clojure Problem
4Clojure Problem
About Midje
What is It?


    It's an API to make your clojure tests more readable   .

    It's based in facts

    It has a lot of functionality to create test complex test cases
How to Use It?
   Create a new project
         ./cake new midje-evaluation


   Copy this file to your root project folder
         https://raw.github.com/marick/Midje/master/examples/cake-midje/tasks.clj



    Write your tests and install the project
         cake midje
More About Midje
About the sintax


(:use midje.sweet)


(fact
 ( [some function variable or object to test]) => [assertions])


(fact
 (+ 1 2) => 3)
More about Midje
It has the Metaconstants concept.


(defn numerical-reverser [n]
  (String/parseInt (string-reverser (str n))))


The function string-reverser doesn't exists. It's provided by test.


(fact
  (numerical-reverser 103) => 301
  (provided
    (string-reverser "103") => "301"))
More About Midje
It has a lot of checkers


(fact #{1 2 3} => (just [odd? odd? Even?])


(fact "as" => (contains [s a] :in-any-order))


(fact "12x" => (has-prefix #"d+"))


(fact "x12" => (has-suffix #"d+"))
More About Midje
You can mix wih def-test functions


(:use clojure.test)
(:use midje.sweet)


(deftest a-clojure-test-test
 (is (= 1 "I am a deftest expected result.")))


(fact
 (+ 1 2) => 3)
More About Midje
It can store the function state
 (fact
  (function-to-test) => [6 12]
  (provided
   (function-to-evaluate) =streams=> [ [1 2] [5 10] ] ))

Weitere ähnliche Inhalte

Was ist angesagt?

Pymongo for the Clueless
Pymongo for the CluelessPymongo for the Clueless
Pymongo for the CluelessChee Leong Chow
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montageKris Kowal
 
AJUG April 2011 Raw hadoop example
AJUG April 2011 Raw hadoop exampleAJUG April 2011 Raw hadoop example
AJUG April 2011 Raw hadoop exampleChristopher Curtin
 
Blender-like SceneView Hotkeys Unity extensions
Blender-like SceneView Hotkeys Unity extensionsBlender-like SceneView Hotkeys Unity extensions
Blender-like SceneView Hotkeys Unity extensionsKoji Hasegawa
 
Functions
FunctionsFunctions
FunctionsSV.CO
 
The Ring programming language version 1.7 book - Part 71 of 196
The Ring programming language version 1.7 book - Part 71 of 196The Ring programming language version 1.7 book - Part 71 of 196
The Ring programming language version 1.7 book - Part 71 of 196Mahmoud Samir Fayed
 
Python For Data Science Cheat Sheet
Python For Data Science Cheat SheetPython For Data Science Cheat Sheet
Python For Data Science Cheat SheetKarlijn Willems
 
Python 3.x Dictionaries and Sets Cheatsheet
Python 3.x Dictionaries and Sets CheatsheetPython 3.x Dictionaries and Sets Cheatsheet
Python 3.x Dictionaries and Sets CheatsheetIsham Rashik
 
Everything is composable
Everything is composableEverything is composable
Everything is composableVictor Igor
 
Designing Immutability Data Flows in Ember
Designing Immutability Data Flows in EmberDesigning Immutability Data Flows in Ember
Designing Immutability Data Flows in EmberJorge Lainfiesta
 
The Ring programming language version 1.5.2 book - Part 41 of 181
The Ring programming language version 1.5.2 book - Part 41 of 181The Ring programming language version 1.5.2 book - Part 41 of 181
The Ring programming language version 1.5.2 book - Part 41 of 181Mahmoud Samir Fayed
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲームNoritada Shimizu
 
Functional Core, Reactive Shell
Functional Core, Reactive ShellFunctional Core, Reactive Shell
Functional Core, Reactive ShellGiovanni Lodi
 
The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180Mahmoud Samir Fayed
 
Logic Equations Resolver J Script
Logic Equations Resolver   J ScriptLogic Equations Resolver   J Script
Logic Equations Resolver J ScriptRoman Agaev
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189Mahmoud Samir Fayed
 

Was ist angesagt? (20)

はじめてのGroovy
はじめてのGroovyはじめてのGroovy
はじめてのGroovy
 
Pymongo for the Clueless
Pymongo for the CluelessPymongo for the Clueless
Pymongo for the Clueless
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montage
 
AJUG April 2011 Raw hadoop example
AJUG April 2011 Raw hadoop exampleAJUG April 2011 Raw hadoop example
AJUG April 2011 Raw hadoop example
 
Blender-like SceneView Hotkeys Unity extensions
Blender-like SceneView Hotkeys Unity extensionsBlender-like SceneView Hotkeys Unity extensions
Blender-like SceneView Hotkeys Unity extensions
 
Functions
FunctionsFunctions
Functions
 
The Ring programming language version 1.7 book - Part 71 of 196
The Ring programming language version 1.7 book - Part 71 of 196The Ring programming language version 1.7 book - Part 71 of 196
The Ring programming language version 1.7 book - Part 71 of 196
 
Python For Data Science Cheat Sheet
Python For Data Science Cheat SheetPython For Data Science Cheat Sheet
Python For Data Science Cheat Sheet
 
Python 3.x Dictionaries and Sets Cheatsheet
Python 3.x Dictionaries and Sets CheatsheetPython 3.x Dictionaries and Sets Cheatsheet
Python 3.x Dictionaries and Sets Cheatsheet
 
Everything is composable
Everything is composableEverything is composable
Everything is composable
 
Promise
PromisePromise
Promise
 
Designing Immutability Data Flows in Ember
Designing Immutability Data Flows in EmberDesigning Immutability Data Flows in Ember
Designing Immutability Data Flows in Ember
 
The Ring programming language version 1.5.2 book - Part 41 of 181
The Ring programming language version 1.5.2 book - Part 41 of 181The Ring programming language version 1.5.2 book - Part 41 of 181
The Ring programming language version 1.5.2 book - Part 41 of 181
 
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop - Xi...
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop  - Xi...PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop  - Xi...
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop - Xi...
 
Oop lecture9 13
Oop lecture9 13Oop lecture9 13
Oop lecture9 13
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲーム
 
Functional Core, Reactive Shell
Functional Core, Reactive ShellFunctional Core, Reactive Shell
Functional Core, Reactive Shell
 
The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180
 
Logic Equations Resolver J Script
Logic Equations Resolver   J ScriptLogic Equations Resolver   J Script
Logic Equations Resolver J Script
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189
 

Andere mochten auch (8)

Aurinko
AurinkoAurinko
Aurinko
 
Haskell
HaskellHaskell
Haskell
 
Gcontract
GcontractGcontract
Gcontract
 
Presentation about ClosureScript fraemework
Presentation about ClosureScript fraemeworkPresentation about ClosureScript fraemework
Presentation about ClosureScript fraemework
 
Jboss AS7 New Main Features
Jboss AS7 New Main FeaturesJboss AS7 New Main Features
Jboss AS7 New Main Features
 
Ocaml
OcamlOcaml
Ocaml
 
Introduction to HashiCorp Consul
Introduction to HashiCorp ConsulIntroduction to HashiCorp Consul
Introduction to HashiCorp Consul
 
Ocaml
OcamlOcaml
Ocaml
 

Ähnlich wie Clojure functions midje

Basic R Data Manipulation
Basic R Data ManipulationBasic R Data Manipulation
Basic R Data ManipulationChu An
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2Kevin Chun-Hsien Hsu
 
Very basic functional design patterns
Very basic functional design patternsVery basic functional design patterns
Very basic functional design patternsTomasz Kowal
 
Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Cdiscount
 
Vectors data frames
Vectors data framesVectors data frames
Vectors data framesFAO
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212Mahmoud Samir Fayed
 
NPTEL QUIZ.docx
NPTEL QUIZ.docxNPTEL QUIZ.docx
NPTEL QUIZ.docxGEETHAR59
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data ScienceMike Anderson
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Day 1c access, select ordering copy.pptx
Day 1c   access, select   ordering copy.pptxDay 1c   access, select   ordering copy.pptx
Day 1c access, select ordering copy.pptxAdrien Melquiond
 
Clojure in the Wild
Clojure in the WildClojure in the Wild
Clojure in the Wildsuitzero
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytestSuraj Deshmukh
 
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...Dr. Volkan OBAN
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side JavascriptJulie Iskander
 

Ähnlich wie Clojure functions midje (20)

Basic R Data Manipulation
Basic R Data ManipulationBasic R Data Manipulation
Basic R Data Manipulation
 
Clojure basics
Clojure basicsClojure basics
Clojure basics
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
 
Very basic functional design patterns
Very basic functional design patternsVery basic functional design patterns
Very basic functional design patterns
 
Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
 
Vectors data frames
Vectors data framesVectors data frames
Vectors data frames
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212
 
NPTEL QUIZ.docx
NPTEL QUIZ.docxNPTEL QUIZ.docx
NPTEL QUIZ.docx
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data Science
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Day 1c access, select ordering copy.pptx
Day 1c   access, select   ordering copy.pptxDay 1c   access, select   ordering copy.pptx
Day 1c access, select ordering copy.pptx
 
Clojure in the Wild
Clojure in the WildClojure in the Wild
Clojure in the Wild
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytest
 
6. R data structures
6. R data structures6. R data structures
6. R data structures
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Xgboost
XgboostXgboost
Xgboost
 
Python testing
Python  testingPython  testing
Python testing
 

Mehr von Jackson dos Santos Olveira (20)

AWS Control Tower
AWS Control TowerAWS Control Tower
AWS Control Tower
 
Netty training
Netty trainingNetty training
Netty training
 
An introduction to predictionIO
An introduction to predictionIOAn introduction to predictionIO
An introduction to predictionIO
 
Apache mahout - introduction
Apache mahout - introductionApache mahout - introduction
Apache mahout - introduction
 
Managing computational resources with Apache Mesos
Managing computational resources with Apache MesosManaging computational resources with Apache Mesos
Managing computational resources with Apache Mesos
 
Introduction to CFEngine
Introduction to CFEngineIntroduction to CFEngine
Introduction to CFEngine
 
DBC Principles
DBC PrinciplesDBC Principles
DBC Principles
 
Racket
RacketRacket
Racket
 
Jboss Teiid - The data you have on the place you need
Jboss Teiid - The data you have on the place you needJboss Teiid - The data you have on the place you need
Jboss Teiid - The data you have on the place you need
 
Apache PIG introduction
Apache PIG introductionApache PIG introduction
Apache PIG introduction
 
Celery Introduction
Celery IntroductionCelery Introduction
Celery Introduction
 
Solid
SolidSolid
Solid
 
Elastic search introduction
Elastic search introductionElastic search introduction
Elastic search introduction
 
Android
AndroidAndroid
Android
 
Clojure functions 4
Clojure functions 4Clojure functions 4
Clojure functions 4
 
Jython Presentation
Jython PresentationJython Presentation
Jython Presentation
 
Clojure functions 3
Clojure functions 3Clojure functions 3
Clojure functions 3
 
Clojure functions
Clojure functionsClojure functions
Clojure functions
 
Prototype js
Prototype jsPrototype js
Prototype js
 
Google application engine
Google application engineGoogle application engine
Google application engine
 

Kürzlich hochgeladen

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Kürzlich hochgeladen (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

Clojure functions midje

  • 1. Clojure Example Functions ilegra - LDC By Jackson dos Santos
  • 2. areduce Apply an expression for each array element user => (defn asum [numbers] (areduce numbers i ret (float 0) (+ ret (aget numbers i)))) user=> (asum (float-array [1 2 3])) 6
  • 3. with-precision Set a precision and rounding to work with point decimal values user => (with-precision 20 (/ 1M 3)) 0.33333333333333333333M
  • 4. with-redefs Mock temporally a value for a function or a variable. Available just in clojure 1.3 (defn address-lookup [] (does some processing)) user> (with-redefs [address-lookup (fn [] "123 Main St.")] (println (address-lookup))) "123 Main St.” nill
  • 10. What is It?  It's an API to make your clojure tests more readable .  It's based in facts  It has a lot of functionality to create test complex test cases
  • 11. How to Use It?  Create a new project  ./cake new midje-evaluation  Copy this file to your root project folder  https://raw.github.com/marick/Midje/master/examples/cake-midje/tasks.clj  Write your tests and install the project  cake midje
  • 12. More About Midje About the sintax (:use midje.sweet) (fact ( [some function variable or object to test]) => [assertions]) (fact (+ 1 2) => 3)
  • 13. More about Midje It has the Metaconstants concept. (defn numerical-reverser [n] (String/parseInt (string-reverser (str n)))) The function string-reverser doesn't exists. It's provided by test. (fact (numerical-reverser 103) => 301 (provided (string-reverser "103") => "301"))
  • 14. More About Midje It has a lot of checkers (fact #{1 2 3} => (just [odd? odd? Even?]) (fact "as" => (contains [s a] :in-any-order)) (fact "12x" => (has-prefix #"d+")) (fact "x12" => (has-suffix #"d+"))
  • 15. More About Midje You can mix wih def-test functions (:use clojure.test) (:use midje.sweet) (deftest a-clojure-test-test (is (= 1 "I am a deftest expected result."))) (fact (+ 1 2) => 3)
  • 16. More About Midje It can store the function state (fact (function-to-test) => [6 12] (provided (function-to-evaluate) =streams=> [ [1 2] [5 10] ] ))