<commit_before><commit_msg>add test cases for kinduction<commit_after>package de.bmoth.modelchecker.kinduction;

import de.bmoth.TestParser;
import de.bmoth.modelchecker.kind.KinductionModelChecker;
import de.bmoth.modelchecker.kind.KinductionModelCheckingResult;
import org.junit.Test;

import static de.bmoth.modelchecker.kind.KinductionModelCheckingResult.Type.COUNTER_EXAMPLE_FOUND;
import static de.bmoth.modelchecker.kind.KinductionModelCheckingResult.Type.EXCEEDED_MAX_STEPS;
import static org.junit.Assert.assertEquals;

public class KInductionModelCheckerTest extends TestParser {

    @Test
    public void test1() {
        String machine = "MACHINE infInc\n" +
            "VARIABLES c\n" +
            "INVARIANT c : NATURAL\n" +
            "INITIALISATION c := 0\n" +
            "OPERATIONS\n" +
            "\tinc = BEGIN c := c + 1 END\n" +
            "END\n";

        KinductionModelCheckingResult result = new KinductionModelChecker(parseMachine(machine), 20).check();
        assertEquals(EXCEEDED_MAX_STEPS, result.getType());
    }

    @Test
    public void test2() {
        String machine = "MACHINE ebr\n" +
            "VARIABLES c, b\n" +
            "INVARIANT c : INTEGER &\n" +
            "\tb = TRUE\n" +
            "INITIALISATION c := 0 || b := TRUE\n" +
            "OPERATIONS\n" +
            "\tinc = ANY x WHERE x:INTEGER THEN c := c + x END;\n" +
            "\terr = PRE c > 99999 THEN b := FALSE END\n" +
            "END\n";

        KinductionModelCheckingResult result = new KinductionModelChecker(parseMachine(machine), 20).check();
        assertEquals(COUNTER_EXAMPLE_FOUND, result.getType());
        assertEquals("{b=false, c=100000}", result.getLastState().toString());
    }
}
{'fraction_non_alphanumeric': 0.11771494518176573, 'fraction_numerical': 0.01154068090017311, 'mean_word_length': 2.7532467532467533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2146811', 'n_tokens_mistral': 576, 'n_tokens_neox': 548, 'n_words': 111}