From babe20090a50657b0dadaf9cda75224abcd9fb0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Wed, 24 May 2023 09:00:57 +0200 Subject: [PATCH] add tarantula --- .../spectrum/SpectrumFormula.java | 4 +++- .../spectrum/formulas/TarantulaFormula.java | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/main/java/fr/spoonlabs/flacoco/localization/spectrum/formulas/TarantulaFormula.java diff --git a/src/main/java/fr/spoonlabs/flacoco/localization/spectrum/SpectrumFormula.java b/src/main/java/fr/spoonlabs/flacoco/localization/spectrum/SpectrumFormula.java index ac20f7e0..739fc2de 100644 --- a/src/main/java/fr/spoonlabs/flacoco/localization/spectrum/SpectrumFormula.java +++ b/src/main/java/fr/spoonlabs/flacoco/localization/spectrum/SpectrumFormula.java @@ -2,10 +2,12 @@ import fr.spoonlabs.flacoco.localization.spectrum.formulas.Formula; import fr.spoonlabs.flacoco.localization.spectrum.formulas.OchiaiFormula; +import fr.spoonlabs.flacoco.localization.spectrum.formulas.TarantulaFormula; public enum SpectrumFormula { - OCHIAI(new OchiaiFormula()); + OCHIAI(new OchiaiFormula()), + TARANTULA(new TarantulaFormula()); private final Formula formula; diff --git a/src/main/java/fr/spoonlabs/flacoco/localization/spectrum/formulas/TarantulaFormula.java b/src/main/java/fr/spoonlabs/flacoco/localization/spectrum/formulas/TarantulaFormula.java new file mode 100644 index 00000000..35b29fd7 --- /dev/null +++ b/src/main/java/fr/spoonlabs/flacoco/localization/spectrum/formulas/TarantulaFormula.java @@ -0,0 +1,20 @@ +package fr.spoonlabs.flacoco.localization.spectrum.formulas; + +public class TarantulaFormula implements Formula { + + public TarantulaFormula() { + } + + public double compute(double nPassingNotExecuting, double nFailingNotExecuting, double nPassingExecuting, + double nFailingExecuting) { + double passingTerm = nPassingNotExecuting + nPassingExecuting == 0 ? 0 : nPassingExecuting / (nPassingNotExecuting + nPassingExecuting); + double failingTerm = nFailingNotExecuting + nFailingExecuting == 0 ? 0 : nFailingExecuting / (nFailingNotExecuting + nFailingExecuting); + + if (passingTerm == 0 || failingTerm == 0) { + return 0; + } + + return passingTerm / (passingTerm + failingTerm); + } + +}