Skip to content

Instantly share code, notes, and snippets.

@bebraw
Created December 13, 2009 13:06
Show Gist options
  • Save bebraw/255407 to your computer and use it in GitHub Desktop.
Save bebraw/255407 to your computer and use it in GitHub Desktop.
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
class Interpreter:
def interpret(self, expression):
return eval(expression)
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
class Interpreter:
def interpret(self, expression):
return 2
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