Exemplo n.º 1
0
def main():
    """ Example: UnitXObjectの変数を保存し,取り出し,確認する.
    """
    from simulator import Simulator
    s = Simulator()
    UnitXObject.manager = s.get_manager()
    UnitXObject.scopes = s.get_scopes()
    
    # Regist part
    crr_scope = s.get_scopes().peek()
    crr_scope['x'] = UnitXObject(value=1.5, varname='x', is_none=False, unit=Unit(ex_numer=u'm', numer=u'cm', ex_denom=None, denom=None))
    crr_scope['y'] = UnitXObject(value=1500, varname='y', is_none=False, unit=Unit(ex_numer=u'm', numer=u'km', ex_denom=u'時', denom=u'分'))
    s.get_scopes().new_scope()
    
    # Find & Show part
    found_scope = s.get_scopes().peek().find_scope_of('x')
    Util.dump(s.get_scopes())

    # Checking equals()
    tmp_obj = UnitXObject(value=1.5, varname='x', is_none=False, unit=Unit(ex_numer=None, numer=u'cm', ex_denom=None, denom=None))
    print tmp_obj
    print crr_scope['x'] == tmp_obj

    # Clear part
    s.get_scopes().del_scope()
    s.get_scopes().del_scope()
    return Constants.EXIT_SUCCESS
Exemplo n.º 2
0
def main():
    """Run an example for a Unit class."""
    from simulator import Simulator
    s = Simulator()
    print s.get_scopes()
    s.get_scopes().del_scope()
    print s.get_scopes()
Exemplo n.º 3
0
def main():
    """Run an example for a Stdlib class."""
    from unitx_object import UnitXObject
    from unit import Unit
    from simulator import Simulator

    s = Simulator()
    UnitXObject.manager = s.get_manager()
    UnitXObject.scopes = s.get_scopes()

    l = UnitXObject(value=1.5, varname='x', is_none=False, unit=Unit(numer=u'cm'))
    r = UnitXObject(value=1.5, varname='y', is_none=False, unit=Unit(numer=u'cm'))
    func_obj = None
    stdlib = Stdlib()
    stdlib.expect([l,r], func_obj)

    return Constants.EXIT_SUCCESS