Skip to content

Commit 09ad33b

Browse files
committed
formats_err: add test for leaking enums
Tests for kaitai-io/kaitai_struct#534 Adds new failing test in compiler: [info] - imports_enum_leaking *** FAILED *** [info] [] [info] did not equal [info] [imports/enum_two.ksy: /seq/0/enum: [info] error: unable to find type 'enum_one', searching from 'enum_two' [info] [info] imports/enum_two.ksy: /instances/instance_one/enum: [info] error: unable to find type 'enum_one', searching from 'enum_two' [info] ] (SimpleMatchers.scala:34)
1 parent 7611f15 commit 09ad33b

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

formats_err/imports/enum_one.ksy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This is a file that is imported in imports_enum_leaking.ksy
2+
meta:
3+
id: enum_one
4+
seq:
5+
- id: something
6+
type: u1
7+
enum: one
8+
enums:
9+
one:
10+
0: zero

formats_err/imports/enum_two.ksy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This is a file that is imported in imports_enum_leaking.ksy
2+
meta:
3+
id: enum_two
4+
# Note: missing import of `enum_one`
5+
seq:
6+
- id: one
7+
type: u1
8+
enum: enum_one::one # Note: `enum_one` is not imported in this spec, so this should cause a compile error
9+
instances:
10+
# Enum resolution in value instances significantly different from enum resolution in other attributes
11+
instance_one:
12+
value: 0
13+
enum: enum_one::one # Note: `enum_one` is not imported in this spec, so this should cause a compile error
14+
enums:
15+
two:
16+
0: zero

formats_err/imports_enum_leaking.ksy

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# imports/enum_two.ksy: /seq/0/enum:
2+
# error: unable to find type 'enum_one', searching from 'enum_two'
3+
#
4+
# imports/enum_two.ksy: /instances/instance_one/enum:
5+
# error: unable to find type 'enum_one', searching from 'enum_two'
6+
#
7+
meta:
8+
id: imports_enum_leaking
9+
imports:
10+
- imports/enum_one
11+
- imports/enum_two
12+
seq:
13+
- id: another_one
14+
type: u1
15+
enum: enum_one::one
16+
- id: another_two
17+
type: u1
18+
enum: enum_two::two
19+
instances:
20+
instance_one:
21+
value: 0
22+
enum: enum_one::one
23+
instance_two:
24+
value: 0
25+
enum: enum_two::two

0 commit comments

Comments
 (0)