Skip to content

Commit d7c3a51

Browse files
committed
add enum test program, update all smir.json, move some parse tests
1 parent 3a2674c commit d7c3a51

20 files changed

+2851
-193
lines changed

kmir/src/tests/integration/data/exec-smir/arithmetic/arithmetic-unchecked-runs.smir.json

+14-11
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
100,
4141
58,
4242
32,
43-
105,
43+
117,
4444
56,
4545
58,
4646
58,
@@ -54,9 +54,9 @@
5454
101,
5555
100,
5656
95,
57-
115,
58-
117,
59-
98,
57+
97,
58+
100,
59+
100,
6060
32,
6161
99,
6262
97,
@@ -120,7 +120,7 @@
120120
100,
121121
58,
122122
32,
123-
117,
123+
105,
124124
56,
125125
58,
126126
58,
@@ -134,9 +134,9 @@
134134
101,
135135
100,
136136
95,
137-
97,
138-
100,
139-
100,
137+
115,
138+
117,
139+
98,
140140
32,
141141
99,
142142
97,
@@ -237,7 +237,7 @@
237237
}
238238
],
239239
[
240-
38,
240+
37,
241241
{
242242
"NoOpSym": ""
243243
}
@@ -3630,6 +3630,7 @@
36303630
{
36313631
"EnumType": {
36323632
"name": "std::result::Result<T/#0, E/#1>",
3633+
"adt_def": 20,
36333634
"discriminants": [
36343635
[
36353636
0,
@@ -3647,7 +3648,8 @@
36473648
15,
36483649
{
36493650
"StructType": {
3650-
"name": "std::sys::pal::unix::process::process_common::ExitCode"
3651+
"name": "std::sys::pal::unix::process::process_common::ExitCode",
3652+
"adt_def": 13
36513653
}
36523654
}
36533655
],
@@ -3663,7 +3665,8 @@
36633665
17,
36643666
{
36653667
"StructType": {
3666-
"name": "std::process::ExitCode"
3668+
"name": "std::process::ExitCode",
3669+
"adt_def": 15
36673670
}
36683671
}
36693672
],

kmir/src/tests/integration/data/exec-smir/arithmetic/arithmetic.smir.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -2745,6 +2745,7 @@
27452745
{
27462746
"EnumType": {
27472747
"name": "std::result::Result<T/#0, E/#1>",
2748+
"adt_def": 8,
27482749
"discriminants": [
27492750
[
27502751
0,
@@ -2762,7 +2763,8 @@
27622763
15,
27632764
{
27642765
"StructType": {
2765-
"name": "std::sys::pal::unix::process::process_common::ExitCode"
2766+
"name": "std::sys::pal::unix::process::process_common::ExitCode",
2767+
"adt_def": 14
27662768
}
27672769
}
27682770
],
@@ -2778,7 +2780,8 @@
27782780
17,
27792781
{
27802782
"StructType": {
2781-
"name": "std::process::ExitCode"
2783+
"name": "std::process::ExitCode",
2784+
"adt_def": 16
27822785
}
27832786
}
27842787
],

kmir/src/tests/integration/data/exec-smir/arithmetic/unary.smir.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,7 @@
19191919
{
19201920
"EnumType": {
19211921
"name": "std::result::Result<T/#0, E/#1>",
1922+
"adt_def": 15,
19221923
"discriminants": [
19231924
[
19241925
0,
@@ -1936,7 +1937,8 @@
19361937
15,
19371938
{
19381939
"StructType": {
1939-
"name": "std::sys::pal::unix::process::process_common::ExitCode"
1940+
"name": "std::sys::pal::unix::process::process_common::ExitCode",
1941+
"adt_def": 9
19401942
}
19411943
}
19421944
],
@@ -1952,7 +1954,8 @@
19521954
17,
19531955
{
19541956
"StructType": {
1955-
"name": "std::process::ExitCode"
1957+
"name": "std::process::ExitCode",
1958+
"adt_def": 11
19561959
}
19571960
}
19581961
],

kmir/src/tests/integration/data/exec-smir/assign-cast/assign-cast.smir.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -2113,6 +2113,7 @@
21132113
{
21142114
"EnumType": {
21152115
"name": "std::result::Result<T/#0, E/#1>",
2116+
"adt_def": 15,
21162117
"discriminants": [
21172118
[
21182119
0,
@@ -2130,7 +2131,8 @@
21302131
15,
21312132
{
21322133
"StructType": {
2133-
"name": "std::sys::pal::unix::process::process_common::ExitCode"
2134+
"name": "std::sys::pal::unix::process::process_common::ExitCode",
2135+
"adt_def": 9
21342136
}
21352137
}
21362138
],
@@ -2146,7 +2148,8 @@
21462148
17,
21472149
{
21482150
"StructType": {
2149-
"name": "std::process::ExitCode"
2151+
"name": "std::process::ExitCode",
2152+
"adt_def": 7
21502153
}
21512154
}
21522155
],

kmir/src/tests/integration/data/exec-smir/call-with-args/main-a-b-with-int.smir.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
}
5959
],
6060
[
61-
32,
61+
29,
6262
{
6363
"NoOpSym": ""
6464
}
@@ -1707,6 +1707,7 @@
17071707
{
17081708
"EnumType": {
17091709
"name": "std::result::Result<T/#0, E/#1>",
1710+
"adt_def": 11,
17101711
"discriminants": [
17111712
[
17121713
0,
@@ -1724,7 +1725,8 @@
17241725
15,
17251726
{
17261727
"StructType": {
1727-
"name": "std::sys::pal::unix::process::process_common::ExitCode"
1728+
"name": "std::sys::pal::unix::process::process_common::ExitCode",
1729+
"adt_def": 18
17281730
}
17291731
}
17301732
],
@@ -1740,7 +1742,8 @@
17401742
17,
17411743
{
17421744
"StructType": {
1743-
"name": "std::process::ExitCode"
1745+
"name": "std::process::ExitCode",
1746+
"adt_def": 16
17441747
}
17451748
}
17461749
],

kmir/src/tests/integration/data/exec-smir/enum/enum.118.state

+94
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#![allow(unused)]
2+
#![allow(dead_code)]
3+
enum Letter {
4+
A = 65,
5+
B,
6+
M = 77,
7+
}
8+
9+
#[repr(u16)]
10+
enum WithData {
11+
X = 88,
12+
Y{y:i32} = 89,
13+
Z{y:i16, z: bool} = 90,
14+
ZZ(i8, i8, bool) = 9090,
15+
}
16+
17+
fn main() {
18+
let a = Letter::A;
19+
20+
let x = WithData::X;
21+
let y = WithData::Y { y: 42};
22+
let z = WithData::Z { y:42, z: false };
23+
let zz = WithData::ZZ(42, 43, true);
24+
25+
let mut zzz : WithData;
26+
27+
if let WithData::Y{y} = x {
28+
let zzz = WithData::Y{y};
29+
}
30+
31+
if let Letter::A = a {
32+
let zzz = a;
33+
}
34+
35+
match zz {
36+
WithData::Y{y:_} =>
37+
zzz = y,
38+
WithData::Z{y:_, z} =>
39+
zzz = WithData::ZZ(0, 0, z),
40+
_ =>
41+
zzz = x,
42+
}
43+
44+
}

0 commit comments

Comments
 (0)