Skip to content

Commit

Permalink
core: added tests for #98
Browse files Browse the repository at this point in the history
  • Loading branch information
matze-dd authored Nov 6, 2020
1 parent b831814 commit 27ce691
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
45 changes: 41 additions & 4 deletions tests/test_packages/test_babel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,59 @@
preamble = '\\usepackage{babel}\n'

def get_plain(latex):
parms = parameters.Parameters()
parms = parameters.Parameters('en')
parms.multi_language = True
p = parser.Parser(parms)
plain, nums = utils.get_txt_pos(p.parse(preamble + latex))
return plain


data_test_macros_latex = [
data_test_macros_python = [

(r'A\foreignlanguage{russian}{T}B', 'ATB'),
(r'A\foreignlanguage[opt]{russian}{T}B', 'ATB'),
(r"""
A
\foreignlanguage{german}{ }
B
""", r"""
A
B
"""),
(r"""
\usepackage{amsthm}
\begin{proof}
\foreignlanguage{german}{\begin{proof}}
""", r"""
Proof.
Beweis.
"""),
(r'A\selectlanguage{russian}B', 'AB'),
(r"""
A
\selectlanguage{english}
B
""", r"""
A
B
"""),
(r"""
\usepackage{amsthm}
\selectlanguage{german}
\begin{proof}
""", r"""
Beweis.
"""),

]

@pytest.mark.parametrize('latex,plain_expected', data_test_macros_latex)
def test_macros_latex(latex, plain_expected):
@pytest.mark.parametrize('latex,plain_expected', data_test_macros_python)
def test_macros_python(latex, plain_expected):
plain = get_plain(latex)
assert plain == plain_expected

4 changes: 2 additions & 2 deletions tests/test_packages/test_latex_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def test_macros_latex(latex, plain_expected):
(r'A\hspace*{1em}B', 'A B'),
(r'A\newcommand{\xxx}{X}B', 'AB'),
(r'A\newcommand*{\xxx}[1][x]{X}B', 'AB'),
(r'A\newtheorem{xxx}{XXX} B', 'AB'),
(r'A\newtheorem{xxx}[c]{XXX}[d] B', 'A B'),
(r'A\newtheorem{xxx}{XYZ} B', 'AB'),
(r'A\newtheorem{xxx}[c]{XYZ}[d] B', 'A B'),
(r'\part[hi]{ho}', 'ho.'),
(r'\part*{ho}', 'ho.'),
(r'\part{ho?}', 'ho?'),
Expand Down

0 comments on commit 27ce691

Please sign in to comment.