Skip to content

Commit

Permalink
cleanup passive integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtf90 committed Oct 22, 2023
1 parent f4f47b4 commit 54871c3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import de.learnlib.api.query.DefaultQuery;
import de.learnlib.example.DefaultPassiveLearningExample.DefaultDFAPassiveLearningExample;
import de.learnlib.example.LearningExample;
import de.learnlib.example.LearningExample.DFALearningExample;
import de.learnlib.example.LearningExamples;
import de.learnlib.example.PassiveLearningExample.DFAPassiveLearningExample;
import de.learnlib.testsupport.it.learner.PassiveLearnerVariantListImpl.DFAPassiveLearnerVariantListImpl;
Expand All @@ -43,17 +43,17 @@ public abstract class AbstractDFAPassiveLearnerIT {

@Factory
public Object[] createExampleITCases() {
final List<LearningExample.DFALearningExample<?>> examples = LearningExamples.createDFAExamples();
final List<DFALearningExample<?>> examples = LearningExamples.createDFAExamples();
final List<PassiveLearnerVariantITCase<?, ?, ?>> result = new ArrayList<>(examples.size());

for (LearningExample.DFALearningExample<?> example : examples) {
for (DFALearningExample<?> example : examples) {
result.addAll(createAllVariantsITCase(example));
}

return result.toArray();
}

private <I> List<PassiveLearnerVariantITCase<I, Boolean, DFA<?, I>>> createAllVariantsITCase(LearningExample.DFALearningExample<I> example) {
private <I> List<PassiveLearnerVariantITCase<I, Boolean, DFA<?, I>>> createAllVariantsITCase(DFALearningExample<I> example) {

final Alphabet<I> alphabet = example.getAlphabet();
final DFA<?, I> reference = example.getReferenceAutomaton();
Expand All @@ -63,7 +63,7 @@ private <I> List<PassiveLearnerVariantITCase<I, Boolean, DFA<?, I>>> createAllVa
final DFAPassiveLearnerVariantListImpl<I> variants = new DFAPassiveLearnerVariantListImpl<>();
addLearnerVariants(alphabet, variants);

final DFAPassiveLearningExample<I> effectiveExample = new DefaultDFAPassiveLearningExample<>(queries, alphabet);
final DFAPassiveLearningExample<I> effectiveExample = new DefaultDFAPassiveLearningExample<>(queries);

return LearnerITUtil.createPassiveExampleITCases(effectiveExample, variants);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import de.learnlib.api.query.DefaultQuery;
import de.learnlib.example.DefaultPassiveLearningExample.DefaultMealyPassiveLearningExample;
import de.learnlib.example.LearningExample;
import de.learnlib.example.LearningExample.MealyLearningExample;
import de.learnlib.example.LearningExamples;
import de.learnlib.example.PassiveLearningExample.MealyPassiveLearningExample;
import de.learnlib.testsupport.it.learner.PassiveLearnerVariantListImpl.MealyLearnerVariantListImpl;
Expand All @@ -40,18 +40,18 @@ public abstract class AbstractMealyPassiveLearnerIT {

@Factory
public Object[] createExampleITCases() {
final List<LearningExample.MealyLearningExample<?, ?>> examples = LearningExamples.createMealyExamples();
final List<MealyLearningExample<?, ?>> examples = LearningExamples.createMealyExamples();
final List<PassiveLearnerVariantITCase<?, ?, ?>> result = new ArrayList<>(examples.size());

for (LearningExample.MealyLearningExample<?, ?> example : examples) {
for (MealyLearningExample<?, ?> example : examples) {
result.addAll(createAllVariantsITCase(example));
}

return result.toArray();
}

private <I, O> List<PassiveLearnerVariantITCase<I, Word<O>, MealyMachine<?, I, ?, O>>> createAllVariantsITCase(
LearningExample.MealyLearningExample<I, O> example) {
MealyLearningExample<I, O> example) {

final Alphabet<I> alphabet = example.getAlphabet();
final MealyMachine<?, I, ?, O> reference = example.getReferenceAutomaton();
Expand All @@ -61,8 +61,7 @@ public Object[] createExampleITCases() {
final MealyLearnerVariantListImpl<I, O> variants = new MealyLearnerVariantListImpl<>();
addLearnerVariants(alphabet, variants);

final MealyPassiveLearningExample<I, O> effectiveExample =
new DefaultMealyPassiveLearningExample<>(queries, alphabet);
final MealyPassiveLearningExample<I, O> effectiveExample = new DefaultMealyPassiveLearningExample<>(queries);

return LearnerITUtil.createPassiveExampleITCases(effectiveExample, variants);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public Object[] createExampleITCases() {
final SSTLearnerVariantListImpl<I, O> variants = new SSTLearnerVariantListImpl<>();
addLearnerVariants(alphabet, variants);

final SSTPassiveLearningExample<I, O> effectiveExample =
new DefaultSSTPassiveLearningExample<>(queries, alphabet);
final SSTPassiveLearningExample<I, O> effectiveExample = new DefaultSSTPassiveLearningExample<>(queries);

return LearnerITUtil.createPassiveExampleITCases(effectiveExample, variants);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Collection;

import de.learnlib.api.query.DefaultQuery;
import net.automatalib.alphabet.Alphabet;
import net.automatalib.word.Word;

/**
Expand All @@ -35,44 +34,36 @@ public class DefaultPassiveLearningExample<I, D> implements PassiveLearningExamp

private final Collection<DefaultQuery<I, D>> samples;

private final Alphabet<I> alphabet;

public DefaultPassiveLearningExample(Collection<DefaultQuery<I, D>> samples, Alphabet<I> alphabet) {
public DefaultPassiveLearningExample(Collection<DefaultQuery<I, D>> samples) {
this.samples = samples;
this.alphabet = alphabet;
}

@Override
public Collection<DefaultQuery<I, D>> getSamples() {
return this.samples;
}

@Override
public Alphabet<I> getAlphabet() {
return this.alphabet;
}

public static class DefaultDFAPassiveLearningExample<I> extends DefaultPassiveLearningExample<I, Boolean>
implements DFAPassiveLearningExample<I> {

public DefaultDFAPassiveLearningExample(Collection<DefaultQuery<I, Boolean>> samples, Alphabet<I> alphabet) {
super(samples, alphabet);
public DefaultDFAPassiveLearningExample(Collection<DefaultQuery<I, Boolean>> samples) {
super(samples);
}
}

public static class DefaultMealyPassiveLearningExample<I, O> extends DefaultPassiveLearningExample<I, Word<O>>
implements MealyPassiveLearningExample<I, O> {

public DefaultMealyPassiveLearningExample(Collection<DefaultQuery<I, Word<O>>> samples, Alphabet<I> alphabet) {
super(samples, alphabet);
public DefaultMealyPassiveLearningExample(Collection<DefaultQuery<I, Word<O>>> samples) {
super(samples);
}
}

public static class DefaultSSTPassiveLearningExample<I, O> extends DefaultPassiveLearningExample<I, Word<O>>
implements SSTPassiveLearningExample<I, O> {

public DefaultSSTPassiveLearningExample(Collection<DefaultQuery<I, Word<O>>> samples, Alphabet<I> alphabet) {
super(samples, alphabet);
public DefaultSSTPassiveLearningExample(Collection<DefaultQuery<I, Word<O>>> samples) {
super(samples);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
import java.util.Collection;

import de.learnlib.api.query.DefaultQuery;
import net.automatalib.alphabet.Alphabet;
import net.automatalib.word.Word;

public interface PassiveLearningExample<I, D> {

Collection<DefaultQuery<I, D>> getSamples();

Alphabet<I> getAlphabet();

interface DFAPassiveLearningExample<I> extends PassiveLearningExample<I, Boolean> {}

interface MealyPassiveLearningExample<I, O> extends PassiveLearningExample<I, Word<O>> {}
Expand Down

0 comments on commit 54871c3

Please sign in to comment.