-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Deric-W/abc
add predefined variables
- Loading branch information
Showing
7 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ Package terms | |
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
terms/abc | ||
terms/logic | ||
terms/arithmetic | ||
terms/pairs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Module abc | ||
========== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
.. automodule:: lambda_calculus.terms.abc | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
"Variable", | ||
"Abstraction", | ||
"Application", | ||
"abc", | ||
"arithmetic", | ||
"logic", | ||
"pairs", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/python3 | ||
|
||
"""Predefined Variables for all ASCII letters""" | ||
|
||
from string import ascii_letters | ||
from . import Variable | ||
|
||
__all__ = tuple(ascii_letters) | ||
|
||
# better IDE autocompletion | ||
a, b, c, d, e, f, g, h, i, j = map(Variable, "abcdefghij") | ||
k, l, m, n, o, p, q, r, s, t = map(Variable, "klmnopqrst") | ||
u, v, w, x, y, z = map(Variable, "uvwxyz") | ||
|
||
A, B, C, D, E, F, G, H, I, J = map(Variable, "ABCDEFGHIJ") | ||
K, L, M, N, O, P, Q, R, S, T = map(Variable, "KLMNOPQRST") | ||
U, V, W, X, Y, Z = map(Variable, "UVWXYZ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/python3 | ||
|
||
"""Tests for the predefined variables""" | ||
|
||
from unittest import TestCase | ||
from string import ascii_letters | ||
from lambda_calculus.terms import Variable, abc | ||
|
||
|
||
class PredefinedVariablesTest(TestCase): | ||
"""Tests for the predefined variables""" | ||
|
||
def test_complete(self) -> None: | ||
"""Check whether all letters exist""" | ||
self.assertEqual(tuple(ascii_letters), abc.__all__) | ||
for letter in ascii_letters: | ||
self.assertTrue(hasattr(abc, letter)) | ||
|
||
def test_variables(self) -> None: | ||
"""Test the predefined variables""" | ||
for letter in ascii_letters: | ||
variable = getattr(abc, letter) | ||
self.assertIsInstance(variable, Variable) | ||
self.assertEqual(variable.name, letter) |