Beispiel #1
0
def test_run_file():
    eva = Evaluator()
    with open('gcd1.ch1') as src:
        eva.run(src)
        eq_(sys.stdout.getvalue(), '3\n')
Beispiel #2
0
def test_run_file_multiline_output():
    eva = Evaluator()
    with open('factorials.ch1') as src:
        eva.run(src)
        eq_(sys.stdout.getvalue(), expected)
Beispiel #3
0
def test_expr_no_output():
    eva = Evaluator()
    src = StringIO('(+ 2 3)')
    eva.run(src)
    eq_(sys.stdout.getvalue(), '')
Beispiel #4
0
def test_expr_with_output():
    eva = Evaluator()
    src = StringIO('(print 7)')
    eva.run(src)
    eq_(sys.stdout.getvalue(), '7\n')
Beispiel #5
0
def test_run_file():
    eva = Evaluator()
    with open('gcd1.ch1') as src:
        eva.run(src)
        eq_(sys.stdout.getvalue(), '3\n')
Beispiel #6
0
def test_run_file_multiline_output():
    eva = Evaluator()
    with open('factorials.ch1') as src:
        eva.run(src)
        eq_(sys.stdout.getvalue(), expected)
Beispiel #7
0
def test_expr_no_output():
    eva = Evaluator()
    src = StringIO('(+ 2 3)')
    eva.run(src)
    eq_(sys.stdout.getvalue(), '')
Beispiel #8
0
def test_expr_with_output():
    eva = Evaluator()
    src = StringIO('(print 7)')
    eva.run(src)
    eq_(sys.stdout.getvalue(), '7\n')
Beispiel #9
0
def setup():
    global evaluate
    eva = Evaluator()
    evaluate = lambda exp: eva.evaluate({}, exp)
Beispiel #10
0
def test_expr_no_output(capsys):
    eva = Evaluator()
    src = StringIO('(+ 2 3)')
    eva.run(src)
    captured = capsys.readouterr()
    assert captured.out == ''
Beispiel #11
0
def test_run_file_multiline_output(capsys):
    eva = Evaluator()
    with open('factorials.ch1') as src:
        eva.run(src)
        captured = capsys.readouterr()
        assert captured.out == expected
Beispiel #12
0
def test_run_file(capsys):
    eva = Evaluator()
    with open('gcd1.ch1') as src:
        eva.run(src)
        captured = capsys.readouterr()
        assert captured.out == '3\n'
Beispiel #13
0
def test_expr_with_output(capsys):
    eva = Evaluator()
    src = StringIO('(print 7)')
    eva.run(src)
    captured = capsys.readouterr()
    assert captured.out == '7\n'