forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request lcompilers#2213 from Smit-create/i-2131
ASR: Support chained CompareOp
- Loading branch information
Showing
6 changed files
with
179 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from lpython import i32 | ||
|
||
def f(): | ||
x: i32 = 2 | ||
y: i32 = 1 | ||
z: i32 = 1 | ||
t: i32 = 1 | ||
assert x > y == z | ||
assert not (x == y == z) | ||
assert y == z == t != x | ||
assert x > y == z >= t | ||
t = 0 | ||
assert x > y == z >= t | ||
t = 4 | ||
assert not (x > y == z >= t) | ||
assert t > x > y == z | ||
assert 3 > 2 >= 0 <= 6 | ||
assert t > y < x | ||
assert not (2 == 3 > 4) | ||
|
||
|
||
f() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from lpython import (i8, i32, i64, f32, f64, | ||
dataclass | ||
) | ||
from numpy import (empty, | ||
int8, | ||
) | ||
|
||
# test issue 2131 | ||
|
||
@dataclass | ||
class Foo: | ||
a : i8[4] = empty(4, dtype=int8) | ||
dim : i32 = 4 | ||
|
||
def trinary_majority(x : Foo, y : Foo, z : Foo) -> Foo: | ||
foo : Foo = Foo() | ||
|
||
assert foo.dim == x.dim == y.dim == z.dim | ||
|
||
return foo | ||
|
||
|
||
t1 : Foo = Foo() | ||
t1.a = empty(4, dtype=int8) | ||
|
||
t2 : Foo = Foo() | ||
t2.a = empty(4, dtype=int8) | ||
|
||
t3 : Foo = Foo() | ||
t3.a = empty(4, dtype=int8) | ||
|
||
r1 : Foo = trinary_majority(t1, t2, t3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.