Ejemplo n.º 1
0
def hide_numbers(obj,deep_max_min=3,deep_max_max=5,lower_bound=-10000,upper_bound=10000):
    deep_max = randint(min(deep_max_min,deep_max_max),max(deep_max_min,deep_max_max))
    for i in xrange(len(obj)):
	#floats   = ExtractKeywords.extract_float(obj[i]) 
	integers = ExtractKeywords.extract_integer(obj[i])
	#for j in xrange(len(floats)): obj[i] = obj[i].replace(floats[j],hide_number(float(floats[j]),0,deep_max,lower_bound,upper_bound))
	for j in xrange(len(integers)): 
	    if int(integers[j])!=0: 
		obj[i] = obj[i].replace(" "+integers[j]+"\n"," "+hide_number(int(integers[j]),0,deep_max,lower_bound,upper_bound)+"\n")
    return obj
Ejemplo n.º 2
0
def hide_numbers(obj,
                 deep_max_min=3,
                 deep_max_max=5,
                 lower_bound=-10000,
                 upper_bound=10000):
    deep_max = randint(min(deep_max_min, deep_max_max),
                       max(deep_max_min, deep_max_max))
    for i in xrange(len(obj)):
        #floats   = ExtractKeywords.extract_float(obj[i])
        integers = ExtractKeywords.extract_integer(obj[i])
        #for j in xrange(len(floats)): obj[i] = obj[i].replace(floats[j],hide_number(float(floats[j]),0,deep_max,lower_bound,upper_bound))
        for j in xrange(len(integers)):
            if int(integers[j]) != 0:
                obj[i] = obj[i].replace(
                    " " + integers[j] + "\n",
                    " " + hide_number(int(integers[j]), 0, deep_max,
                                      lower_bound, upper_bound) + "\n")
    return obj
Ejemplo n.º 3
0
def block_while(deep_act,
                n_statements_min=10,
                n_statements_max=20,
                n_guard_statements_min=1,
                n_guard_statements_max=5,
                n_else_if_min=1,
                n_else_if_max=5,
                deep_max=5,
                case_values_min=-1000,
                case_values_max=1000):
    n_guard_statements = randint(
        min(n_guard_statements_min, n_guard_statements_max),
        max(n_guard_statements_min, n_guard_statements_max))
    log_statements, declarations = logical_statements(n_guard_statements), ""
    logic_variables = ExtractKeywords.extract_variables(log_statements)
    relational_operators = ExtractKeywords.extract_relational_operators(
        log_statements)
    const_values = ExtractKeywords.extract_integer(log_statements)
    for i in logic_variables:
        declarations += Utils.generate_random_declarator(
        ) + assign_by_var_name(i) + "\n"
    res = declarations + Utils.low_up_string("\nWhile ") + log_statements
    return res  # Acabar #