Kirk Rader  1.0-SNAPSHOT
SentenceTest.java
Go to the documentation of this file.
1 /*
2  * Copyright 2016 Kirk Rader
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package us.rader.tt.formula.test;
18 
19 import static org.junit.Assert.assertEquals;
20 
21 import org.junit.Test;
22 
24 import us.rader.tt.formula.Formula;
25 import us.rader.tt.formula.Variable;
26 
27 /**
28  * Unit tests for us.rader.tt.formula.Sentence
29  */
30 public class SentenceTest {
31 
32  /**
33  * Unit test for {@link Expression#replaceVariable}.
34  *
35  * @throws Exception
36  * Thrown if an unexpected error occurs.
37  */
38  @Test
39  public void replaceVariableTest() throws Exception {
40 
41  final Formula sentence1 = Formula.parseFormula("P");
42  final Variable boundVariable = new Variable("x");
43  final Variable freeVariable = new Variable("a");
44  final Expression sentence2 = sentence1.replaceVariable(boundVariable, freeVariable);
45  assertEquals("P", sentence2.toString());
46 
47  }
48 
49 }
Demonstrate object-oriented design and implementation using a simple Java class library.
void replaceVariableTest()
Unit test for Expression#replaceVariable.
Unit tests for us.rader.tt.formula.Sentence.
A variable (lower-case alphabetic character) of the monadic predicate calculus.
Definition: Variable.java:27
static Formula parseFormula(final BufferedReader reader)
Parse the next Formula from the given buffered input stream.
Definition: Formula.java:112
Processor for well-formed formulas of the monadic predicate calculus.
Objects with unique Graphviz node names.
Definition: Expression.java:32
abstract Expression replaceVariable(Variable boundVariable, Expression factor)
Replace boundVariable with factor everywhere in this Expression.
A formula of the monadic predicate calculus.
Definition: Formula.java:51