-
Notifications
You must be signed in to change notification settings - Fork 1
/
BudInterpreterTest.java
80 lines (65 loc) · 2.58 KB
/
BudInterpreterTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package me.predatorray.bud.lisp;
import me.predatorray.bud.lisp.lang.BudCharacter;
import me.predatorray.bud.lisp.lang.BudList;
import me.predatorray.bud.lisp.lang.BudNumber;
import me.predatorray.bud.lisp.lang.BudObject;
import me.predatorray.bud.lisp.lang.BudString;
import me.predatorray.bud.lisp.lang.BudType;
import me.predatorray.bud.lisp.lang.Symbol;
import me.predatorray.bud.lisp.test.AbstractInterpreterTest;
import org.junit.Test;
import java.math.BigDecimal;
import java.util.Arrays;
public class BudInterpreterTest extends AbstractInterpreterTest {
@Test
public void testNumber1() throws Exception {
assertInterpretCorrectly(new BudNumber(BigDecimal.ONE), "number1.bud");
}
@Test
public void testCharacterNewline() throws Exception {
assertInterpretCorrectly(new BudCharacter('\n'), "character-newline.bud");
}
@Test
public void testHelloWorld() throws Exception {
assertInterpretCorrectly(new BudString("Hello, world!"), "hello-world.bud");
}
@Test
public void testOnePlusOne() throws Exception {
assertInterpretCorrectly(new BudNumber(new BigDecimal(2)), "one-plus-one.bud");
}
@Test
public void testSumOneToFive() throws Exception {
assertInterpretCorrectly(new BudNumber(new BigDecimal(15)), "sum-one-to-five.bud");
}
@Test
public void testLastSymbol() throws Exception {
assertInterpretCorrectly(new Symbol("foobar"), "last-symbol.bud");
}
@Test
public void testLambdaAbs() throws Exception {
assertInterpretCorrectly(new BudNumber(new BigDecimal(100)), "abs.bud");
}
@Test
public void testNegNumericFunction() throws Exception {
assertInterpretCorrectly(new BudNumber(new BigDecimal(-15)), "neg-function.bud");
}
@Test
public void testFactorial() throws Exception {
assertInterpretCorrectly(new BudNumber(new BigDecimal(120)), "factorial.bud");
}
@Test
public void testSumOfNumberList() throws Exception {
assertInterpretCorrectly(new BudNumber(new BigDecimal(15)), "sum-of-number-list.bud");
}
@Test
public void testDoubleNumberList() throws Exception {
assertInterpretCorrectly(new BudList(BudType.NUMBER, Arrays.<BudObject>asList(
new BudNumber(new BigDecimal(2)),
new BudNumber(new BigDecimal(4)),
new BudNumber(new BigDecimal(6)))), "double-number-list.bud");
}
@Test
public void testFibonacci() throws Exception {
assertInterpretCorrectly(new BudNumber(new BigDecimal("573147844013817084101")), "fibonacci.bud");
}
}