package testutil;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static sexpression.Nil.NIL;
import static sexpression.Symbol.T;

import sexpression.SExpression;

public final class TypeAssertions {

    public static void assertList(SExpression sExpression) {
        assertFalse(sExpression.isAtom());
        assertTrue(sExpression.isCons());
        assertFalse(sExpression.isFunction());
        assertTrue(sExpression.isList());
        assertFalse(sExpression.isNull());
        assertFalse(sExpression.isNumber());
        assertFalse(sExpression.isString());
        assertFalse(sExpression.isSymbol());
        assertFalse(sExpression.isBackquote());
        assertFalse(sExpression.isComma());
        assertFalse(sExpression.isAtSign());
    }

    public static void assertNil(SExpression sExpression) {
        assertEquals(NIL, sExpression);

        assertTrue(sExpression.isAtom());
        assertFalse(sExpression.isCons());
        assertFalse(sExpression.isFunction());
        assertTrue(sExpression.isList());
        assertTrue(sExpression.isNull());
        assertFalse(sExpression.isNumber());
        assertFalse(sExpression.isString());
        assertTrue(sExpression.isSymbol());
        assertFalse(sExpression.isBackquote());
        assertFalse(sExpression.isComma());
        assertFalse(sExpression.isAtSign());
    }

    public static void assertNumber(SExpression sExpression) {
        assertTrue(sExpression.isAtom());
        assertFalse(sExpression.isCons());
        assertFalse(sExpression.isFunction());
        assertFalse(sExpression.isList());
        assertFalse(sExpression.isNull());
        assertTrue(sExpression.isNumber());
        assertFalse(sExpression.isString());
        assertFalse(sExpression.isSymbol());
        assertFalse(sExpression.isBackquote());
        assertFalse(sExpression.isComma());
        assertFalse(sExpression.isAtSign());
    }

    public static void assertString(SExpression sExpression) {
        assertTrue(sExpression.isAtom());
        assertFalse(sExpression.isCons());
        assertFalse(sExpression.isFunction());
        assertFalse(sExpression.isList());
        assertFalse(sExpression.isNull());
        assertFalse(sExpression.isNumber());
        assertTrue(sExpression.isString());
        assertFalse(sExpression.isSymbol());
        assertFalse(sExpression.isBackquote());
        assertFalse(sExpression.isComma());
        assertFalse(sExpression.isAtSign());
    }

    public static void assertSymbol(SExpression sExpression) {
        assertTrue(sExpression.isAtom());
        assertFalse(sExpression.isCons());
        assertFalse(sExpression.isFunction());
        assertFalse(sExpression.isList());
        assertFalse(sExpression.isNull());
        assertFalse(sExpression.isNumber());
        assertFalse(sExpression.isString());
        assertTrue(sExpression.isSymbol());
        assertFalse(sExpression.isBackquote());
        assertFalse(sExpression.isComma());
        assertFalse(sExpression.isAtSign());
    }

    public static void assertT(SExpression sExpression) {
        assertEquals(T, sExpression);
    }

    public static void assertBackTickExpression(SExpression sExpression) {
        assertFalse(sExpression.isAtom());
        assertFalse(sExpression.isCons());
        assertFalse(sExpression.isFunction());
        assertFalse(sExpression.isList());
        assertFalse(sExpression.isNull());
        assertFalse(sExpression.isNumber());
        assertFalse(sExpression.isString());
        assertFalse(sExpression.isSymbol());
        assertTrue(sExpression.isBackquote());
        assertFalse(sExpression.isComma());
        assertFalse(sExpression.isAtSign());
    }

    public static void assertCommaExpression(SExpression sExpression) {
        assertFalse(sExpression.isAtom());
        assertFalse(sExpression.isCons());
        assertFalse(sExpression.isFunction());
        assertFalse(sExpression.isList());
        assertFalse(sExpression.isNull());
        assertFalse(sExpression.isNumber());
        assertFalse(sExpression.isString());
        assertFalse(sExpression.isSymbol());
        assertFalse(sExpression.isBackquote());
        assertTrue(sExpression.isComma());
        assertFalse(sExpression.isAtSign());
    }

    public static void assertAtSignExpression(SExpression sExpression) {
        assertFalse(sExpression.isAtom());
        assertFalse(sExpression.isCons());
        assertFalse(sExpression.isFunction());
        assertFalse(sExpression.isList());
        assertFalse(sExpression.isNull());
        assertFalse(sExpression.isNumber());
        assertFalse(sExpression.isString());
        assertFalse(sExpression.isSymbol());
        assertFalse(sExpression.isBackquote());
        assertFalse(sExpression.isComma());
        assertTrue(sExpression.isAtSign());
    }

}
