source_language = 'C' hotspot_declarations = [ ['$x','int'], ['$operator','ascii_string'], ['$y','int'], ['$out','string'], ] x = range(-2,3) # consider separate group for &&,|| operator = ['<','<=','==','!=','<=','<', '&&','||'] y = [-2,-1,1,2] group_list = [ ['conditional_expression_io_'] + \ #[[1,'<',2,None]] generate_util.cross_product_sublist([x,operator,y,None], range(3)) ] #DB print 'expected number of tuples:',len(x)*len(operator)*len(y) global_code_template = '''\ d #include <stdio.h> x #include <stdio.h> dx ''' main_code_template = '''\ dx dx printf("%s\\n", $x $operator $y ? "a" : "b"); dx '''
actual = G.group_list expected = [ ['g_0', [4, 'x', 5]], ['g_1', [6, 'x', 7]], ] message = '''Error in %s: \tactual: %s \texpected: %s ''' if actual != expected: print message % (cut,str(actual),str(expected)) # sub_list ------------------------------------------------------- cut = 'cross_product_sublist' actual = generate_util.cross_product_sublist([[1,2],3,['a','b']], [0,2]) expected = [ [1,3,'a'], [1,3,'b'], [2,3,'a'], [2,3,'b'] ] message = '''Error in %s: \tactual: %s \texpected: %s ''' if actual != expected: print message % (cut,str(actual),str(expected)) cut = 'generalize_sublist' actual = generate_util.generalize_sublist([1,'a',2],1,[0,2]) expected = [ [None,'a',2], [1,'a',None] ] message = '''Error in %s: \tactual: %s \texpected: %s '''
source_language = 'C' hotspot_declarations = [ ['$a','int'], ['$b','int'], ['$c','int'], ['$d','int'], ['$out','string'], ] a = range(-2,3) b = range(-2,3) c = [-2,-1,1,2] d = range(-2,3) # print 'expected number of tuples',len(a)*len(b)*len(c)*len(d) group_list = [ ['abcd_io_'] + \ generate_util.cross_product_sublist([a,b,c,d,None], range(4)) ] global_code_template = '''\ d #include <stdio.h> x #include <stdio.h> dx ''' main_code_template = '''\ dx dx printf("%d\\n", $a + (($b/$c) - $d)); dx ''' argv_template = ''
['$out', 'string'], ] u = [-2, -1, 1, 2] v = [-2, -1, 1, 2] w = [-2, -1, 1, 2] x = range(-2, 3) print 'expected number of tuples', len(u) * len(v) * len(w) * len(x) group_list = [ # EoP example ['uvwx_io_eop_'] + [[1,-2,3,-4,None]], ['uvwx_io_b_'] + \ generate_util.cross_product_sublist([u,v,w,x,None], range(4)) ] global_code_template = '''\ d #include <stdio.h> x #include <stdio.h> dx ''' main_code_template = '''\ dx dx int u,v,w,x; dx u = $u; dx v = $v; dx w = $w; dx x = $x;
['$out','string'], ] u = [-2,-1,1,2] v = [-2,-1,1,2] w = [-2,-1,1,2] x = range(-2,3) print 'expected number of tuples',len(u)*len(v)*len(w)*len(x) group_list = [ # EoP example ['uvwx_io_eop_'] + [[1,-2,3,-4,None]], ['uvwx_io_b_'] + \ generate_util.cross_product_sublist([u,v,w,x,None], range(4)) ] global_code_template = '''\ d #include <stdio.h> x #include <stdio.h> dx ''' main_code_template = '''\ dx dx int u,v,w,x; dx u = $u; dx v = $v; dx w = $w; dx x = $x;
import generate_util question_type = "input_output" source_language = "C" hotspot_declarations = [["$a", "int"], ["$b", "int"], ["$c", "int"], ["$y", "int"]] group_list = [ ["min_three_io_h1_"] + generate_util.generalize([1, 2, 3, 1], 1), ["min_three_io_h2_"] + generate_util.generalize([1, 2, 3, 1], 2), ["min_three_io_cp_"] + generate_util.cross_product_sublist([[1, 2, 5], [3, 4, 7], [5, 6, 9], None], [0, 1, 2]), ] global_code_template = """\ d #include <stdio.h> x #include <stdio.h> dx """ main_code_template = """\ dx int a,b,c; dx dx a = $a; dx b = $b; dx c = $c; dx dx if (a < b) { dx if (a < c) { dx printf("%d\\n",a); dx } else { dx printf("%d\\n",c);
actual = G.group_list expected = [ ['g_0', [4, 'x', 5]], ['g_1', [6, 'x', 7]], ] message = '''Error in %s: \tactual: %s \texpected: %s ''' if actual != expected: print message % (cut, str(actual), str(expected)) # sub_list ------------------------------------------------------- cut = 'cross_product_sublist' actual = generate_util.cross_product_sublist([[1, 2], 3, ['a', 'b']], [0, 2]) expected = [[1, 3, 'a'], [1, 3, 'b'], [2, 3, 'a'], [2, 3, 'b']] message = '''Error in %s: \tactual: %s \texpected: %s ''' if actual != expected: print message % (cut, str(actual), str(expected)) cut = 'generalize_sublist' actual = generate_util.generalize_sublist([1, 'a', 2], 1, [0, 2]) expected = [[None, 'a', 2], [1, 'a', None]] message = '''Error in %s: \tactual: %s \texpected: %s '''