2017-01-14 18:01:14 -05:00
|
|
|
package function.builtin.cons;
|
2017-01-06 17:10:00 -05:00
|
|
|
|
|
|
|
import static testutil.TestUtilities.*;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
public class LISTTester {
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithNoArguments() {
|
|
|
|
String input = "(list)";
|
|
|
|
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("nil"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithOneArgument() {
|
|
|
|
String input = "(list 1)";
|
|
|
|
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("(1)"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithTwoArguments() {
|
|
|
|
String input = "(list 2 3)";
|
|
|
|
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("(2 3)"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithManyArguments() {
|
|
|
|
String input = "(list 'm 'a 'n 'y 'a 'r 'g 's)";
|
|
|
|
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("(m a n y a r g s)"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithOneListArgument() {
|
|
|
|
String input = "(list '(1))";
|
|
|
|
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("((1))"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithManyListArguments() {
|
|
|
|
String input = "(list '(1) '(2 3) ())";
|
|
|
|
|
|
|
|
assertSExpressionsMatch(evaluateString(input), parseString("((1) (2 3) ())"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMakeList() {
|
|
|
|
assertSExpressionsMatch(LIST.makeList(parseString("22")), parseString("(22)"));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|