Skip to content

Commit 8e97202

Browse files
committed
Add rudimentary test for vect in 1.4
1 parent 4d17335 commit 8e97202

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

test/1.4/errors/T_ENLST.dml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
© 2025 Intel Corporation
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
dml 1.4;
6+
7+
provisional simics_util_vect;
8+
9+
device test;
10+
11+
import "internal.dml";
12+
13+
method init() {
14+
local uint8 arr[3];
15+
/// ERROR ENLST
16+
foreach x in (arr) {
17+
}
18+
local int vect v;
19+
// this was allowed in DML 1.2
20+
/// ERROR ENLST
21+
foreach i in (v) {
22+
}
23+
}

test/1.4/misc/T_vect.dml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
© 2025 Intel Corporation
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
dml 1.4;
6+
7+
provisional simics_util_vect;
8+
9+
device test;
10+
11+
import "internal.dml";
12+
13+
// Test the basic operations of vect types
14+
method init() {
15+
local int vect v;
16+
VINIT(v);
17+
VADD(v, 3);
18+
assert VLEN(v) == 1;
19+
assert VELEMSIZE(v) == sizeoftype(int);
20+
VRESIZE(v, 2);
21+
VRESIZE_FREE(v, 1);
22+
VADD(v, 4);
23+
VDELETE_ORDER(v, 0);
24+
assert v[0] == 4;
25+
VREMOVE(v, 0);
26+
VADD(v, 5);
27+
VINSERT(v, 0, 6);
28+
VSETLAST(v, 7);
29+
assert v[1] == 7;
30+
v[1] = 8;
31+
assert v[1] == 8;
32+
VGROW(v, 2);
33+
assert VLEN(v) == 4;
34+
VSHRINK(v, 2);
35+
VTRUNCATE(v, 1);
36+
assert VLEN(v) == 1;
37+
assert cast(VVEC(v), int *)[0] == 6;
38+
local int vect v2;
39+
VCOPY(v2, v);
40+
VCLEAR(v2);
41+
assert VLEN(v2) == 0;
42+
VFREE(v);
43+
VFREE(v2);
44+
}

0 commit comments

Comments
 (0)