Skip to content

Commit 0b5d660

Browse files
committed
add test case for NL* bug
1 parent 8efdb67 commit 0b5d660

3 files changed

Lines changed: 80 additions & 1 deletion

File tree

algorithms/active/nlstar/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ limitations under the License.
7070
<groupId>de.learnlib.testsupport</groupId>
7171
<artifactId>learnlib-learner-it-support</artifactId>
7272
</dependency>
73+
<dependency>
74+
<groupId>de.learnlib</groupId>
75+
<artifactId>learnlib-equivalence-oracles</artifactId>
76+
<scope>test</scope>
77+
</dependency>
7378
<dependency>
7479
<groupId>de.learnlib</groupId>
7580
<artifactId>learnlib-membership-oracles</artifactId>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* Copyright (C) 2013-2020 TU Dortmund
2+
* This file is part of LearnLib, http://www.learnlib.de/.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package de.learnlib.algorithms.nlstar;
17+
18+
import de.learnlib.oracle.equivalence.SampleSetEQOracle;
19+
import de.learnlib.oracle.membership.SimulatorOracle;
20+
import de.learnlib.util.Experiment;
21+
import net.automatalib.automata.fsa.NFA;
22+
import net.automatalib.automata.fsa.impl.compact.CompactNFA;
23+
import net.automatalib.util.automata.Automata;
24+
import net.automatalib.util.automata.builders.AutomatonBuilders;
25+
import net.automatalib.util.automata.fsa.NFAs;
26+
import net.automatalib.words.Alphabet;
27+
import net.automatalib.words.Word;
28+
import net.automatalib.words.impl.Alphabets;
29+
import org.testng.Assert;
30+
import org.testng.annotations.Test;
31+
32+
public class NLStarTest {
33+
34+
/**
35+
* Test case for the bug described in issue <a href="https://github.com/LearnLib/learnlib/issues/70">#70</a>.
36+
*/
37+
@Test
38+
public void testIssue70() {
39+
final Alphabet<Character> alphabet = Alphabets.characters('a', 'b');
40+
41+
// @formatter:off
42+
final CompactNFA<Character> nfa = AutomatonBuilders.newNFA(alphabet)
43+
.withInitial("q0")
44+
.from("q0")
45+
.on('a').to("q1")
46+
.on('b').to("q2")
47+
.from("q1").on('b').to("q1")
48+
.from("q2").on('a').to("q2")
49+
.withAccepting("q1", "q2")
50+
.create();
51+
// @formatter:on
52+
53+
final SimulatorOracle<Character, Boolean> mqOracle = new SimulatorOracle<>(nfa);
54+
55+
final SampleSetEQOracle<Character, Boolean> eqOracle = new SampleSetEQOracle<>(false);
56+
eqOracle.addAll(mqOracle,
57+
Word.fromCharSequence("a"),
58+
Word.fromCharSequence("ab"),
59+
Word.fromCharSequence("aa"),
60+
Word.fromCharSequence("bab"));
61+
62+
final NLStarLearner<Character> learner = new NLStarLearner<>(alphabet, mqOracle);
63+
64+
final Experiment<NFA<?, Character>> experiment = new Experiment<>(learner, eqOracle, alphabet);
65+
experiment.run();
66+
final NFA<?, Character> hyp = experiment.getFinalHypothesis();
67+
68+
Assert.assertEquals(nfa.size(), hyp.size());
69+
Assert.assertTrue(Automata.testEquivalence(NFAs.determinize(nfa, false, false),
70+
NFAs.determinize(hyp, alphabet, false, false),
71+
alphabet));
72+
}
73+
}

algorithms/active/nlstar/src/test/java/de/learnlib/algorithms/nlstar/NLStarIT.java renamed to algorithms/active/nlstar/src/test/java/de/learnlib/algorithms/nlstar/it/NLStarIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package de.learnlib.algorithms.nlstar;
16+
package de.learnlib.algorithms.nlstar.it;
1717

18+
import de.learnlib.algorithms.nlstar.NLStarLearner;
1819
import de.learnlib.api.oracle.MembershipOracle.DFAMembershipOracle;
1920
import de.learnlib.testsupport.it.learner.AbstractDFALearnerIT;
2021
import de.learnlib.testsupport.it.learner.LearnerVariantList.DFALearnerVariantList;

0 commit comments

Comments
 (0)