Skip to content

Commit

Permalink
test(tests): update tests to new import structure
Browse files Browse the repository at this point in the history
  • Loading branch information
aadhithya committed May 21, 2022
1 parent 5c59466 commit c3bfccc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
3 changes: 0 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from rajinipp.runner import RppRunner

runner = RppRunner()
8 changes: 4 additions & 4 deletions tests/test_exprs.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from . import runner
from rajinipp import rpp


def test_conditional_exprs(cond_code, capsys):
runner.exec(cond_code)
rpp.exec(cond_code)
out, err = capsys.readouterr()
assert "x ( 15.0 ) is equal to 15!" in out.strip()


def test_logical_exprs(logic_code, capsys):
runner.exec(logic_code)
rpp.exec(logic_code)
out, err = capsys.readouterr()
assert "x != b: True" in out.strip()


def test_math_exprs(math_code, capsys):
runner.exec(math_code)
rpp.exec(math_code)
out, err = capsys.readouterr()
assert "modvar = 1.0" in out.strip()
10 changes: 5 additions & 5 deletions tests/test_flow_control.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
from . import runner
from rajinipp import rpp


def test_if(cond_code, capsys):
runner.exec(cond_code)
rpp.exec(cond_code)
out, err = capsys.readouterr()
assert "x ( 15.0 ) is equal to 15!" in out.strip()


def test_if_else(if_else_code, capsys):
runner.exec(if_else_code)
rpp.exec(if_else_code)
out, err = capsys.readouterr()
assert "x ( 5.0 ) is less than 10!" in out.strip()


def test_for_loop(for_loop_code, capsys):
runner.exec(for_loop_code)
rpp.exec(for_loop_code)
out, err = capsys.readouterr()
assert "After loop: X = 14.0" in out.strip()


def test_while_loop(while_loop_code, capsys):
runner.exec(while_loop_code)
rpp.exec(while_loop_code)
out, err = capsys.readouterr()
assert "breaking out of loop..." in out.strip()
6 changes: 3 additions & 3 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from . import runner
from rajinipp import rpp


def test_function(fn_code, capsys):
runner.exec(fn_code)
rpp.exec(fn_code)
out, err = capsys.readouterr()
assert "Hello from myfunc_one!" in out.strip()


def test_function_return(fn_return_code, capsys):
runner.exec(fn_return_code)
rpp.exec(fn_return_code)
out, err = capsys.readouterr()
assert "Value returned from myfunc_one: 100.0" in out.strip()
6 changes: 3 additions & 3 deletions tests/test_print.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from . import runner
from rajinipp import rpp


def test_print(hello_world, capsys):
runner.exec(hello_world)
rpp.exec(hello_world)
out, err = capsys.readouterr()
assert out.strip() == "Hello, World!"


def test_multi_print(multi_print, capsys):
runner.exec(multi_print)
rpp.exec(multi_print)
out, err = capsys.readouterr()
assert out.strip() == "5 + 5 = 10.0"
6 changes: 3 additions & 3 deletions tests/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from . import runner
from rajinipp import rpp


def test_exec(hello_world, capsys):
runner.exec(hello_world)
rpp.exec(hello_world)
out, err = capsys.readouterr()
assert out.strip() == "Hello, World!"


def test_eval():
out = runner.eval("5+5;")
out = rpp.eval("5+5;")
assert out == 10.0

0 comments on commit c3bfccc

Please sign in to comment.