def test_is_basetype(self): true = self.assertTrue true( int_t.is_base() ) true( float_t.is_base() ) true( str_t.is_base() ) true( unicode_t.is_base() ) true( bool_t.is_base() ) true( unit_t.is_base() ) equal = self.assertEqual equal( PType.int(), int_t ) equal( PType.float(), float_t ) equal( PType.string(), str_t ) equal( PType.unicode(), unicode_t ) equal( PType.bool(), bool_t ) equal( PType.unit(), unit_t ) all(equal(PType.from_str(k), v) for (k,v) in base_ts.iteritems())
import sys import unittest from lepl import sexpr_to_tree # Include src in the Python search path sys.path.insert(0, '../src') from ptype import (PType, TypeSpecParser, better_sexpr_to_tree, Lst, Stt, Tup, Mpp, Arr) int_t = PType.int() float_t = PType.float() str_t = PType.string() unicode_t = PType.unicode() bool_t = PType.bool() unit_t = PType.unit() base_ts = {"int": int_t, "float": float_t, "str": str_t, "unicode": unicode_t, "bool": bool_t, "unit": unit_t} class PTypeTests(unittest.TestCase): def test_is_basetype(self): true = self.assertTrue true( int_t.is_base() ) true( float_t.is_base() ) true( str_t.is_base() ) true( unicode_t.is_base() ) true( bool_t.is_base() ) true( unit_t.is_base() )
import ast import logging from util import cname, slice_range, node_is_int, valid_int_slice from errors import TypeUnspecifiedError from ptype import PType from settings import DEBUG_INFER # Need to use this form to resolve circular import. import check int_t = PType.int() float_t = PType.float() bool_t = PType.bool() str_t = PType.string() unicode_t = PType.unicode() unit_t = PType.unit() log = None def i_debug(s, cond=True): log.debug(s, DEBUG_INFER and cond) def call_function(fun_name, *args, **kwargs): return globals()[fun_name](*args, **kwargs) def env_get(env, var_id): """