Commit daf5a559 authored by Matthew Dawson's avatar Matthew Dawson
Browse files

Add a literal class.

Add a literal to hold literal numbers.  Currently forced to only be Reals.


git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/branches/TableTool_javization@9620 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent 34e99ffe
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.mcmaster.cas.matlab2smt;

/**
 *
 * @author matthew
 */
public final class MatlabLiteral implements MatlabExpression {

    public MatlabLiteral(String value) {
        m_value = value;
    }
    
    @Override
    public VariableType type() {
        return m_type;
    }

    @Override
    public String getCVC3Output() {
        return m_value;
    }
    
    final String m_value;
    final VariableType m_type = new RealVariableType();
}
+44 −0
Original line number Diff line number Diff line
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.mcmaster.cas.matlab2smt;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
 *
 * @author matthew
 */
@RunWith(JUnit4.class)
public class MatlabLiteralTest {
    /**
     * Test of type method, of class MatlabLiteral.
     */
    @Test
    public void testType() {
        MatlabLiteral instance = new MatlabLiteral(null);
        VariableType expResult = new RealVariableType();
        VariableType result = instance.type();
        assertEquals(expResult, result);
        assertEquals(result, instance.type());
    }

    /**
     * Test of getCVC3Output method, of class MatlabLiteral.
     */
    @Test
    public void testGetCVC3Output() {
        MatlabLiteral instance = new MatlabLiteral("5");
        String expResult = "5";
        String result = instance.getCVC3Output();
        assertEquals(expResult, result);
    }
}