Skip to content

Commit d3ac315

Browse files
committed
add ability to test where-clause, test mirror norm
Whoops, we aren't adding the required WF predicates. Gotta deal with implied bounds.
1 parent ae38718 commit d3ac315

File tree

16 files changed

+126
-73
lines changed

16 files changed

+126
-73
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ expect-test = "1.4.0"
1414
formality-macros = { version = "0.1.0", path = "crates/formality-macros" }
1515
formality-core = { version = "0.1.0", path = "crates/formality-core" }
1616

17+
1718
[dependencies]
1819
anyhow = "1"
1920
clap = { version = "4.0.9", features = ["derive"] }
2021
formality-rust = { version = "0.1.0", path = "crates/formality-rust" }
2122
formality-types = { version = "0.1.0", path = "crates/formality-types" }
2223
formality-check = { version = "0.1.0", path = "crates/formality-check" }
24+
formality-prove = { version = "0.1.0", path = "crates/formality-prove" }
2325

2426
[workspace]
2527
members = [

crates/formality-check/src/impls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ impl super::Check<'_> {
157157
Ok(())
158158
}
159159

160+
#[context("check_associated_ty_value({impl_value:?})")]
160161
fn check_associated_ty_value(
161162
&self,
162163
impl_env: &Env,

crates/formality-prove/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ mod prove;
66

77
pub use decls::*;
88
pub use prove::prove;
9+
pub use prove::Constraints;
910
pub use prove::Env;
1011

1112
#[cfg(test)]
1213
mod test;
14+
15+
pub mod test_util;

crates/formality-prove/src/test.rs

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
use std::sync::Arc;
2-
3-
use formality_macros::term;
4-
use formality_types::{
5-
collections::Set,
6-
grammar::{Binder, Wcs},
7-
};
8-
9-
use crate::{
10-
decls::Decls,
11-
prove::{prove, Constraints, Env},
12-
};
13-
141
mod eq_assumptions;
152
mod eq_partial_eq;
163
mod exists_constraints;
@@ -20,50 +7,3 @@ mod magic_copy;
207
mod occurs_check;
218
mod simple_impl;
229
mod universes;
23-
24-
#[term]
25-
enum TestAssertion {
26-
#[grammar(coherence_mode $v0)]
27-
CoherenceMode(Arc<TestAssertion>),
28-
#[grammar(forall $v0)]
29-
ForAll(Binder<Arc<TestAssertion>>),
30-
#[grammar(exists $v0)]
31-
Exists(Binder<Arc<TestAssertion>>),
32-
#[grammar($v0 => $v1)]
33-
Prove(Wcs, Wcs),
34-
}
35-
36-
/// `t` represents some set of existential bindings combined with (assumptions, goals).
37-
/// Returns the constraints that result from proving assumptions/goals. These will reference
38-
/// existential variables created for the bindings, so they're really just suitable for
39-
/// using with expect.
40-
fn test_prove(decls: Decls, mut assertion: Arc<TestAssertion>) -> Set<Constraints> {
41-
let mut env = Env::default();
42-
43-
loop {
44-
match &*assertion {
45-
TestAssertion::ForAll(binder) => {
46-
let (env1, subst) = env.universal_substitution(binder);
47-
let assertion1 = binder.instantiate_with(&subst).unwrap();
48-
env = env1;
49-
assertion = assertion1;
50-
}
51-
52-
TestAssertion::Exists(binder) => {
53-
let (env1, subst) = env.existential_substitution(binder);
54-
let assertion1 = binder.instantiate_with(&subst).unwrap();
55-
env = env1;
56-
assertion = assertion1;
57-
}
58-
59-
TestAssertion::Prove(assumptions, goals) => {
60-
return prove(decls, env, assumptions, goals);
61-
}
62-
63-
TestAssertion::CoherenceMode(assertion1) => {
64-
env = env.with_coherence_mode(true);
65-
assertion = assertion1.clone();
66-
}
67-
}
68-
}
69-
}

crates/formality-prove/src/test/eq_assumptions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use formality_types::parse::term;
44

55
use crate::decls::Decls;
66

7-
use super::test_prove;
7+
use crate::test_util::test_prove;
88

99
#[test]
1010
fn test_a() {

crates/formality-prove/src/test/exists_constraints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use formality_types::parse::term;
44

55
use crate::decls::Decls;
66

7-
use super::test_prove;
7+
use crate::test_util::test_prove;
88

99
/// Simple example decls consisting only of two trait declarations.
1010
fn decls() -> Decls {

crates/formality-prove/src/test/expanding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use expect_test::expect;
22
use formality_macros::test;
33
use formality_types::parse::term;
44

5-
use crate::decls::Decls;
5+
use crate::{test_util::test_prove, Decls};
66

77
/// Simple example decls consisting only of two trait declarations.
88
fn decls() -> Decls {
@@ -17,7 +17,7 @@ fn decls() -> Decls {
1717
/// There is no U that is equal to all T.
1818
#[test]
1919
fn expanding() {
20-
let constraints = super::test_prove(decls(), term("exists<ty T> {} => {Debug(T)}"));
20+
let constraints = test_prove(decls(), term("exists<ty T> {} => {Debug(T)}"));
2121
expect![[r#"
2222
{
2323
Constraints {

crates/formality-prove/src/test/is_local.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use formality_types::parse::term;
44

55
use crate::decls::Decls;
66

7-
use super::test_prove;
7+
use crate::test_util::test_prove;
88

99
#[test]
1010
fn test_forall_not_local() {

crates/formality-prove/src/test/magic_copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use formality_types::parse::term;
44

55
use crate::decls::Decls;
66

7-
use super::test_prove;
7+
use crate::test_util::test_prove;
88

99
/// Simple example decls consisting only of two trait declarations.
1010
fn decls() -> Decls {

0 commit comments

Comments
 (0)