<commit_before>package nl.utwente.group10.haskell.type;

import nl.utwente.group10.haskell.exceptions.HaskellException;
import org.junit.Test;
import static org.junit.Assert.*;

public class FuncTTest {
    @Test
    public void toHaskellTypeTest() {
        ConstT integer = new ConstT("Integer");
        FuncT ft = new FuncT(integer, integer);
        assertEquals("(Integer -> Integer)", ft.toHaskellType());
    }

    @Test
    public void compatibleWithTest() {
        ConstT integer1 = new ConstT("Integer");
        ConstT integer2 = new ConstT("Integer");
        ConstT string = new ConstT("String");
        ConstT bool = new ConstT("Bool");
        TypeClass stringOrInteger = new TypeClass("StringOrInteger", new ConstT("Integer"), new ConstT("String"));
        FuncT ft = new FuncT(stringOrInteger, string);
        assertTrue(ft.compatibleWith(integer1));
        assertTrue(ft.compatibleWith(integer2));
        assertTrue(ft.compatibleWith(string));
        assertFalse(ft.compatibleWith(bool));
    }

    @Test
    public void getAppliedTypeTest() throws HaskellException {
        // Define some types
        ConstT integer = new ConstT("Integer");
        ConstT string = new ConstT("String");
        ConstT bool = new ConstT("Bool");

        // Define a type class
        TypeClass stringOrInteger = new TypeClass("StringOrInteger", new ConstT("Integer"), new ConstT("String"));

        // Define some variable types
        VarT varA = new VarT("a", stringOrInteger);

        // Define some function types
        FuncT ft1 = new FuncT(integer, integer);
        FuncT ft2 = new FuncT(bool, ft1, stringOrInteger, string);
        FuncT ft3 = new FuncT(stringOrInteger, stringOrInteger, string);
        FuncT ft4 = new FuncT(varA, varA, string);

        // Test function application
        assertEquals(ft2.getAppliedType(bool, ft1), new FuncT(stringOrInteger, string));

        // Test type class application
        assertEquals(ft3.getAppliedType(string, integer), string);

        // Test variable type application
        assertEquals(ft4.getAppliedType(string, string), string);

        // Test incorrect application of simple type
        try {
            ft2.getAppliedType(string);
            assertTrue(false);
        } catch (HaskellException e) {
            assertTrue(true);
        }

        // Test incorrect application of variable type
        try {
            ft4.getAppliedType(string, integer);
            assertTrue(false);
        } catch (HaskellException e) {
            assertTrue(true);
        }
    }
}<commit_msg>Fix tests for new FuncT.getAppliedType signature<commit_after>package nl.utwente.group10.haskell.type;

import nl.utwente.group10.haskell.exceptions.HaskellException;
import org.junit.Test;
import static org.junit.Assert.*;

public class FuncTTest {
    @Test
    public void toHaskellTypeTest() {
        ConstT integer = new ConstT("Integer");
        FuncT ft = new FuncT(integer, integer);
        assertEquals("(Integer -> Integer)", ft.toHaskellType());
    }

    @Test
    public void compatibleWithTest() {
        ConstT integer1 = new ConstT("Integer");
        ConstT integer2 = new ConstT("Integer");
        ConstT string = new ConstT("String");
        ConstT bool = new ConstT("Bool");
        TypeClass stringOrInteger = new TypeClass("StringOrInteger", new ConstT("Integer"), new ConstT("String"));
        FuncT ft = new FuncT(stringOrInteger, string);
        assertTrue(ft.compatibleWith(integer1));
        assertTrue(ft.compatibleWith(integer2));
        assertTrue(ft.compatibleWith(string));
        assertFalse(ft.compatibleWith(bool));
    }

    @Test
    public void getAppliedTypeTest() throws HaskellException {
        // Define some types
        ConstT integer = new ConstT("Integer");
        ConstT string = new ConstT("String");
        ConstT bool = new ConstT("Bool");

        // Define a type class
        TypeClass stringOrInteger = new TypeClass("StringOrInteger", new ConstT("Integer"), new ConstT("String"));

        // Define some variable types
        VarT varA = new VarT("a", stringOrInteger);

        // Define some function types
        FuncT ft1 = new FuncT(integer, integer);
        FuncT ft2 = new FuncT(bool, ft1, stringOrInteger, string);
        FuncT ft3 = new FuncT(stringOrInteger, stringOrInteger, string);
        FuncT ft4 = new FuncT(varA, varA, string);

        // Test function application
        assertEquals(ft2.getAppliedType(null, bool, ft1), new FuncT(stringOrInteger, string));

        // Test type class application
        assertEquals(ft3.getAppliedType(null, string, integer), string);

        // Test variable type application
        assertEquals(ft4.getAppliedType(null, string, string), string);

        // Test incorrect application of simple type
        try {
            ft2.getAppliedType(null, string);
            assertTrue(false);
        } catch (HaskellException e) {
            assertTrue(true);
        }

        // Test incorrect application of variable type
        try {
            ft4.getAppliedType(null, string, integer);
            assertTrue(false);
        } catch (HaskellException e) {
            assertTrue(true);
        }
    }
}
{'fraction_non_alphanumeric': 0.10612712349685055, 'fraction_numerical': 0.007253292613094102, 'mean_word_length': 2.664335664335664, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6100429', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1406, 'n_words': 378}