コード例 #1
0
ファイル: test_argument.py プロジェクト: alkorzt/pypy
    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)
コード例 #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)
コード例 #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)
コード例 #4
0
ファイル: test_argument.py プロジェクト: alkorzt/pypy
 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)
コード例 #5
0
ファイル: test_argument.py プロジェクト: nipengadmaster/pypy
 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)
コード例 #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
コード例 #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)
コード例 #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)
コード例 #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)