def randomize(self): while True: self.value = common.get_random_string( randomizer.randint(self.min_identifier_length, self.max_identifier_length), False) if not self.filter(): break
def randomize(self): common.usedRandomize() self.name = common.get_random_string(self.max_name_length, False) #self.type = self.base_type_generator.generate_random(['bit', 'varbit', 'int']) self.type = self.base_type_generator.generate_random( ['int'] ) # todo change to ['bit', 'varbit', 'int'] when literals are correctly generated self.value = literal.get(self.type)
def generate_base_expression(self, type): if type == 'bool': values = ['true', 'false'] return randomizer.choice(values) if type == 'string': return '"' + common.get_random_string( randomizer.randint(self.string_min_length, self.string_max_length), False) + '"' if type == 'arithmetic': return common.get_random_number(self.numeric_min_size, self.numeric_max_size)
def generate_code(self): common.usedCodeGenerator(self) code = '' if self.annotation is not None: code = self.annotation.generate_code() + ' ' code += 'header_union' + ' ' code += self.name + ' ' code += '{\n' for header in self.headers: name = header.get_name() + '_' + common.get_random_string( self.name_length, False) code += '\t' + header.generate_code_ref() + ' ' + name + '; \n' code += '}\n' return code
def get(type): max_string_length = 1000 max_int_size = 100000 # if type == 'error': # return error(identifier_list) if type.get_name() == 'bool': return randomizer.choice(["true", "false"]) if type.get_name() == 'bit': return '"' + common.get_random_string(type.get_size(), False) + '"' if type.get_name() == 'varbit': return '"' + bin(common.get_random_number(0, type.get_size())) + '"' if type.get_name() == 'int': return common.get_random_number(0, type.get_size()) return ''
def generate_name(self): return common.get_random_string(self.name_max_length, False) + '_union'
def randomize(self): common.get_random_string( randomizer.randint(self.name_min_length, self.name_max_length), False)
def generate_field_name(self, name): return common.get_random_string(self.max_field_name_length, False) + '_' + name
def randomize(self): common.usedRandomize() self.name = common.get_random_string(self.max_name_length, False) self.type = self.base_type_generator.generate_random(['bit', 'varbit', 'int']) self.value = 1 # todo generate random value based on type
def generate_name(self): code = common.get_random_string(self.name_length, True) + '_enum' return code
def generate_identifiers(self, number): identifiers = [] for x in range(0, number): identifiers.append( common.get_random_string(self.field_name_length, True)) return identifiers