forked from UnitTestBot/UTBotJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneral.py
More file actions
208 lines (145 loc) · 3.02 KB
/
general.py
File metadata and controls
208 lines (145 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import collections
import heapq
import typing
from socket import socket
from typing import List, Dict, Set, Optional, AbstractSet
from dataclasses import dataclass
import logging
import datetime
import sample_classes
class Dummy:
def propagate(self):
return [self, self]
@staticmethod
def abs(x):
return abs(x)
def dict_f(x, a, b, c):
y = {1: 2}
if x == y:
return 1
x = a
x = b
x = c
return 2
class A:
x = 4
y = 5
def func(self):
n = 0
for i in range(self.x):
n += self.y
return n
def fact(n):
ans = 1
for i in range(1, n + 1):
ans *= i
return ans
def empty_():
pass
def conditions(x):
if x % 100 == 0:
return 1
elif x + 100 < 400:
return 2
else:
if x == complex(1, 2):
return x.real
elif len(str(x)) > 3:
return 3
else:
return 4
def test_call(x):
return repr_test(x)
def zero_division(x):
return x / x
def repr_test(x):
x *= 100
return [1, x + 1, collections.UserList([1, 2, 3]), collections.Counter("flkafksdf"), collections.OrderedDict({1: 2, 4: "jflas"})]
def str_test(x):
x += '1"23'
x += "flskjd'jfslk"
if len(x.split('.')) == 1:
return '1"23'
else:
return """100''500"""
def return_socket(x: int):
return socket()
def empty():
return 1
def id_(x: AbstractSet[int]):
return x
def f(x, y, z, a, c, d, e, g, h, i):
if y % 2 == 0:
x = 1 + y
z += "aba"
a += [2] + list("str") + i
A = c < "abc"
B = "abc" == d
e = {1, 2, 3}
C = g == {1: 2}
h += int("777")
return x + y
def g(x: List[int], y: List):
y[0] += 1
return x, y
def i(x: Dict[int, int]):
return x[0]
def j(x: Set[int]):
return x
def h(x):
if x < 123:
return 1
return 2
def a(x):
x.description += 1
return x.description
def sqrt(x):
return x.sqrt()
@dataclass
class InventoryItem:
name: str
def inv(x):
return x.name + "aba" # interesting case with io.BytesIO
def b(x, y):
y = len(x)
return bytes(x, 'utf-8')
def c(x):
return heapq.heapify(x)
def d(x: Optional[int]):
return x
def k(x: typing.Any):
if x == complex(1):
return x
def constants(x):
if x == 1e5:
return "one"
elif (x > 1e4 - 2) and (x < 1e4):
return "two"
else:
return "three"
# interesting case with sets
def get_data_labels(dates):
if len(dates) == 0:
return None
if all(x.hour == 0 and x.minute == 0 for x in dates):
return [x.strftime('%Y-%m-%d') for x in dates]
else:
return [x.strftime('%H:%M') for x in dates]
"""
# bad function
def m(x):
x = frozenset()
return len(x + 1)
# very bad function
def n(x, y):
y = (-x) + 1
x *= 10
# z = -x
print(x)
x = len([1])
if y == len([1]):
y += print()
return x.description
"""
def list_of_list(x: List[List[InventoryItem]]):
return x