Skip to content

Commit

Permalink
Add basic tests for opaque type generics
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwhit committed May 20, 2020
1 parent 97a84ca commit 0918102
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/test/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,61 @@ fn opaque_reveal() {
}
}
}

#[test]
fn opaque_generics_simple() {
test! {
program {
trait Iterator { type Item; }

struct Vec<T> { }
struct Bar { }
impl<T> Iterator for Vec<T> {
type Item = u32;
}

opaque type Foo<X>: Iterator = Vec<X>;
}

goal {
Foo<Bar>: Iterator
} yields {
"Unique; substitution []"
}

}
}

#[test]
fn opaque_generics() {
test! {
program {
trait Iterator { type Item; }

struct Vec<T> { }
struct Bar { }
impl<T> Iterator for Vec<T> {
type Item = T;
}

opaque type Foo<X>: Iterator<Item = X> = Vec<X>;
}

goal {
Foo<Bar>: Iterator<Item = Bar>
} yields {
"Unique; substitution []"
}

goal {
forall<T> {
if (T: Iterator) {
Foo<T>: Iterator<Item = T>
}
}
} yields {
"Unique; substitution []"
}

}
}

0 comments on commit 0918102

Please sign in to comment.