Skip to content

Commit 727821e

Browse files
committed
Add tests for array types
1 parent 8d62637 commit 727821e

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

tests/test/arrays.rs

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
use super::*;
2+
3+
#[test]
4+
fn arrays_are_sized_if_element_sized() {
5+
test! {
6+
program {
7+
#[lang(sized)]
8+
trait Sized { }
9+
}
10+
11+
goal {
12+
forall<const N> {
13+
[u32; N]: Sized
14+
}
15+
} yields {
16+
"Unique"
17+
}
18+
19+
}
20+
}
21+
22+
#[test]
23+
fn arrays_are_not_sized_if_element_not_sized() {
24+
test! {
25+
program {
26+
#[lang(sized)]
27+
trait Sized { }
28+
}
29+
30+
goal {
31+
forall<const N, T> {
32+
[[T]; N]: Sized
33+
}
34+
} yields {
35+
"No possible solution"
36+
}
37+
}
38+
}
39+
40+
#[test]
41+
fn arrays_are_copy_if_element_copy() {
42+
test! {
43+
program {
44+
#[lang(copy)]
45+
trait Copy { }
46+
}
47+
48+
goal {
49+
forall<const N> {
50+
[u32; N]: Copy
51+
}
52+
} yields {
53+
"Unique"
54+
}
55+
}
56+
}
57+
58+
#[test]
59+
fn arrays_are_not_copy_if_element_not_copy() {
60+
test! {
61+
program {
62+
#[lang(copy)]
63+
trait Copy { }
64+
65+
struct Foo { }
66+
}
67+
68+
goal {
69+
forall<const N> {
70+
[Foo; N]: Copy
71+
}
72+
} yields {
73+
"No possible solution"
74+
}
75+
}
76+
}
77+
78+
#[test]
79+
fn arrays_are_clone_if_element_clone() {
80+
test! {
81+
program {
82+
#[lang(clone)]
83+
trait Clone { }
84+
}
85+
86+
goal {
87+
forall<const N> {
88+
[u32; N]: Clone
89+
}
90+
} yields {
91+
"Unique"
92+
}
93+
}
94+
}
95+
96+
#[test]
97+
fn arrays_are_not_clone_if_element_not_clone() {
98+
test! {
99+
program {
100+
#[lang(clone)]
101+
trait Clone { }
102+
103+
struct Foo { }
104+
}
105+
106+
goal {
107+
forall<const N> {
108+
[Foo; N]: Clone
109+
}
110+
} yields {
111+
"No possible solution"
112+
}
113+
}
114+
}
115+
116+
#[test]
117+
fn arrays_are_well_formed() {
118+
test! {
119+
program { }
120+
121+
goal {
122+
forall<const N, T> {
123+
WellFormed([T; N])
124+
}
125+
} yields {
126+
"Unique"
127+
}
128+
}
129+
}

tests/test/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ fn solve_goal(program_text: &str, goals: Vec<(&str, SolverChoice, TestGoal)>) {
296296
}
297297
}
298298

299+
mod arrays;
299300
mod auto_traits;
300301
mod coherence_goals;
301302
mod coinduction;

0 commit comments

Comments
 (0)