/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.mcmaster.cas.matlab2smt;

import static org.junit.Assert.*;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
 *
 * @author matthew
 */
@RunWith(JUnit4.class)
public class VariableTest {
    @Test
    public void exerciseVariable() {
        String name = "Var";
        VariableType type = new RealVariableType();
        
        Variable var = new Variable(name, type);
        
        assertSame(name, var.name());
        assertSame(type, var.type());
        assertEquals(name, var.getCheckerOutput(null, new RealVariableType()));

        CheckerGenerator generator = new CVC3Generator();
        assertEquals(name+":REAL;", generator.GenerateVariableDecleration(var));

        generator = new SMTLIBGenerator();
        assertEquals("(declare-fun " +name+ " () Real)", generator.GenerateVariableDecleration(var));
    }

    // Verify handling of invalid type to getCheckerOutput
    @Test(expected=IllegalArgumentException.class)
    public void testInvalidOutputType() {
        String name = "Var";
        VariableType type = new BooleanVariableType();

        Variable var = new Variable(name, type);

        var.getCheckerOutput(null, new RealVariableType()); //Returns a boolean, so will fail.
    }
}
