forked from lfortran/lfortran
-
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 lfortran#4604 from HarshitaKalani/sign_01
Throw error for different kind of args in `sign` and update integration test
- Loading branch information
Showing
8 changed files
with
175 additions
and
14 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,72 @@ | ||
program intrinsics_304 | ||
implicit none | ||
integer, parameter :: a1 = sign(1, 1) | ||
integer(8), parameter :: a2 = sign(1, -1) | ||
integer, parameter :: a3 = sign(-13, 0) | ||
integer(8), parameter :: a4 = sign(0, 42) | ||
real, parameter :: a5 = sign(1.425, 3.0) | ||
real(8), parameter :: a6 = sign(1.425, -3.0) | ||
real, parameter :: a7 = sign(1.425, 0.0) | ||
real(8), parameter :: a8 = sign(0.0, -3.0) | ||
|
||
integer, parameter :: ar1(3) = sign([1, 2, 3], [1, 2, 3]) | ||
integer(8), parameter :: ar2(3) = sign([1, -2, 3], -3) | ||
real, parameter :: ar3(3) = sign([1.425, -2.425, 3.425], 3.0) | ||
real(8), parameter :: ar4(3) = sign([1.425, -2.425, 3.425], 3.0) | ||
|
||
integer :: x1 = 123, x2 = -90 | ||
integer(8) :: x3 = 123, x4 = 423 | ||
real :: x5 = 123.0, x6 = -47981 | ||
real(8) :: x7 = 123.0, x8 = 123.0 | ||
|
||
integer :: arr1(3) = [-311, -241, 331], arr2(3) = [1, 2, 3] | ||
real :: arr3(3) = [1.425, -2.425, 3.425], arr4(3) = [1.425, -2.425, 3.425] | ||
|
||
print *, a1 | ||
if (a1 /= 1) error stop | ||
print *, a2 | ||
if (a2 /= -1) error stop | ||
print *, a3 | ||
if (a3 /= 13) error stop | ||
print *, a4 | ||
if (a4 /= 0) error stop | ||
print *, a5 | ||
if (a5 /= 1.425) error stop | ||
print *, a6 | ||
if (a6 /= -1.425) error stop | ||
print *, a7 | ||
if (a7 /= 1.425) error stop | ||
print *, a8 | ||
if (a8 /= -0.0) error stop | ||
|
||
print *, ar1 | ||
if (any(ar1 /= [1, 2, 3])) error stop | ||
print *, ar2 | ||
if (any(ar2 /= [-1, -2, -3])) error stop | ||
print *, ar3 | ||
if (any(ar3 /= [1.42499995e+00, 2.42499995e+00, 3.42499995e+00])) error stop | ||
print *, ar4 | ||
if (any(ar4 /= [1.42499995231628418e+00, 2.42499995231628418e+00, 3.42499995231628418e+00])) error stop | ||
|
||
print *, sign(x1, x2) | ||
if (sign(x1, x2) /= -123) error stop | ||
print *, sign(x3, x4) | ||
if (sign(x3, x4) /= 123) error stop | ||
print *, sign(x5, x6) | ||
if (sign(x5, x6) /= -123.0) error stop | ||
print *, sign(x7, x8) | ||
if (sign(x7, x8) /= 123.0) error stop | ||
|
||
print *, sign(arr1, arr2) | ||
if (any(sign(arr1, arr2) /= [311, 241, 331])) error stop | ||
print *, sign(arr3, arr4) | ||
if (any(sign(arr3, arr4) /= [1.425, -2.425, 3.425])) error stop | ||
|
||
print *, sign(a=-12.,b=0.) | ||
print *, sign(a=-12.,b=1.) | ||
print *, sign(a=-12.,b=-1.) | ||
|
||
if ( .not. sign( a = -12, b = 1 ) == 12 ) error stop | ||
if ( .not. sign( -12, b = 0 ) == 12 ) error stop | ||
if ( .not. sign( -12, -1 ) == -12 ) error stop | ||
end program |
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
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,3 @@ | ||
program main | ||
print *, sign(1, 1_8) | ||
end program |
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,13 @@ | ||
{ | ||
"basename": "asr-sign_01-62b270e", | ||
"cmd": "lfortran --show-asr --no-color {infile} -o {outfile}", | ||
"infile": "tests/errors/sign_01.f90", | ||
"infile_hash": "467c2bd094955c085a80d6f4eb00ad122dfb895a2327a02ae62f1836", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": null, | ||
"stdout_hash": null, | ||
"stderr": "asr-sign_01-62b270e.stderr", | ||
"stderr_hash": "dab94d75469b4260c70326c06698d247c7f9bbe6c0aeebd631d20ab0", | ||
"returncode": 2 | ||
} |
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,5 @@ | ||
semantic error: Kind of all the arguments of Sign must be the same | ||
--> tests/errors/sign_01.f90:2:14 | ||
| | ||
2 | print *, sign(1, 1_8) | ||
| ^^^^^^^^^^^^ |
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