Skip to content

Commit 35062de

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

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

tests/test/arrays.rs

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
use super::*;
2+
3+
#[test]
4+
fn arrays_are_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_copy_if_element_copy() {
24+
test! {
25+
program {
26+
#[lang(copy)]
27+
trait Copy { }
28+
29+
struct Foo { }
30+
impl Copy for Foo { }
31+
}
32+
33+
goal {
34+
forall<const N> {
35+
[Foo; N]: Copy
36+
}
37+
} yields {
38+
"Unique"
39+
}
40+
}
41+
}
42+
43+
#[test]
44+
fn arrays_are_not_copy_if_element_not_copy() {
45+
test! {
46+
program {
47+
#[lang(copy)]
48+
trait Copy { }
49+
50+
struct Foo { }
51+
}
52+
53+
goal {
54+
forall<const N> {
55+
[Foo; N]: Copy
56+
}
57+
} yields {
58+
"No possible solution"
59+
}
60+
}
61+
}
62+
63+
#[test]
64+
fn arrays_are_clone_if_element_clone() {
65+
test! {
66+
program {
67+
#[lang(clone)]
68+
trait Clone { }
69+
70+
struct Foo { }
71+
impl Clone for Foo { }
72+
}
73+
74+
goal {
75+
forall<const N> {
76+
[Foo; N]: Clone
77+
}
78+
} yields {
79+
"Unique"
80+
}
81+
}
82+
}
83+
84+
#[test]
85+
fn arrays_are_not_clone_if_element_not_clone() {
86+
test! {
87+
program {
88+
#[lang(clone)]
89+
trait Clone { }
90+
91+
struct Foo { }
92+
}
93+
94+
goal {
95+
forall<const N> {
96+
[Foo; N]: Clone
97+
}
98+
} yields {
99+
"No possible solution"
100+
}
101+
}
102+
}
103+
104+
#[test]
105+
fn arrays_are_well_formed() {
106+
test! {
107+
program { }
108+
109+
goal {
110+
forall<const N, T> {
111+
WellFormed([T; N])
112+
}
113+
} yields {
114+
"Unique"
115+
}
116+
}
117+
}

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)