2017-01-14 18:01:14 -05:00
|
|
|
package function.builtin.cons;
|
2017-01-06 17:10:00 -05:00
|
|
|
|
2017-03-02 09:54:23 -05:00
|
|
|
import static function.builtin.cons.LIST.makeList;
|
2017-01-06 17:10:00 -05:00
|
|
|
import static testutil.TestUtilities.*;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
2017-07-19 15:23:15 -04:00
|
|
|
import testutil.SymbolAndFunctionCleaner;
|
|
|
|
|
|
|
|
public class LISTTest extends SymbolAndFunctionCleaner {
|
2017-01-06 17:10:00 -05:00
|
|
|
|
|
|
|
@Test
|
2017-03-02 09:54:23 -05:00
|
|
|
public void listWithNoArguments() {
|
2017-01-06 17:10:00 -05:00
|
|
|
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
|
2017-03-02 09:54:23 -05:00
|
|
|
public void listWithOneArgument() {
|
2017-01-06 17:10:00 -05:00
|
|
|
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
|
2017-03-02 09:54:23 -05:00
|
|
|
public void listWithTwoArguments() {
|
2017-01-06 17:10:00 -05:00
|
|
|
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
|
2017-03-02 09:54:23 -05:00
|
|
|
public void listWithManyArguments() {
|
2017-01-06 17:10:00 -05:00
|
|
|
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
|
2017-03-02 09:54:23 -05:00
|
|
|
public void listWithOneListArgument() {
|
2017-01-06 17:10:00 -05:00
|
|
|
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
|
2017-03-02 09:54:23 -05:00
|
|
|
public void listWithManyListArguments() {
|
2017-01-06 17:10:00 -05:00
|
|
|
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
|
2017-03-02 09:54:23 -05:00
|
|
|
public void staticMakeList() {
|
|
|
|
assertSExpressionsMatch(parseString("(22)"), makeList(parseString("22")));
|
2017-01-06 17:10:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|