Skip to content

Commit 8b870e8

Browse files
authored
Merge pull request #389 from polystat/fixDjangoAndTodo
Fix django and todo
2 parents 979cbc8 + 26cbb58 commit 8b870e8

File tree

24 files changed

+158
-73
lines changed

24 files changed

+158
-73
lines changed

parser/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ SOFTWARE.
5252
<artifactId>scala-library</artifactId>
5353
<version>${scala.version}</version>
5454
</dependency>
55+
<dependency>
56+
<groupId>junit</groupId>
57+
<artifactId>junit</artifactId>
58+
<version>4.13.2</version>
59+
<scope>test</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.scalatest</groupId>
63+
<artifactId>scalatest_2.13</artifactId>
64+
<version>3.2.10</version>
65+
<scope>test</scope>
66+
</dependency>
5567
</dependencies>
5668
<build>
5769
<plugins>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.polystat.py2eo.parser
2+
3+
import org.junit.Assert.fail
4+
import org.junit.Test
5+
import org.polystat.py2eo.parser.Expression.Ident
6+
import org.polystat.py2eo.parser.Statement.{Assign, Suite}
7+
8+
class MapStatementsTest {
9+
10+
@Test def simpleAssign(): Unit = {
11+
Parse("a = b") match {
12+
case Some(Suite(List(Suite(List(
13+
Assign(List(Ident("a", _), Ident("b", _)), _)
14+
), _)), _)) => ()
15+
case _ => fail()
16+
}
17+
}
18+
19+
@Test def longAssign(): Unit = {
20+
Parse("a = b = c") match {
21+
case Some(Suite(List(Suite(List(
22+
Assign(List(Ident("a", _), Ident("b", _), Ident("c", _)), _)
23+
), _)), _)) => ()
24+
case _ : Any => fail()
25+
}
26+
}
27+
28+
}

transpiler/src/main/eo/preface/pyint.eo

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,14 @@
108108

109109
[x] > mul
110110
xfakeclasses.convert (pyint value) x > p
111+
memory 0 > tmp
111112
seq > @
112113
if.
113114
(xfakeclasses.has-type x (xfakeclasses.pyIntClass))
114-
pyint (value.times (x.value))
115+
seq
116+
tmp.write (value.times (x.value))
117+
tmp
118+
pyint (tmp)
115119
p.fst.mul (p.snd)
116120

117121
[x] > div
@@ -226,7 +230,7 @@
226230
pyfloat (value.as-float) > @
227231

228232
[] > force
229-
value.write val > @
233+
value > @
230234

231235
[] > xto-int
232236
[] > ap

transpiler/src/main/eo/preface/pystring.eo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
123
6565

6666
[] > to-my-array
67-
(goto ((xmyArray.ap (*)).@)).result > a
67+
(goto ((xmyArray.ap (pybool TRUE) (*)).@)).result > a
6868
memory 0 > index
6969
seq > @
7070
(index.lt (value.length)).while

transpiler/src/main/eo/preface/xfakeclasses.eo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
fakeclass 10 > pyListClass
2222
fakeclass 13 > pyStringClass
2323
fakeclass 17 > xpyTypeClass
24+
fakeclass 18 > pyTupleClass
2425

2526
[typ1 typ2] > gt
2627
seq > @

transpiler/src/main/eo/preface/xfilter.eo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
+package preface
22
+alias return preface.return
33
+alias xmyArray preface.xmyArray
4+
+alias pybool preface.pybool
45

56
[] > xfilter
67
[f l] > ap
78
[stackUp] > @
8-
(goto ((xmyArray.ap (*)).@)).result > ans
9+
(goto ((xmyArray.ap (pybool TRUE) (*)).@)).result > ans
910
memory 0 > i
1011
seq > @
1112
(i.lt (l.value.length)).while

transpiler/src/main/eo/preface/xmap.eo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
+package preface
22
+alias return preface.return
33
+alias xmyArray preface.xmyArray
4+
+alias pybool preface.pybool
45

56
[] > xmap
67
[f l] > ap
78
[stackUp] > @
8-
(goto ((xmyArray.ap (*)).@)).result > ans
9+
(goto ((xmyArray.ap (pybool TRUE) (*)).@)).result > ans
910
memory 0 > i
1011
seq > @
1112
(i.lt (l.value.length)).while

transpiler/src/main/eo/preface/xmyArray.eo

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
+alias xAssertionError preface.xAssertionError
1313

1414
[] > xmyArray
15-
[initValue] > ap
15+
[is-list initValue] > ap
1616
[stackUp] > @
1717
cage result > pResult
1818
[] > result
1919
cage initValue > value
20-
xfakeclasses.pyListClass > x__class__
20+
is-list.if (xfakeclasses.pyListClass) (xfakeclasses.pyTupleClass) > x__class__
2121
[] > to-my-array
2222
pResult > @
2323
[x] > with-value
24-
(goto ((xmyArray.ap x).@)).result > @
24+
(goto ((xmyArray.ap is-list x).@)).result > @
2525
[] > xlength
2626
[self] > ap
2727
[stackUp] > @
@@ -52,7 +52,7 @@
5252
[self what] > ap
5353
[stackUp] > @
5454
memory FALSE > removed
55-
(goto ((xmyArray.ap (*)).@)).result > accum
55+
(goto ((xmyArray.ap is-list (*)).@)).result > accum
5656
memory 0 > i
5757
seq > @
5858
(i.lt (self.value.length)).while
@@ -77,7 +77,7 @@
7777
memory TRUE > acc
7878
memory 0 > pos
7979
if. > res
80-
((x.x__class__.eq (xfakeclasses.pyListClass)).value.and (value.length.eq (x.value.length)))
80+
((x.x__class__.eq (is-list.if (xfakeclasses.pyListClass) (xfakeclasses.pyTupleClass))).value.and (value.length.eq (x.value.length)))
8181
seq
8282
(acc.and (pos.lt (value.length))).while
8383
[unused]

transpiler/src/main/eo/preface/xmyMap.eo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
[] > xkeys
128128
[self] > ap
129129
[stackUp] > @
130-
(goto ((xmyArray.ap (*)).@)).result > accum
130+
(goto ((xmyArray.ap (pybool TRUE) (*)).@)).result > accum
131131
memory 0 > i
132132
seq > @
133133
(i.lt (value.length)).while
@@ -143,7 +143,7 @@
143143
[] > xkeys-internal
144144
[] > ap
145145
[stackUp] > @
146-
(goto ((xmyArray.ap (*)).@)).result > accum
146+
(goto ((xmyArray.ap (pybool TRUE) (*)).@)).result > accum
147147
memory 0 > i
148148
seq > @
149149
(i.lt (value.length)).while
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
+package preface
2+
+alias xfakeclasses preface.xfakeclasses
3+
4+
[] > xtuple
5+
xfakeclasses.pyTupleClass > @
6+

0 commit comments

Comments
 (0)