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)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("nil"), evaluateString(input));
|
2017-01-06 17:10:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithOneArgument() {
|
|
|
|
String input = "(list 1)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("(1)"), evaluateString(input));
|
2017-01-06 17:10:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithTwoArguments() {
|
|
|
|
String input = "(list 2 3)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("(2 3)"), evaluateString(input));
|
2017-01-06 17:10:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithManyArguments() {
|
|
|
|
String input = "(list 'm 'a 'n 'y 'a 'r 'g 's)";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("(m a n y a r g s)"), evaluateString(input));
|
2017-01-06 17:10:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithOneListArgument() {
|
|
|
|
String input = "(list '(1))";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("((1))"), evaluateString(input));
|
2017-01-06 17:10:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testListWithManyListArguments() {
|
|
|
|
String input = "(list '(1) '(2 3) ())";
|
|
|
|
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("((1) (2 3) ())"), evaluateString(input));
|
2017-01-06 17:10:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMakeList() {
|
2017-01-27 10:51:25 -05:00
|
|
|
assertSExpressionsMatch(parseString("(22)"), LIST.makeList(parseString("22")));
|
2017-01-06 17:10:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|