GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gpython/py/tests/set.py at main · go-python/gpython

Expand file tree

/

set.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
109 lines (94 loc) · 1.67 KB
/

set.py

Copy path

File metadata and controls

109 lines (94 loc) · 1.67 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# Copyright 2019 The go-python Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
from libtest import assertRaises
doc="__and__"
a = {1, 2, 3}
b = {2, 3, 4, 5}
c = a.__and__(b)
assert 2 in c
assert 3 in c
d = a & b
assert 2 in d
assert 3 in d
doc="__or__"
a = {1, 2, 3}
b = {2, 3, 4, 5}
c = a.__or__(b)
assert 1 in c
assert 2 in c
assert 3 in c
assert 4 in c
assert 5 in c
d = a | b
assert 1 in c
assert 2 in c
assert 3 in c
assert 4 in c
assert 5 in c
doc="__sub__"
a = {1, 2, 3}
b = {2, 3, 4, 5}
c = a.__sub__(b)
d = b.__sub__(a)
assert 1 in c
assert 4 in d
assert 5 in d
e = a - b
f = b - a
assert 1 in c
assert 4 in d
assert 5 in d
doc="__xor__"
a = {1, 2, 3}
b = {2, 3, 4, 5}
c = a.__xor__(b)
assert 1 in c
assert 4 in c
assert 5 in c
d = a ^ b
assert 1 in c
doc="__repr__"
a = {1, 2, 3}
b = a.__repr__()
assert "{" in b
assert "1" in b
assert "2" in b
assert "3" in b
assert "}" in b
doc="set"
a = set([1,2,3])
b = set("set")
c = set((4,5))
assert len(a) == 3
assert len(b) == 3
assert len(c) == 2
assert 1 in a
assert 2 in a
assert 3 in a
assert "s" in b
assert "e" in b
assert "t" in b
assert 4 in c
assert 5 in c
doc="add"
a = set()
a.add(1)
a.add(2)
a.add(3)
assert len(a) == 3
assert 1 in a
assert 2 in a
assert 3 in a
assert 4 not in a
assertRaises(TypeError, lambda: a.add())
doc="__eq__, __ne__"
a = set([1,2,3])
assert a.__eq__(3) != True
assert a.__ne__(3) != False
assert a.__ne__(3) != True
assert a.__ne__(3) != False # This part should be changed in comparison with NotImplemented
assert a.__ne__(set()) == True
assert a.__eq__({1,2,3}) == True
assert a.__ne__({1,2,3}) == False
doc="finished"
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.