Skip to content
Snippets Groups Projects
Commit 551d3ed4 authored by Arthur Jacquin's avatar Arthur Jacquin
Browse files

fix: fix the calculator

parent 0f47a881
No related branches found
No related tags found
No related merge requests found
Pipeline #46378 failed
......@@ -10,7 +10,7 @@ download_dependencies:
script:
- python -m venv .venv
- source .venv/bin/activate
- pip install -r requirements.txt
- python -m pip install -r requirements.txt
artifacts:
paths:
- .venv
......@@ -23,9 +23,16 @@ pylint:
- download_dependencies
script:
- source .venv/bin/activate
- pip install pylint
- pylint calculator --fail-on=error
- python -m pip install pylint
- python -m pylint calculator --fail-on=error
# À toi de nous rajouter un petit job pour faire des tests unitaires
pytest:
## Bon courage
stage: test
dependencies:
- download_dependencies
script:
- source .venv/bin/activate
- python -m pip install pylint
- python -m pytest calculator
\ No newline at end of file
......@@ -66,5 +66,5 @@ class Calculator:
return OperatorExpression(operator, self.parse(left), self.parse(right))
def __call__(self, expression: str) -> Term:
return 5 # Au moins il y a pas de surprise 😐
# return self.parse(self.tokenize(expression))()
# return 5 # Au moins il y a pas de surprise 😐
return self.parse(self.tokenize(expression))()
"""
Operator module contains the Operator class and a list of standard operators.
"""
class Operator:
"""
Operator class is a binary operator with a symbol, a precedence and an evaluation function.
......@@ -21,6 +23,6 @@ class Operator:
STANDARD_OPERATORS = {
'+': Operator('+', 1, lambda a, b: a + b),
'-': Operator('-', 1, lambda a, b: a - b),
'*': Operator('×', 2, lambda a, b: a * b),
'*': Operator('*', 2, lambda a, b: a * b),
'/': Operator('/', 2, lambda a, b: a / b),
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment