Esempio n. 1
0
def test_if(capfd):
    interpret('''
    if (1) {
       print 2;
    }
    ''')
    out, err = capfd.readouterr()
    assert out == '2\n'
Esempio n. 2
0
def test_func(capfd):
    interpret('''
    func hello() {
      print "Hello World!";
    }

    hello();
    ''')

    out, err = capfd.readouterr()
    assert out == 'Hello World!\n'
Esempio n. 3
0
def test_float_lt_int_error(capfd):
    with raises(Exception):
        interpret('1.5 < 5;')
Esempio n. 4
0
def test_float_lt(capfd):
    interpret('print 1.5 < .5;')
    out, err = capfd.readouterr()
    assert out == 'False\n' and not err
Esempio n. 5
0
def test_float_add_int_error():
    with raises(Exception):
        interpret('1.5 + 5;')
Esempio n. 6
0
def test_float_add(capfd):
    interpret('print 1.5 + .5;')
    out, err = capfd.readouterr()
    assert out == '2.0\n' and not err
Esempio n. 7
0
def test_int_lt(capfd):
    interpret('print 1 < 5;')
    out, err = capfd.readouterr()
    assert out == 'True\n' and not err
Esempio n. 8
0
def test_add_int_error():
    with raises(Exception):
        interpret('1 + .5;')
Esempio n. 9
0
def test_string_lt(capfd):
    interpret('print "foo" < "bar";')
    out, err = capfd.readouterr()
    assert out == 'False\n' and not err
Esempio n. 10
0
def test_print(capfd):
    interpret('print 1;')
    out, err = capfd.readouterr()
    assert out == '1\n'
Esempio n. 11
0
def test_interp():
    interpret('1 + 2;')
Esempio n. 12
0
def test_while():
    interpret('n = 0; while (n < 10) { n = n + 1; }')
Esempio n. 13
0
def test_string_lt_other_error(capfd):
    with raises(Exception):
        interpret('"foo" < 5;')
Esempio n. 14
0
def test_string_add(capfd):
    interpret('print "foo" + "bar";')
    out, err = capfd.readouterr()
    assert out == 'foobar\n' and not err
Esempio n. 15
0
def test_int_add(capfd):
    interpret('print 1 + 5;')
    out, err = capfd.readouterr()
    assert out == '6\n' and not err
Esempio n. 16
0
def test_string_add_other_error():
    with raises(Exception):
        interpret('"foo" + 5;')
Esempio n. 17
0
 def main(i):
     interpret(codes[i])