Created
December 13, 2009 13:06
-
-
Save bebraw/255407 to your computer and use it in GitHub Desktop.
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
from placidity.interpreter import Interpreter | |
def test_sum(): | |
interpreter = Interpreter() | |
assert interpreter.interpret('1+1') == 2 | |
def test_subtract(): | |
interpreter = Interpreter() | |
assert interpreter.interpret('5-1') == 4 | |
def test_multiply(): | |
interpreter = Interpreter() | |
assert interpreter.interpret('3*5') == 15 | |
def test_divide(): | |
interpreter = Interpreter() | |
assert interpreter.interpret('12/4') == 3 |
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
class Interpreter: | |
def interpret(self, expression): | |
return eval(expression) |
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
from placidity.interpreter import Interpreter | |
class TestInterpreter: | |
def setup_method(self, method): | |
self.interpreter = Interpreter() | |
def test_sum(self): | |
assert self.interpreter.interpret('1+1') == 2 | |
def test_subtract(self): | |
assert self.interpreter.interpret('5-1') == 4 | |
def test_multiply(self): | |
assert self.interpreter.interpret('3*5') == 15 | |
def test_divide(self): | |
assert self.interpreter.interpret('12/4') == 3 |
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
class Interpreter: | |
def interpret(self, expression): | |
return 2 |
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
from placidity.interpreter import Interpreter | |
def test_sum(): | |
interpreter = Interpreter() | |
assert interpreter.interpret('1+1') == 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment