Exemplo n.º 1
0
    def test_rawshape(self):
        space = DummySpace()
        args = make_arguments_for_translation(space, [1,2,3])
        assert rawshape(args) == (3, (), False, False)

        args = make_arguments_for_translation(space, [1])
        assert rawshape(args, 2) == (3, (), False, False)

        args = make_arguments_for_translation(space, [1,2,3,4,5])
        assert rawshape(args) == (5, (), False, False)

        args = make_arguments_for_translation(space, [1], {'c': 3, 'b': 2})
        assert rawshape(args) == (1, ('b', 'c'), False, False)

        args = make_arguments_for_translation(space, [1], {'c': 5})
        assert rawshape(args) == (1, ('c', ), False, False)

        args = make_arguments_for_translation(space, [1], {'c': 5, 'd': 7})
        assert rawshape(args) == (1, ('c', 'd'), False, False)

        args = make_arguments_for_translation(space, [1,2,3,4,5], {'e': 5, 'd': 7})
        assert rawshape(args) == (5, ('d', 'e'), False, False)

        args = make_arguments_for_translation(space, [], {},
                                       w_stararg=[1],
                                       w_starstararg={'c': 5, 'd': 7})
        assert rawshape(args) == (0, (), True, True)

        args = make_arguments_for_translation(space, [1,2], {'g': 9},
                                       w_stararg=[3,4,5],
                                       w_starstararg={'e': 5, 'd': 7})
        assert rawshape(args) == (2, ('g', ), True, True)
Exemplo n.º 2
0
    def test_rawshape(self):
        space = DummySpace()
        args = make_arguments_for_translation(space, [1, 2, 3])
        assert rawshape(args) == (3, (), False, False)

        args = make_arguments_for_translation(space, [1])
        assert rawshape(args, 2) == (3, (), False, False)

        args = make_arguments_for_translation(space, [1, 2, 3, 4, 5])
        assert rawshape(args) == (5, (), False, False)

        args = make_arguments_for_translation(space, [1], {"c": 3, "b": 2})
        assert rawshape(args) == (1, ("b", "c"), False, False)

        args = make_arguments_for_translation(space, [1], {"c": 5})
        assert rawshape(args) == (1, ("c",), False, False)

        args = make_arguments_for_translation(space, [1], {"c": 5, "d": 7})
        assert rawshape(args) == (1, ("c", "d"), False, False)

        args = make_arguments_for_translation(space, [1, 2, 3, 4, 5], {"e": 5, "d": 7})
        assert rawshape(args) == (5, ("d", "e"), False, False)

        args = make_arguments_for_translation(space, [], {}, w_stararg=[1], w_starstararg={"c": 5, "d": 7})
        assert rawshape(args) == (0, (), True, True)

        args = make_arguments_for_translation(
            space, [1, 2], {"g": 9}, w_stararg=[3, 4, 5], w_starstararg={"e": 5, "d": 7}
        )
        assert rawshape(args) == (2, ("g",), True, True)
Exemplo n.º 3
0
    def test_rawshape(self):
        space = DummySpace()
        args = make_arguments_for_translation(space, [1,2,3])
        assert rawshape(args) == (3, (), False, False)

        args = make_arguments_for_translation(space, [1])
        assert rawshape(args, 2) == (3, (), False, False)

        args = make_arguments_for_translation(space, [1,2,3,4,5])
        assert rawshape(args) == (5, (), False, False)

        args = make_arguments_for_translation(space, [1], {'c': 3, 'b': 2})
        assert rawshape(args) == (1, ('b', 'c'), False, False)

        args = make_arguments_for_translation(space, [1], {'c': 5})
        assert rawshape(args) == (1, ('c', ), False, False)

        args = make_arguments_for_translation(space, [1], {'c': 5, 'd': 7})
        assert rawshape(args) == (1, ('c', 'd'), False, False)

        args = make_arguments_for_translation(space, [1,2,3,4,5], {'e': 5, 'd': 7})
        assert rawshape(args) == (5, ('d', 'e'), False, False)

        args = make_arguments_for_translation(space, [], {},
                                       w_stararg=[1],
                                       w_starstararg={'c': 5, 'd': 7})
        assert rawshape(args) == (0, (), True, True)

        args = make_arguments_for_translation(space, [1,2], {'g': 9},
                                       w_stararg=[3,4,5],
                                       w_starstararg={'e': 5, 'd': 7})
        assert rawshape(args) == (2, ('g', ), True, True)
Exemplo n.º 4
0
 def test_copy_and_shape(self):
     space = DummySpace()        
     args = ArgumentsForTranslation(space, ['a'], ['x'], [1],
                                    ['w1'], {'y': 'w2'})
     args1 = args.copy()
     args.combine_if_necessary()
     assert rawshape(args1) == (1, ('x',), True, True)
Exemplo n.º 5
0
 def test_copy_and_shape(self):
     space = DummySpace()
     args = ArgumentsForTranslation(space, ['a'], ['x'], [1], ['w1'],
                                    {'y': 'w2'})
     args1 = args.copy()
     args.combine_if_necessary()
     assert rawshape(args1) == (1, ('x', ), True, True)
Exemplo n.º 6
0
 def variant_for_call_site(bookkeeper, family, descs, args, op):
     shape = rawshape(args)
     bookkeeper.enter(None)
     try:
         row = FunctionDesc.row_to_consider(descs, args, op)
     finally:
         bookkeeper.leave()
     index = family.calltable_lookup_row(shape, row)
     return shape, index
Exemplo n.º 7
0
 def consider_call_site(bookkeeper, family, descs, args, s_result, op):
     shape = rawshape(args, nextra=1)     # account for the extra 'self'
     funcdescs = [methoddesc.funcdesc for methoddesc in descs]
     row = FunctionDesc.row_to_consider(descs, args, op)
     family.calltable_add_row(shape, row)
Exemplo n.º 8
0
 def consider_call_site(bookkeeper, family, descs, args, s_result, op):
     shape = rawshape(args)
     row = FunctionDesc.row_to_consider(descs, args, op)
     family.calltable_add_row(shape, row)
Exemplo n.º 9
0
 def test_copy_and_shape(self):
     space = DummySpace()
     args = ArgumentsForTranslation(space, ["a"], ["x"], [1], ["w1"], {"y": "w2"})
     args1 = args.copy()
     args.combine_if_necessary()
     assert rawshape(args1) == (1, ("x",), True, True)