transcendental-lisp/test/function/builtin/cons/LISTTest.java

62 lines
1.6 KiB
Java

package function.builtin.cons;
import static function.builtin.cons.LIST.makeList;
import static testutil.TestUtilities.assertSExpressionsMatch;
import static testutil.TestUtilities.evaluateString;
import static testutil.TestUtilities.parseString;
import org.junit.Test;
import testutil.SymbolAndFunctionCleaner;
public class LISTTest extends SymbolAndFunctionCleaner {
@Test
public void listWithNoArguments() {
String input = "(list)";
assertSExpressionsMatch(parseString("nil"), evaluateString(input));
}
@Test
public void listWithOneArgument() {
String input = "(list 1)";
assertSExpressionsMatch(parseString("(1)"), evaluateString(input));
}
@Test
public void listWithTwoArguments() {
String input = "(list 2 3)";
assertSExpressionsMatch(parseString("(2 3)"), evaluateString(input));
}
@Test
public void listWithManyArguments() {
String input = "(list 'm 'a 'n 'y 'a 'r 'g 's)";
assertSExpressionsMatch(parseString("(m a n y a r g s)"), evaluateString(input));
}
@Test
public void listWithOneListArgument() {
String input = "(list '(1))";
assertSExpressionsMatch(parseString("((1))"), evaluateString(input));
}
@Test
public void listWithManyListArguments() {
String input = "(list '(1) '(2 3) ())";
assertSExpressionsMatch(parseString("((1) (2 3) ())"), evaluateString(input));
}
@Test
public void staticMakeList() {
assertSExpressionsMatch(parseString("(22)"), makeList(parseString("22")));
}
}