This commit is contained in:
KtorZ
2024-03-21 09:44:26 +01:00
committed by Lucas
parent 4f8e900aac
commit bee2b712de
2 changed files with 39 additions and 2 deletions

View File

@@ -1835,6 +1835,30 @@ fn forbid_expect_into_opaque_type_from_data() {
))
}
#[test]
fn allow_expect_into_type_from_data() {
let source_code = r#"
fn bar(n: Data) {
expect a: Option<Int> = n
a
}
"#;
assert!(check(parse(source_code)).is_ok())
}
#[test]
fn allow_expect_into_type_from_data_2() {
let source_code = r#"
fn bar(n: Data) {
expect Some(a): Option<Int> = n
a
}
"#;
assert!(check(parse(source_code)).is_ok())
}
#[test]
fn forbid_expect_into_opaque_type_constructor_without_typecasting_in_module() {
let source_code = r#"
@@ -1985,6 +2009,19 @@ fn allow_expect_on_var_patterns_that_are_opaque() {
assert!(check(parse(source_code)).is_ok())
}
#[test]
fn can_down_cast_to_data_always() {
let source_code = r#"
pub opaque type Foo { x: Int }
pub fn bar(a: Foo) {
let b: Data = a
b
}
"#;
assert!(check(parse(source_code)).is_ok());
}
#[test]
fn correct_span_for_backpassing_args() {
let source_code = r#"