-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend well-formedness check of ADTs to include where-clauses (#148)
* Extend well-formedness check of ADTs to include where-clauses * Update adt_wf.rs --------- Co-authored-by: Niko Matsakis <[email protected]>
- Loading branch information
1 parent
d5825b0
commit 3691f7c
Showing
5 changed files
with
124 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod adt_wf; | ||
mod eq_assumptions; | ||
mod eq_partial_eq; | ||
mod exists_constraints; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use expect_test::expect; | ||
use formality_core::test; | ||
use formality_types::{ | ||
grammar::{Parameter, Relation, Wcs}, | ||
rust::term, | ||
}; | ||
|
||
use crate::{decls::Decls, prove::prove}; | ||
|
||
fn decls() -> Decls { | ||
Decls { | ||
trait_decls: vec![term("trait Foo<ty Self> where {}")], | ||
impl_decls: vec![term("impl<> Foo(u32) where {}")], | ||
adt_decls: vec![term("adt X<ty T> where {Foo(T)}")], | ||
..Decls::empty() | ||
} | ||
} | ||
|
||
#[test] | ||
fn well_formed_adt() { | ||
let assumptions: Wcs = Wcs::t(); | ||
let goal: Parameter = term("X<u32>"); | ||
let constraints = prove(decls(), (), assumptions, Relation::WellFormed(goal)); | ||
expect![[r#" | ||
{ | ||
Constraints { | ||
env: Env { | ||
variables: [], | ||
coherence_mode: false, | ||
}, | ||
known_true: true, | ||
substitution: {}, | ||
}, | ||
} | ||
"#]] | ||
.assert_debug_eq(&constraints); | ||
} | ||
|
||
#[test] | ||
fn not_well_formed_adt() { | ||
let assumptions: Wcs = Wcs::t(); | ||
let goal: Parameter = term("X<u64>"); | ||
let constraints = prove(decls(), (), assumptions, Relation::WellFormed(goal)); | ||
expect![[r#" | ||
{} | ||
"#]] | ||
.assert_debug_eq(&constraints); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters