Skip to content

Commit 1608cc2

Browse files
authored
Merge pull request #137 from obeis/add-fn-ui-tests
Add ui tests for functions
2 parents f9a50cb + da8c57b commit 1608cc2

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

crates/formality-check/src/fns.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use formality_rust::{
33
grammar::{Fn, FnBoundData},
44
prove::ToWcs,
55
};
6-
use formality_types::{
7-
grammar::{Fallible, Wcs},
8-
};
6+
use formality_types::grammar::{Fallible, Wcs};
97

108
use crate::Check;
119

tests/ui/fn/lifetime.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Error: failed to prove {@ wf((rigid &(shared) !lt_1 !ty_2))} given {}, got {}

tests/ui/fn/lifetime.🔬

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Test lifetimes on function
2+
[
3+
crate Foo {
4+
// fn one_lt_arg<'a, T>(_: &'a T) -> () {}
5+
fn one_lt_arg<lt a, ty T>(&a T) -> () where [] { trusted }
6+
}
7+
]

tests/ui/fn/ok.🔬

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Test functions, function's arguments, and function's returns
2+
//@check-pass
3+
[
4+
crate Foo {
5+
// fn simple_fn() {}
6+
fn simple_fn<>() -> () where [] { trusted }
7+
8+
// fn one_arg<T>(_: T) {}
9+
fn one_arg<ty T>(T) -> () where [] { trusted }
10+
11+
// fn one_ret<T>(_: T) {}
12+
fn one_ret<ty T>() -> T where [] { trusted }
13+
14+
// fn arg_ret<T, U>(_: T) -> U {}
15+
fn arg_ret<ty T, ty U>(T) -> U where [] { trusted }
16+
17+
// fn multi_arg_ret<T, Y, U, I>(_: T, _: Y) -> (U, I) {}
18+
fn multi_arg_ret<ty T, ty Y, ty U, ty I>(T, Y) -> (U, I) where [] { trusted }
19+
}
20+
]

0 commit comments

Comments
 (0)