File: test_paren.py

package info (click to toggle)
plots 0.8.5%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,612 kB
  • sloc: python: 3,247; xml: 443; sh: 26; makefile: 6
file content (47 lines) | stat: -rw-r--r-- 1,512 bytes parent folder | download
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
43
44
45
46
47
# Copyright 2021 Alexander Huntley

# This file is part of Plots.

# Plots is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# Plots is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Plots.  If not, see <https://www.gnu.org/licenses/>.

import pytest

import plots.formula as f
from plots.parser import from_latex

lefts = [f.Paren(c) for c in "([{"]
rights = [f.Paren(c) for c in "}])"]

@pytest.mark.parametrize("paren", lefts + rights)
def test_is_paren(paren):
    assert f.Paren.is_paren(paren)

def test_is_not_paren():
    assert not f.Paren.is_paren(f.Atom("f"))

@pytest.mark.parametrize("paren", lefts)
def test_is_left_paren(paren):
    assert f.Paren.is_paren(paren, left=True)

@pytest.mark.parametrize("paren", rights)
def test_is_not_left_paren(paren):
    assert not f.Paren.is_paren(paren, left=True)

@pytest.mark.parametrize("paren", rights)
def test_is_right_paren(paren):
    assert f.Paren.is_paren(paren, left=False)

@pytest.mark.parametrize("paren", lefts)
def test_is_not_right_paren(paren):
    assert not f.Paren.is_paren(paren, left=False)