Пример #1
0
def randSimpleDict():
    pyDict = {}
    length = randint(0, MAX_DICT_LENGTH)
    for i in range(length):
        pyDict[choice(simpleTypePool)()[0]] = choice(simpleTypePool)()[0]
        #Overwriting keys isn't really a big deal, since we are choosing the length randomly anyway.
    return (pyDict, toScala(pyDict))
Пример #2
0
def randSimpleDict():
    pyDict = {}
    length = randint(0,MAX_DICT_LENGTH)
    for i in range(length):
        pyDict[choice(simpleTypePool)()[0]]=choice(simpleTypePool)()[0]
        #Overwriting keys isn't really a big deal, since we are choosing the length randomly anyway.
    return (pyDict,toScala(pyDict))
Пример #3
0
def randSimpleTuple():
    pyList = []
    length = randint(1,MAX_TUPLE_LENGTH)
    for i in range(length):
        pyList.append(choice(simpleTypePool)()[0])
    tup = tuple(pyList)
    return (tup,toScala(tup))
Пример #4
0
def randSimpleTuple():
    pyList = []
    length = randint(1, MAX_TUPLE_LENGTH)
    for i in range(length):
        pyList.append(choice(simpleTypePool)()[0])
    tup = tuple(pyList)
    return (tup, toScala(tup))
Пример #5
0
def randList(depth=1):
    pyList = []
    length = randint(0,MAX_LIST_LENGTH)
    if depth >= MAX_DEPTH:
        for i in range(length):
            pyList.append(choice(completeSimplePool)()[0])
    else:
        for i in range(length):
            if random() < RECURSE_RATE:
                pyList.append(choice(recursiveContainerPool)(depth+1)[0])
            else:
                pyList.append(choice(completeSimplePool)()[0])
    return (pyList,toScala(pyList))
Пример #6
0
def randList(depth=1):
    pyList = []
    length = randint(0, MAX_LIST_LENGTH)
    if depth >= MAX_DEPTH:
        for i in range(length):
            pyList.append(choice(completeSimplePool)()[0])
    else:
        for i in range(length):
            if random() < RECURSE_RATE:
                pyList.append(choice(recursiveContainerPool)(depth + 1)[0])
            else:
                pyList.append(choice(completeSimplePool)()[0])
    return (pyList, toScala(pyList))
Пример #7
0
def randTuple(depth=1):
    pyList = []
    length = randint(1,MAX_TUPLE_LENGTH)
    if depth >= MAX_DEPTH:
        for i in range(length):
            pyList.append(choice(simpleTypePool)()[0])
    else:
        for i in range(length):
            if random() < RECURSE_RATE:
                pyList.append(choice(recursiveContainerPool)(depth+1)[0])
            else:
                pyList.append(choice(completeSimplePool)()[0])
    tup = tuple(pyList)
    return (tup,toScala(tup))
Пример #8
0
def randTuple(depth=1):
    pyList = []
    length = randint(1, MAX_TUPLE_LENGTH)
    if depth >= MAX_DEPTH:
        for i in range(length):
            pyList.append(choice(simpleTypePool)()[0])
    else:
        for i in range(length):
            if random() < RECURSE_RATE:
                pyList.append(choice(recursiveContainerPool)(depth + 1)[0])
            else:
                pyList.append(choice(completeSimplePool)()[0])
    tup = tuple(pyList)
    return (tup, toScala(tup))
Пример #9
0
def randDict(depth=1):
    pyDict = {}
    length = randint(0,MAX_DICT_LENGTH)
    if depth >= MAX_DEPTH:
        for i in range(length):
            pyDict[choice(simpleTypePool)()[0]] = choice(simpleTypePool)()[0]
    else:
        key=None
        value=None
        for i in range(length):
            key = choice(simpleTypePool)()[0]
            if random() < RECURSE_RATE:
                value = choice(recursiveContainerPool)(depth+1)[0]
            else:
                value = choice(completeSimplePool)()[0]
            pyDict[key]=value
    return (pyDict,toScala(pyDict))
Пример #10
0
def randDict(depth=1):
    pyDict = {}
    length = randint(0, MAX_DICT_LENGTH)
    if depth >= MAX_DEPTH:
        for i in range(length):
            pyDict[choice(simpleTypePool)()[0]] = choice(simpleTypePool)()[0]
    else:
        key = None
        value = None
        for i in range(length):
            key = choice(simpleTypePool)()[0]
            if random() < RECURSE_RATE:
                value = choice(recursiveContainerPool)(depth + 1)[0]
            else:
                value = choice(completeSimplePool)()[0]
            pyDict[key] = value
    return (pyDict, toScala(pyDict))
Пример #11
0
def randLong128():
    num=randInt(128)
    return (long(num),toScala(num))
Пример #12
0
def randLong64():
    num=randInt(64)
    #Need to convert to long because some Python ints may not fit into a Scala Int.
    #This is important for when toArray tries to implicitly determine the type of the array.
    return (long(num),toScala(num))
Пример #13
0
def randSimpleList():
    pyList = []
    length = randint(0,MAX_LIST_LENGTH)
    for i in range(length):
        pyList.append(choice(simpleTypePool)()[0])
    return (pyList,toScala(pyList))
Пример #14
0
def randLong128():
    num = randInt(128)
    return (long(num), toScala(num))
Пример #15
0
def randLong64():
    num = randInt(64)
    #Need to convert to long because some Python ints may not fit into a Scala Int.
    #This is important for when toArray tries to implicitly determine the type of the array.
    return (long(num), toScala(num))
Пример #16
0
def randSimpleList():
    pyList = []
    length = randint(0, MAX_LIST_LENGTH)
    for i in range(length):
        pyList.append(choice(simpleTypePool)()[0])
    return (pyList, toScala(pyList))