<s> import pytest <EOL> from pycket . expand import expand , parse_module , expand_string <EOL> from pycket . interpreter import * <EOL> from pycket . values import * <EOL> from pycket . prims import * <EOL> from pycket . test . testhelper import run , run_fix , run_mod_expr , run_mod_defs , run_mod <EOL> def test_empty_mod ( ) : <EOL> run_mod_defs ( "<STR_LIT>" ) <EOL> def test_racket_mod ( ) : <EOL> m = run_mod ( "<STR_LIT>" ) <EOL> ov = m . defs [ W_Symbol . make ( "<STR_LIT:x>" ) ] <EOL> assert ov . value == <NUM_LIT:1> <EOL> def test_constant_mod ( ) : <EOL> run_mod_expr ( "<STR_LIT:1>" ) <EOL> def test_constant_mod_val ( ) : <EOL> ov = run_mod_expr ( "<STR_LIT:1>" ) <EOL> assert isinstance ( ov , W_Fixnum ) <EOL> assert ov . value == <NUM_LIT:1> <EOL> def test_constant ( ) : <EOL> run_fix ( "<STR_LIT:1>" , v = <NUM_LIT:1> ) <EOL> def test_set_modvar ( ) : <EOL> m = run_mod ( """<STR_LIT>""" ) <EOL> ov = m . defs [ W_Symbol . make ( "<STR_LIT>" ) ] . get_val ( ) <EOL> assert ov . value == <NUM_LIT:100> <EOL> def test_set_mod2 ( ) : <EOL> m = run_mod ( """<STR_LIT>""" ) <EOL> ov = m . defs [ W_Symbol . make ( "<STR_LIT>" ) ] <EOL> assert isinstance ( ov , W_Cell ) <EOL> def test_set_mod_other ( ) : <EOL> m = run_mod ( """<STR_LIT>""" ) <EOL> assert m . defs [ W_Symbol . make ( "<STR_LIT:y>" ) ] <EOL> def test_use_before_definition ( ) : <EOL> with pytest . raises ( SchemeException ) : <EOL> m = run_mod ( """<STR_LIT>""" ) <EOL> with pytest . raises ( SchemeException ) : <EOL> m = run_mod ( """<STR_LIT>""" ) <EOL> def test_shadowing_macro ( ) : <EOL> m = run_mod ( """<STR_LIT>""" ) <EOL> ov = m . defs [ W_Symbol . make ( "<STR_LIT:x>" ) ] <EOL> assert ov . value == <NUM_LIT:6> <EOL> def test_kw_submodule ( ) : <EOL> m = run_mod ( <EOL> """<STR_LIT>""" ) <EOL> def test_submodule_operations ( ) : <EOL> m = run_mod ( <EOL> """<STR_LIT>""" ) <EOL> assert len ( m . submodules ) == <NUM_LIT:1> <EOL> b = m . defs [ W_Symbol . make ( "<STR_LIT:b>" ) ] <EOL> sub = m . resolve_submodule_path ( [ "<STR_LIT>" ] ) <EOL> assert sub . parent is m <EOL> assert sub in m . submodules <EOL> assert m . root_module ( ) is m <EOL> assert sub . root_module ( ) is m <EOL> a = sub . defs [ W_Symbol . make ( "<STR_LIT:a>" ) ] <EOL> assert isinstance ( b , W_Integer ) and b . value == <NUM_LIT:2> <EOL> assert isinstance ( a , W_Integer ) and a . value == <NUM_LIT:1> <EOL> def test_module_star ( ) : <EOL> m = run_mod ( <EOL> """<STR_LIT>""" ) <EOL> assert len ( m . submodules ) == <NUM_LIT:2> <EOL> outer = m . find_submodule ( "<STR_LIT>" ) <EOL> snd = m . find_submodule ( "<STR_LIT>" ) <EOL> assert outer . parent is m <EOL> assert snd . parent is m <EOL> assert len ( outer . submodules ) == <NUM_LIT:1> <EOL> assert len ( snd . submodules ) == <NUM_LIT:0> <EOL> d = m . defs [ W_Symbol . make ( "<STR_LIT:d>" ) ] <EOL> assert isinstance ( d , W_Integer ) and d . value == <NUM_LIT:4> </s>
