forked from john-bai/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterpreterTest.java
More file actions
42 lines (32 loc) · 810 Bytes
/
Copy pathInterpreterTest.java
File metadata and controls
42 lines (32 loc) · 810 Bytes
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
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package designpatterns;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author jtherrell
*/
public class InterpreterTest {
public InterpreterTest() {
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
public void hello() {
BooleanExp expression;
Context context = new Context();
VariableExp x = new VariableExp("X");
VariableExp y = new VariableExp("Y");
expression = new OrExp(
new AndExp(new Constant(true), x),
new AndExp(y, new NotExp(x)));
context.assign(x, false);
context.assign(y, true);
boolean result = expression.evaluate(context);
assertTrue(result);
}
}