Skip to content

Commit 1213039

Browse files
committed
Added some more tests
1 parent a5686bd commit 1213039

4 files changed

Lines changed: 50 additions & 25 deletions

File tree

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn array_type_empty_fails() {
2323
}
2424

2525
#[test]
26-
fn nested_array_types() {
26+
fn array_type_nested() {
2727
parses_to! {
2828
parser: UnrealScriptParser,
2929
input: "array<array<int>>",
@@ -34,26 +34,4 @@ fn nested_array_types() {
3434
])])
3535
]
3636
}
37-
}
38-
39-
#[test]
40-
fn class_type() {
41-
parses_to!(
42-
parser: UnrealScriptParser,
43-
input: "class<Foo.Bar>",
44-
rule: Rule::class_type,
45-
tokens: [ class_type(0, 14, [ identifier(6, 13) ]) ]
46-
)
47-
}
48-
49-
#[test]
50-
fn class_type_empty_fails() {
51-
fails_with!(
52-
parser: UnrealScriptParser,
53-
input: "class<>",
54-
rule: Rule::class_type,
55-
positives: [Rule::identifier],
56-
negatives: [],
57-
pos: 6
58-
)
59-
}
37+
}

‎tests/parser/class_type.rs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use super::*;
2+
3+
#[test]
4+
fn class_type() {
5+
parses_to!(
6+
parser: UnrealScriptParser,
7+
input: "class<Foo.Bar>",
8+
rule: Rule::class_type,
9+
tokens: [ class_type(0, 14, [ identifier(6, 13) ]) ]
10+
)
11+
}
12+
13+
#[test]
14+
fn class_type_empty_fails() {
15+
fails_with!(
16+
parser: UnrealScriptParser,
17+
input: "class<>",
18+
rule: Rule::class_type,
19+
positives: [Rule::identifier],
20+
negatives: [],
21+
pos: 6
22+
)
23+
}

‎tests/parser/mod.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ mod string_literal;
2121
mod vector_literal;
2222

2323
// Type tests
24-
mod types;
24+
mod array_type;
25+
mod class_type;
2526

2627
// Declaration tests
2728
mod class_declaration;

‎tests/parser/var_declaration.rs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,26 @@ fn var_declaration_all_features() {
143143
]
144144
}
145145
}
146+
147+
#[test]
148+
fn var_declaration_with_inline_struct_type() {
149+
parses_to! {
150+
parser: UnrealScriptParser,
151+
input: "var struct Foo { var int Bar; } Baz;",
152+
rule: Rule::var_declaration,
153+
tokens: [
154+
var_declaration(0, 36, [
155+
type_(4, 31, [
156+
struct_declaration(4, 31, [
157+
unqualified_identifier(11, 14),
158+
struct_var_declaration(17, 29, [
159+
type_(21, 24, [ identifier(21, 24) ]),
160+
var_name(25, 28, [ unqualified_identifier(25, 28) ]),
161+
])
162+
])
163+
]),
164+
var_name(32, 35, [ unqualified_identifier(32, 35) ]),
165+
])
166+
]
167+
}
168+
}

0 commit comments

Comments
 (0)