Skip to content

Commit 8260367

Browse files
authored
Merge pull request #185 from FullyNonlinear/main
Reinstate test cases for parsing
2 parents b9dbce6 + 34ca4d0 commit 8260367

File tree

1 file changed

+90
-6
lines changed

1 file changed

+90
-6
lines changed

crates/formality-rust/src/test.rs

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#![cfg(test)]
2-
#![cfg(FIXME)]
32

43
use formality_macros::test;
5-
use formality_types::parse::term;
4+
use formality_types::rust::term;
65

76
use crate::grammar::Program;
87

@@ -20,7 +19,45 @@ fn test_parse_rust_like_trait_impl_syntax() {
2019

2120
// Note: the for etc are correctly accounted.
2221
expect_test::expect![[r#"
23-
[crate core { impl <ty, ty> PartialEq < ^ty0_0 > for ^ty0_1 { } }]
22+
Program {
23+
crates: [
24+
Crate {
25+
id: core,
26+
items: [
27+
TraitImpl(
28+
TraitImpl {
29+
safety: Safe,
30+
binder: Binder {
31+
kinds: [
32+
Ty,
33+
Ty,
34+
],
35+
term: TraitImplBoundData {
36+
trait_id: PartialEq,
37+
self_ty: Ty {
38+
data: Variable(
39+
^ty0_1,
40+
),
41+
},
42+
trait_parameters: [
43+
Ty(
44+
Ty {
45+
data: Variable(
46+
^ty0_0,
47+
),
48+
},
49+
),
50+
],
51+
where_clauses: [],
52+
impl_items: [],
53+
},
54+
},
55+
},
56+
),
57+
],
58+
},
59+
],
60+
}
2461
"#]]
2562
.assert_debug_eq(&r);
2663
}
@@ -39,7 +76,22 @@ fn test_parse_rust_like_trait_syntax() {
3976

4077
// Note: two type parameters, and the 0th one is self:
4178
expect_test::expect![[r#"
42-
[crate core { trait Foo <ty, ty> where ^ty0_1 : Bar < ^ty0_0 > { } }]
79+
Program {
80+
crates: [
81+
Crate {
82+
id: core,
83+
items: [
84+
Trait(
85+
Trait {
86+
safety: Safe,
87+
id: Foo,
88+
binder: <ty, ty> where ^ty0_1 : Bar <^ty0_0> { },
89+
},
90+
),
91+
],
92+
},
93+
],
94+
}
4395
"#]]
4496
.assert_debug_eq(&r);
4597
}
@@ -56,9 +108,41 @@ fn test_parse_rust_like_struct_syntax() {
56108
]",
57109
);
58110

59-
// Note: two type parameters, and the 0th one is self:
60111
expect_test::expect![[r#"
61-
[crate core { struct Foo <ty> { a : ^ty0_0 } }]
112+
Program {
113+
crates: [
114+
Crate {
115+
id: core,
116+
items: [
117+
Struct(
118+
Struct {
119+
id: Foo,
120+
binder: Binder {
121+
kinds: [
122+
Ty,
123+
],
124+
term: StructBoundData {
125+
where_clauses: [],
126+
fields: [
127+
Field {
128+
name: Id(
129+
a,
130+
),
131+
ty: Ty {
132+
data: Variable(
133+
^ty0_0,
134+
),
135+
},
136+
},
137+
],
138+
},
139+
},
140+
},
141+
),
142+
],
143+
},
144+
],
145+
}
62146
"#]]
63147
.assert_debug_eq(&r);
64148
}

0 commit comments

Comments
 (0)