Skip to content

Commit fc72b10

Browse files
committed
Add tests for array types
1 parent 6025184 commit fc72b10

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed

tests/test/arrays.rs

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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> {
32+
[str; 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+
struct Foo { }
48+
impl Copy for Foo { }
49+
}
50+
51+
goal {
52+
forall<const N> {
53+
[Foo; N]: Copy
54+
}
55+
} yields {
56+
"Unique"
57+
}
58+
}
59+
}
60+
61+
#[test]
62+
fn arrays_are_not_copy_if_element_not_copy() {
63+
test! {
64+
program {
65+
#[lang(copy)]
66+
trait Copy { }
67+
68+
struct Foo { }
69+
}
70+
71+
goal {
72+
forall<const N> {
73+
[Foo; N]: Copy
74+
}
75+
} yields {
76+
"No possible solution"
77+
}
78+
}
79+
}
80+
81+
#[test]
82+
fn arrays_are_clone_if_element_clone() {
83+
test! {
84+
program {
85+
#[lang(clone)]
86+
trait Clone { }
87+
88+
struct Foo { }
89+
impl Clone for Foo { }
90+
}
91+
92+
goal {
93+
forall<const N> {
94+
[Foo; N]: Clone
95+
}
96+
} yields {
97+
"Unique"
98+
}
99+
}
100+
}
101+
102+
#[test]
103+
fn arrays_are_not_clone_if_element_not_clone() {
104+
test! {
105+
program {
106+
#[lang(clone)]
107+
trait Clone { }
108+
109+
struct Foo { }
110+
}
111+
112+
goal {
113+
forall<const N> {
114+
[Foo; N]: Clone
115+
}
116+
} yields {
117+
"No possible solution"
118+
}
119+
}
120+
}
121+
122+
#[test]
123+
fn arrays_are_well_formed() {
124+
test! {
125+
program { }
126+
127+
goal {
128+
forall<const N, T> {
129+
WellFormed([T; N])
130+
}
131+
} yields {
132+
"Unique"
133+
}
134+
}
135+
}

tests/test/mod.rs

Lines changed: 1 addition & 0 deletions
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)