예제 #1
0
 def test_20(self, x: Variable, env: Environment) -> None:
     try:
         assert IsEqual(Logarithm(x, x), Integer(1)).evaluate(env)
     except EvaluationError:
         pass
예제 #2
0
 def test_18(self, x: Variable, env: Environment) -> None:
     assert IsEqual(x**0, Integer(1)).evaluate(env)
예제 #3
0
 def test_19(self, x: Variable, y: Variable, env: Environment) -> None:
     try:
         assert IsEqual((x + y)**2, x**2 + y**2 + 2 * x * y).evaluate(env)
     except EvaluationError:
         pass
예제 #4
0
 def test_2(self, x: Variable, y: Variable, z: Variable,
            env: Environment) -> None:
     assert IsEqual((x + y) + z, x + (y + z)).evaluate(env)
예제 #5
0
 def test_17(self, x: Variable, env: Environment) -> None:
     assert (IsEqual(x**1, x) | IsEqual(x, Integer(0))).evaluate(env)
예제 #6
0
 def test_or(self, x: Variable, y: Variable, env: Environment) -> None:
     assert IsEqual(Or(x, y), Nand(Not(x), Not(y))).evaluate(env)
예제 #7
0
 def test_4(self, x: Variable, env: Environment) -> None:
     assert IsEqual(Negate(Negate(x)), x).evaluate(env)
예제 #8
0
 def test_10(self, x: Variable, y: Variable, z: Variable,
             env: Environment) -> None:
     try:
         assert IsEqual(x * (y + z), x * y + x * z).evaluate(env)
     except EvaluationError:
         pass
예제 #9
0
 def test_13(self, x: Variable, env: Environment) -> None:
     if x.evaluate(env) != 0:
         assert IsEqual(x * Invert(x), Integer(1)).evaluate(env)
예제 #10
0
 def test_8(self, x: Variable, y: Variable, env: Environment) -> None:
     assert IsEqual(x * y, y * x).evaluate(env)
예제 #11
0
 def test_9(self, x: Variable, y: Variable, z: Variable,
            env: Environment) -> None:
     try:
         assert IsEqual((x * y) * z, x * (y * z)).evaluate(env)
     except EvaluationError:
         pass
예제 #12
0
 def test_7(self, x: Variable, env: Environment) -> None:
     assert IsEqual(x + x, x * 2).evaluate(env)
예제 #13
0
 def test_5(self, x: Variable, y: Variable, env: Environment) -> None:
     assert IsEqual(x + -y, x - y).evaluate(env)
예제 #14
0
 def test_4(self, x: Variable, env: Environment) -> None:
     assert IsEqual(x + -x, Integer(0)).evaluate(env)
예제 #15
0
 def test_not(self, x: Variable, env: Environment) -> None:
     assert IsEqual(Not(x), Nand(x, x)).evaluate(env)
예제 #16
0
 def test_14(self, x: Variable, y: Variable, env: Environment) -> None:
     try:
         if y.evaluate(env) != 0:
             assert IsEqual(x * Invert(y), x / y).evaluate(env)
     except EvaluationError:
         pass
예제 #17
0
 def test_and(self, x: Variable, y: Variable, env: Environment) -> None:
     assert IsEqual(And(x, y), Not(Nand(x, y))).evaluate(env)
예제 #18
0
 def test_15(self, x: Variable, env: Environment) -> None:
     assert IsEqual(x / 1, x).evaluate(env)
예제 #19
0
 def test_xor(self, x: Variable, y: Variable, env: Environment) -> None:
     assert IsEqual(Xor(x, y), And(Or(x, y), Nand(x, y))).evaluate(env)
예제 #20
0
 def test_16(self, x: Variable, env: Environment) -> None:
     try:
         assert IsEqual(x * x, x**2).evaluate(env)
     except EvaluationError:
         pass
예제 #21
0
 def test_5(self, x: Variable, env: Environment) -> None:
     assert IsEqual(Absolute(Negate(x)), Absolute(x)).evaluate(env)
예제 #22
0
def test_equality(val1: Node, val2: Node) -> None:
    assert IsEqual(val1,
                   val2).evaluate() == (val1.evaluate() == val2.evaluate())