Skip to content

Commit 19b22a0

Browse files
committed
Updated reference tests
1 parent c1a7267 commit 19b22a0

15 files changed

+111
-39
lines changed

tests/errors/bindc_03.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11

22
from lpython import c_p_pointer, CPtr, i32, Pointer, i16
3+
from numpy import array
34

45
def fill_A(k: i32, n: i32, b: CPtr) -> None:
5-
nk: i32 = n * k
6-
A: Pointer[i16[nk]] = c_p_pointer(b, i16[k * n])
6+
A: Pointer[i16[:]] = c_p_pointer(b, i16[n * k], array([k * n]))
77
i: i32; j: i32
88
for j in range(k):
99
for i in range(n):
1010
A[j*n+i] = i16((i+j))
11-
12-
def fill_B(k: i32, n: i32, b: CPtr) -> None:
13-
B: Pointer[i16[n * k]] = c_p_pointer(b, i16[k * n])
14-
i: i32; j: i32
15-
for j in range(k):
16-
for i in range(n):
17-
B[j*n+i] = i16((i+j))
18-
19-
def fill_C(k: i32, n: i32, b: CPtr) -> None:
20-
C: Pointer[i16[n]] = c_p_pointer(b, i16[n * k])
21-
i: i32; j: i32
22-
for j in range(k):
23-
for i in range(n):
24-
C[j*n+i] = i16((i+j))

tests/errors/bindc_04.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from lpython import CPtr, i32, Pointer, i16
2+
from numpy import empty, int32
3+
4+
def fill_A(k: i32, n: i32) -> None:
5+
A: i16[n*k] = empty(n*k, dtype=int32)
6+
i: i32; j: i32
7+
for j in range(k):
8+
for i in range(n):
9+
A[j*n+i] = i16((i+j))
10+
11+
def fill_B(k: i32, n: i32) -> None:
12+
B: i16[k*n] = empty(k*n, dtype=int32)
13+
i: i32; j: i32
14+
for j in range(k):
15+
for i in range(n):
16+
B[j*n+i] = i16((i+j))
17+
18+
def fill_C(k: i32, n: i32, b: CPtr) -> None:
19+
nk: i32 = n * k
20+
C: i16[nk] = empty(nk, dtype=int32)
21+
i: i32; j: i32
22+
for j in range(k):
23+
for i in range(n):
24+
C[j*n+i] = i16((i+j))

tests/errors/func_06.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def init_X(m:i32, n: i32, b: CPtr, m: i32) -> None:
2-
B: Pointer[i16[m*n]] = c_p_pointer(b, i16[m*n])
2+
B: Pointer[i16[m*n]] = c_p_pointer(b, i16[m*n], array([m*n]))
33
i: i32
44
j: i32
55
for i in range(m):

tests/reference/asr-bindc_02-bc1a7ea.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"basename": "asr-bindc_02-bc1a7ea",
33
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
44
"infile": "tests/../integration_tests/bindc_02.py",
5-
"infile_hash": "f01761bc86ab282ba20778efe62f227b36929c0232cf5343588b5a85",
5+
"infile_hash": "a29f0f269c494419077ca8725e7c2d2dc7a5b4964d5c909347f1caa4",
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-bindc_02-bc1a7ea.stdout",
9-
"stdout_hash": "675347588ab9699bcbef6f6b7a36d2cbd85cfbf25170519093a3c889",
9+
"stdout_hash": "a84c81209f918df8b469a9249361ac3b7237cf0967e8dc0800279ff9",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-bindc_02-bc1a7ea.stdout

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,24 @@
3535
[(CPtrToPointer
3636
(Var 204 queries)
3737
(Var 204 x)
38-
()
39-
()
38+
(ArrayConstant
39+
[(IntegerConstant 1 (Integer 4))]
40+
(Array
41+
(Integer 4)
42+
[(()
43+
())]
44+
)
45+
RowMajor
46+
)
47+
(ArrayConstant
48+
[(IntegerConstant 0 (Integer 4))]
49+
(Array
50+
(Integer 4)
51+
[(()
52+
())]
53+
)
54+
RowMajor
55+
)
4056
)
4157
(Print
4258
()
@@ -189,8 +205,8 @@
189205
(Pointer
190206
(Array
191207
(Integer 2)
192-
[((IntegerConstant 0 (Integer 4))
193-
(IntegerConstant 2 (Integer 4)))]
208+
[(()
209+
())]
194210
)
195211
)
196212
()
@@ -204,8 +220,8 @@
204220
(Pointer
205221
(Array
206222
(Integer 2)
207-
[((IntegerConstant 0 (Integer 4))
208-
(IntegerConstant 2 (Integer 4)))]
223+
[(()
224+
())]
209225
)
210226
)
211227
()
@@ -286,8 +302,24 @@
286302
(CPtrToPointer
287303
(Var 201 yq)
288304
(Var 201 yptr1)
289-
()
290-
()
305+
(ArrayConstant
306+
[(IntegerConstant 2 (Integer 4))]
307+
(Array
308+
(Integer 4)
309+
[(()
310+
())]
311+
)
312+
RowMajor
313+
)
314+
(ArrayConstant
315+
[(IntegerConstant 0 (Integer 4))]
316+
(Array
317+
(Integer 4)
318+
[(()
319+
())]
320+
)
321+
RowMajor
322+
)
291323
)
292324
(Print
293325
()

tests/reference/asr-bindc_03-95dbba7.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"basename": "asr-bindc_03-95dbba7",
33
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
44
"infile": "tests/errors/bindc_03.py",
5-
"infile_hash": "966305cef9890644f613e81f7405e694af6fa13e1b06f0e3e08782bb",
5+
"infile_hash": "68e9bc4105ff94df854ee89163425cdc8fd26bcb5615938f6993985c",
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": null,
99
"stdout_hash": null,
1010
"stderr": "asr-bindc_03-95dbba7.stderr",
11-
"stderr_hash": "bd49feaada7484eafec316056295c58526a05d426d1a28f1bb5d8b93",
11+
"stderr_hash": "c883db0632bbc273091e912f2e87f9530b662185953c2869bc96ed8f",
1212
"returncode": 2
1313
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
semantic error: Only those local variables which can be reduced to compile time constant should be used in dimensions of an array.
2-
--> tests/errors/bindc_03.py:6:20
1+
semantic error: Target type specified in c_p_pointer must have deferred shape.
2+
--> tests/errors/bindc_03.py:6:5
33
|
4-
6 | A: Pointer[i16[nk]] = c_p_pointer(b, i16[k * n])
5-
| ^^
4+
6 | A: Pointer[i16[:]] = c_p_pointer(b, i16[n * k], array([k * n]))
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "asr-bindc_04-06bd800",
3+
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
4+
"infile": "tests/errors/bindc_04.py",
5+
"infile_hash": "cf66037fcd7e8cfdd63dc5800b73e5c398afda99cf83ed51a6e70c51",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": null,
9+
"stdout_hash": null,
10+
"stderr": "asr-bindc_04-06bd800.stderr",
11+
"stderr_hash": "3468ddf2bd723ff316c68d930a74ca8cad2dc3b4458bee1028752848",
12+
"returncode": 2
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
semantic error: Only those local variables which can be reduced to compile time constant should be used in dimensions of an array.
2+
--> tests/errors/bindc_04.py:20:12
3+
|
4+
20 | C: i16[nk] = empty(nk, dtype=int32)
5+
| ^^

tests/reference/asr-func_06-62e738c.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"basename": "asr-func_06-62e738c",
33
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
44
"infile": "tests/errors/func_06.py",
5-
"infile_hash": "2b8a5fa5d38ad35eeec67177ab8848255901548fe929c964a9eefef1",
5+
"infile_hash": "eed0fcf15f1964c916df4aa9bc4fab78f74f87243a42549a99234b7b",
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": null,

0 commit comments

Comments
 (0)