コード例 #1
0
ファイル: test_run_snippet.py プロジェクト: andybalaam/pepper
def Run_snippet_runs_single_line__test():
    assert_equal(
        "6",
        run_snippet( """
3*2
        """)
    )
コード例 #2
0
ファイル: test_run_snippet.py プロジェクト: andybalaam/pepper
def Run_snippet_can_use_variable__test():
    assert_equal(
        "12",
        run_snippet( """
int x = 3
x*4
        """)
    )
コード例 #3
0
ファイル: test_run_snippet.py プロジェクト: andybalaam/pepper
def Run_snippet_can_call_a_function__test():
    assert_equal(
        "24",
        run_snippet( """
def int myfn( int x ):
    return x + 1
6 * myfn( 3 )
        """)
    )
コード例 #4
0
def len_argv_can_be_stored_in_a_variable__test():
    """
    At one point, the length of sys.argv could not be stored in a variable.
    Correct behaviour is to render the name of the variable, since the
    value is not known at compile time.
    """

    assert_equal(
        'num_args',
        run_snippet( """
import sys
int num_args = len( sys.argv )
num_args
        """)
    )