package testutil;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static sexpression.Nil.NIL;
import static sexpression.Symbol.T;

import sexpression.SExpression;

public final class TypeAssertions {

    public static void assertList(SExpression sExpression) {
        assertThat(sExpression.isAtom(), is(false));
        assertThat(sExpression.isCons(), is(true));
        assertThat(sExpression.isFunction(), is(false));
        assertThat(sExpression.isList(), is(true));
        assertThat(sExpression.isNull(), is(false));
        assertThat(sExpression.isNumber(), is(false));
        assertThat(sExpression.isString(), is(false));
        assertThat(sExpression.isSymbol(), is(false));
        assertThat(sExpression.isBackquote(), is(false));
        assertThat(sExpression.isComma(), is(false));
        assertThat(sExpression.isAtSign(), is(false));
    }

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

        assertThat(sExpression.isAtom(), is(true));
        assertThat(sExpression.isCons(), is(false));
        assertThat(sExpression.isFunction(), is(false));
        assertThat(sExpression.isList(), is(true));
        assertThat(sExpression.isNull(), is(true));
        assertThat(sExpression.isNumber(), is(false));
        assertThat(sExpression.isString(), is(false));
        assertThat(sExpression.isSymbol(), is(true));
        assertThat(sExpression.isBackquote(), is(false));
        assertThat(sExpression.isComma(), is(false));
        assertThat(sExpression.isAtSign(), is(false));
    }

    public static void assertNumber(SExpression sExpression) {
        assertThat(sExpression.isAtom(), is(true));
        assertThat(sExpression.isCons(), is(false));
        assertThat(sExpression.isFunction(), is(false));
        assertThat(sExpression.isList(), is(false));
        assertThat(sExpression.isNull(), is(false));
        assertThat(sExpression.isNumber(), is(true));
        assertThat(sExpression.isString(), is(false));
        assertThat(sExpression.isSymbol(), is(false));
        assertThat(sExpression.isBackquote(), is(false));
        assertThat(sExpression.isComma(), is(false));
        assertThat(sExpression.isAtSign(), is(false));
    }

    public static void assertString(SExpression sExpression) {
        assertThat(sExpression.isAtom(), is(true));
        assertThat(sExpression.isCons(), is(false));
        assertThat(sExpression.isFunction(), is(false));
        assertThat(sExpression.isList(), is(false));
        assertThat(sExpression.isNull(), is(false));
        assertThat(sExpression.isNumber(), is(false));
        assertThat(sExpression.isString(), is(true));
        assertThat(sExpression.isSymbol(), is(false));
        assertThat(sExpression.isBackquote(), is(false));
        assertThat(sExpression.isComma(), is(false));
        assertThat(sExpression.isAtSign(), is(false));
    }

    public static void assertSymbol(SExpression sExpression) {
        assertThat(sExpression.isAtom(), is(true));
        assertThat(sExpression.isCons(), is(false));
        assertThat(sExpression.isFunction(), is(false));
        assertThat(sExpression.isList(), is(false));
        assertThat(sExpression.isNull(), is(false));
        assertThat(sExpression.isNumber(), is(false));
        assertThat(sExpression.isString(), is(false));
        assertThat(sExpression.isSymbol(), is(true));
        assertThat(sExpression.isBackquote(), is(false));
        assertThat(sExpression.isComma(), is(false));
        assertThat(sExpression.isAtSign(), is(false));
    }

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

    public static void assertBackTickExpression(SExpression sExpression) {
        assertThat(sExpression.isAtom(), is(false));
        assertThat(sExpression.isCons(), is(false));
        assertThat(sExpression.isFunction(), is(false));
        assertThat(sExpression.isList(), is(false));
        assertThat(sExpression.isNull(), is(false));
        assertThat(sExpression.isNumber(), is(false));
        assertThat(sExpression.isString(), is(false));
        assertThat(sExpression.isSymbol(), is(false));
        assertThat(sExpression.isBackquote(), is(true));
        assertThat(sExpression.isComma(), is(false));
        assertThat(sExpression.isAtSign(), is(false));
    }

    public static void assertCommaExpression(SExpression sExpression) {
        assertThat(sExpression.isAtom(), is(false));
        assertThat(sExpression.isCons(), is(false));
        assertThat(sExpression.isFunction(), is(false));
        assertThat(sExpression.isList(), is(false));
        assertThat(sExpression.isNull(), is(false));
        assertThat(sExpression.isNumber(), is(false));
        assertThat(sExpression.isString(), is(false));
        assertThat(sExpression.isSymbol(), is(false));
        assertThat(sExpression.isBackquote(), is(false));
        assertThat(sExpression.isComma(), is(true));
        assertThat(sExpression.isAtSign(), is(false));
    }

    public static void assertAtSignExpression(SExpression sExpression) {
        assertThat(sExpression.isAtom(), is(false));
        assertThat(sExpression.isCons(), is(false));
        assertThat(sExpression.isFunction(), is(false));
        assertThat(sExpression.isList(), is(false));
        assertThat(sExpression.isNull(), is(false));
        assertThat(sExpression.isNumber(), is(false));
        assertThat(sExpression.isString(), is(false));
        assertThat(sExpression.isSymbol(), is(false));
        assertThat(sExpression.isBackquote(), is(false));
        assertThat(sExpression.isComma(), is(false));
        assertThat(sExpression.isAtSign(), is(true));
    }

}
