Skip to content

Commit

Permalink
Merge pull request #137 from obeis/add-fn-ui-tests
Browse files Browse the repository at this point in the history
Add ui tests for functions
  • Loading branch information
nikomatsakis authored Sep 18, 2023
2 parents f9a50cb + da8c57b commit 1608cc2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
4 changes: 1 addition & 3 deletions crates/formality-check/src/fns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use formality_rust::{
grammar::{Fn, FnBoundData},
prove::ToWcs,
};
use formality_types::{
grammar::{Fallible, Wcs},
};
use formality_types::grammar::{Fallible, Wcs};

use crate::Check;

Expand Down
1 change: 1 addition & 0 deletions tests/ui/fn/lifetime.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Error: failed to prove {@ wf((rigid &(shared) !lt_1 !ty_2))} given {}, got {}
7 changes: 7 additions & 0 deletions tests/ui/fn/lifetime.πŸ”¬
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Test lifetimes on function
[
crate Foo {
// fn one_lt_arg<'a, T>(_: &'a T) -> () {}
fn one_lt_arg<lt a, ty T>(&a T) -> () where [] { trusted }
}
]
20 changes: 20 additions & 0 deletions tests/ui/fn/ok.πŸ”¬
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Test functions, function's arguments, and function's returns
//@check-pass
[
crate Foo {
// fn simple_fn() {}
fn simple_fn<>() -> () where [] { trusted }

// fn one_arg<T>(_: T) {}
fn one_arg<ty T>(T) -> () where [] { trusted }

// fn one_ret<T>(_: T) {}
fn one_ret<ty T>() -> T where [] { trusted }

// fn arg_ret<T, U>(_: T) -> U {}
fn arg_ret<ty T, ty U>(T) -> U where [] { trusted }

// fn multi_arg_ret<T, Y, U, I>(_: T, _: Y) -> (U, I) {}
fn multi_arg_ret<ty T, ty Y, ty U, ty I>(T, Y) -> (U, I) where [] { trusted }
}
]

0 comments on commit 1608cc2

Please sign in to comment.