Skip to content

Commit 5f19626

Browse files
committed
added more tests
1 parent 48ad126 commit 5f19626

File tree

2 files changed

+232
-0
lines changed

2 files changed

+232
-0
lines changed

sandbox/div0.eo

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
+package org.eolang
2+
3+
[] > div0
4+
100.div 0 > @

sandbox/py2eoTest.eo

+228
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
+package org.eolang
2+
+alias goto org.eolang.goto
3+
+alias stdout org.eolang.io.stdout
4+
+alias sprintf org.eolang.txt.sprintf
5+
+alias cage org.eolang.cage
6+
+junit
7+
8+
[unused] > py2eoTest
9+
100.div 0 > @
10+
[] > raiseNothing
11+
[] > x__class__
12+
(pyint 0) > x__id__
13+
14+
[] > raiseEmpty
15+
[] > x__class__
16+
(pyint 4) > x__id__
17+
18+
[val] > pybool
19+
20+
memory val > value
21+
22+
fakeclasses.pyBoolClass > x__class__
23+
24+
[x] > neq
25+
pybool (x.value.neq value) > @
26+
27+
[x] > eq
28+
pybool (x.value.eq value) > @
29+
30+
[] > not
31+
pybool (value.not) > @
32+
33+
[x] > or
34+
pybool (value.or (x.value)) > @
35+
36+
[x] > xor
37+
pybool (value.xor (x.value)) > @
38+
39+
[x] > and
40+
pybool (value.and (x.value)) > @
41+
42+
[t f] > if
43+
value.if t f > @
44+
45+
[f] > while
46+
value.while f > @
47+
48+
[] > as-string
49+
value.as-string > @
50+
51+
[] > force
52+
value.write val > @
53+
54+
value > @
55+
56+
[] > newUID
57+
memory 12 > cur
58+
[unused] > apply
59+
seq > @
60+
cur.write (cur.plus (1))
61+
(pyint cur)
62+
63+
[value] > pyfloat
64+
65+
fakeclasses.pyFloatClass > x__class__
66+
67+
[x] > with-value
68+
pyfloat x > @
69+
70+
[x] > eq
71+
fakeclasses.convert (pyfloat value) x > p
72+
seq > @
73+
if.
74+
(fakeclasses.has-type x (fakeclasses.pyFloatClass))
75+
pybool (value.eq (x.value))
76+
p.fst.eq (p.snd)
77+
78+
[x] > mkCopy
79+
x' > copy
80+
copy.< > @
81+
82+
[res] > return
83+
res > result
84+
[] > x__class__
85+
(pyint 3) > x__id__
86+
87+
[] > xZeroDivisionError
88+
pyint 12 > x__id__
89+
[] > apply
90+
[stackUp] > @
91+
cage result > pResult
92+
[] > result
93+
xZeroDivisionError > x__class__
94+
stackUp.forward (return pResult) > @
95+
96+
[] > fakeclasses
97+
[xid] > fakeclass
98+
newUID.apply 0 > xidnormal
99+
pyint xid > x__id__
100+
[x] > eq
101+
pybool (xid.eq (x.xid)) > @
102+
103+
fakeclass 5 > pyBoolClass
104+
fakeclass 6 > pyIntClass
105+
fakeclass 7 > pyFloatClass
106+
fakeclass 8 > pyComplexClass
107+
fakeclass 13 > pyStringClass
108+
109+
[typ1 typ2] > gt
110+
seq > @
111+
typ1.xid.gt (typ2.xid)
112+
113+
[obj typ] > has-type
114+
obj.x__class__.eq typ > @
115+
116+
[obj dst] > convert-to
117+
seq > @
118+
stdout (sprintf "%s" "convert-to\n")
119+
if.
120+
dst.eq pyIntClass
121+
pyint (obj.value)
122+
if.
123+
dst.eq pyFloatClass
124+
seq
125+
stdout "converting to float\n"
126+
obj.as-float
127+
seq
128+
stdout "Oblom\n"
129+
("Oblom")
130+
131+
[fst snd] > pair
132+
133+
[a b] > convert
134+
seq > @
135+
stdout "convert\n"
136+
if.
137+
gt (a.x__class__) (b.x__class__)
138+
seq
139+
pair
140+
a
141+
convert-to b (a.x__class__)
142+
seq
143+
stdout "false\n"
144+
pair
145+
convert-to a (b.x__class__)
146+
b
147+
148+
[val] > pyint
149+
memory val > value
150+
151+
fakeclasses.pyIntClass > x__class__
152+
153+
[x] > with-value
154+
pyint x > @
155+
156+
[x] > eq
157+
fakeclasses.convert (pyint value) x > p
158+
seq > @
159+
if.
160+
(fakeclasses.has-type x (fakeclasses.pyIntClass))
161+
pybool (value.eq (x.value))
162+
p.fst.eq (p.snd)
163+
164+
[x] > float-div
165+
fakeclasses.convert (pyint value) x > p
166+
seq > @
167+
if.
168+
(fakeclasses.has-type x (fakeclasses.pyIntClass))
169+
(x.value.eq 0).if
170+
seq
171+
stdout "division by zero\n"
172+
(goto (xZeroDivisionError.apply.@)).result
173+
(return (pyfloat (value.as-float.div (x.value.as-float))))
174+
p.fst.div (p.snd)
175+
176+
[] > apply
177+
[stackUp] > @
178+
[id] > is-exception
179+
id.greater (pyint 3) > @
180+
[id] > is-break-continue-return
181+
(id.greater (pyint 0)).and (id.less (pyint 4)) > @
182+
[] > xbool
183+
[x] > apply
184+
[stackUp] > @
185+
seq > @
186+
stackUp.forward (return x)
187+
123
188+
cage 0 > xcurrent-exception
189+
cage 0 > xexcinexc
190+
cage FALSE > xcaught
191+
newUID > dummy-newUID
192+
fakeclasses.pyFloatClass > xfloat
193+
fakeclasses.pyComplexClass > xcomplex
194+
raiseNothing > dummy-rn
195+
return > dummy-return
196+
raiseEmpty > dummy-raiseEmpty
197+
mkCopy > dummy-mkCopy
198+
xZeroDivisionError > dummy-xZeroDivisionError
199+
cage 0 > tmp
200+
cage 0 > toReturn
201+
cage 0 > assertMe
202+
cage 0 > xtest
203+
seq > @
204+
stdout "div\n"
205+
write.
206+
xtest
207+
[]
208+
[xxNotCopied] > apply
209+
[stackUp] > @
210+
cage 0 > tmp
211+
cage 0 > toReturn
212+
xxNotCopied' > xx
213+
cage 0 > e0
214+
seq > @
215+
stdout "xtest\n"
216+
xx.<
217+
tmp.write (100.div 0)
218+
(tmp.x__class__.x__id__.neq (return.x__class__.x__id__)).if (stackUp.forward tmp) 0
219+
(e0).write (tmp.result)
220+
((e0).<)
221+
toReturn.write ((e0))
222+
stackUp.forward (return toReturn)
223+
123
224+
tmp.write (goto ((((xtest)).apply).@))
225+
(tmp.x__class__.x__id__.neq (return.x__class__.x__id__)).if (stackUp.forward tmp) 0
226+
(assertMe).write (tmp.result)
227+
toReturn.write ((assertMe))
228+
stackUp.forward (return toReturn)

0 commit comments

Comments
 (0)