Skip to content

Commit

Permalink
formats_err: add test for leaking enums
Browse files Browse the repository at this point in the history
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]   ] (SimpleMatchers.scala:34)
  • Loading branch information
Mingun committed Oct 5, 2024
1 parent 7611f15 commit e0a43e1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
10 changes: 10 additions & 0 deletions formats_err/imports/enum_one.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This is a file that is imported in imports_enum_leaking.ksy
meta:
id: enum_one
seq:
- id: something
type: u1
enum: one
enums:
one:
0: zero
16 changes: 16 additions & 0 deletions formats_err/imports/enum_two.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is a file that is imported in imports_enum_leaking.ksy
meta:
id: enum_two
# Note: missing import of `enum_one`
seq:
- id: one
type: u1
enum: enum_one::one # Note: `enum_one` is not imported in this spec, so this should cause a compile error
instances:
# Enum resolution in value instances significantly different from enum resolution in other attributes
instance_one:
value: 0
enum: enum_one::one # Note: `enum_one` is not imported in this spec, so this should cause a compile error
enums:
two:
0: zero
25 changes: 25 additions & 0 deletions formats_err/imports_enum_leaking.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# imports/enum_two.ksy: /seq/0/enum:
# error: unable to find type 'enum_one', searching from 'enum_two'
#
# imports/enum_two.ksy: /instances/instance_one/enum:
# error: unable to find type 'enum_one', searching from 'enum_two'
#
meta:
id: imports_enum_leaking
imports:
- imports/enum_one
- imports/enum_two
seq:
- id: another_one
type: u1
enum: enum_one::one
- id: another_two
type: u1
enum: enum_two::two
instances:
instance_one:
value: 0
enum: enum_one::one
instance_two:
value: 0
enum: enum_two::two

0 comments on commit e0a43e1

Please sign in to comment.