forked from UnitTestBot/UTBotJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeep_equals.py
More file actions
79 lines (51 loc) · 1.37 KB
/
deep_equals.py
File metadata and controls
79 lines (51 loc) · 1.37 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
from __future__ import annotations
from typing import List
class ComparableClass:
def __init__(self, x):
self.x = x
def __eq__(self, other):
return self.x == other.x
class BadClass:
def __init__(self, x):
self.x = x
def return_bad_class(x: int):
return BadClass(x)
def return_comparable_class(x: int):
return ComparableClass(x)
def primitive_list(x: int):
return [x] * 10
def primitive_set(x: int):
return set(x+i for i in range(5))
def primitive_dict(x: str, y: int):
return {x: y}
def comparable_list(length: int):
return [ComparableClass(x) for x in range(min(length, 10))]
def bad_list(length: int):
return [BadClass(x) for x in range(min(length, 10))]
class Node:
name: str
children: List[Node]
def __init__(self, name: str):
self.name = name
self.children = []
def __str__(self):
return f'<Node: {self.name}>'
def __eq__(self, other):
if isinstance(other, Node):
return self.name == other.name
else:
return False
def cycle(x: str):
a = Node(x + '_a')
b = Node(x + '_b')
a.children.append(b)
b.children.append(a)
return a
def cycle2(x: str):
a = Node(x + '_a')
b = Node(x + '_b')
c = Node(x + '_c')
a.children.append(b)
b.children.append(c)
c.children.append(a)
return a