1import smartpy as sp
2
3
4@sp.module
5def main():
6 class C(sp.Contract):
7 def __init__(self):
8 self.data.xy = (0, 0)
9
10 @sp.entrypoint
11 def ep1(self):
12 self.data.xy = (sp.snd(self.data.xy), sp.fst(self.data.xy))
13
14 @sp.entrypoint
15 def ep2(self):
16 self.data.xy = (
17 sp.snd(sp.fst((self.data, ())).xy),
18 sp.fst(sp.fst((self.data, ())).xy),
19 )
20
21 @sp.entrypoint
22 def ep3(self):
23 self.data.xy = (sp.fst(self.data.xy), sp.fst(self.data.xy))
24
25 @sp.entrypoint
26 def ep4(self):
27 self.data.xy = (sp.snd(self.data.xy), sp.snd(self.data.xy))
28
29 @sp.entrypoint
30 def ep5(self, params):
31 sp.cast(params, sp.nat)
32 with sp.match(sp.ediv(params, 2)):
33 with None:
34 self.data.xy = (0, 0)
35 with sp.case.Some as s65:
36 self.data.xy = (1, 1)
37
38 @sp.entrypoint
39 def ep6(self, params):
40 sp.cast(params, sp.nat)
41 with sp.match(sp.ediv(params, 2)):
42 with sp.case.Some as s65:
43 self.data.xy = (1, 1)
44 with None:
45 self.data.xy = (0, 0)
46
47
48@sp.add_test()
49def test():
50 scenario = sp.test_scenario("Misc", main)
51 scenario += main.C()