Skip to content

Commit 77090c3

Browse files
committed
Simplify ExprIoEofBits, adjust Python test specs
1 parent fca4f1d commit 77090c3

File tree

4 files changed

+24
-49
lines changed

4 files changed

+24
-49
lines changed

formats/expr_io_eof_bits.ksy

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,12 @@ seq:
99
- id: bar
1010
type: b4
1111
if: not _io.eof
12-
# `_io.eof` is expected to be true, so we "assert" it like this - if `_io.eof`
13-
# is false, it will attempt to consume 8 bytes, which would trigger a EOF
14-
# exception.
15-
- id: assert_io_eof_before_baz
16-
size: '_io.eof ? 0 : 8'
17-
18-
# 0 bits available at this point. When parsing, this is basically guaranteed
19-
# to fail with EOF exception immediately (because it would translate to
20-
# requesting more bytes, which are not available). But when writing, it
21-
# would succeed until an attempt to align the stream to a byte position is
22-
# done - which should happen at the latest when the stream is closed.
12+
# EOF reached here
2313
- id: baz
24-
type: b3
25-
26-
# `_io.eof` is expected to be true, so we "assert" it like this - if `_io.eof`
27-
# is false, it will attempt to consume 8 bytes, which would trigger a EOF
28-
# exception.
29-
- id: assert_io_eof_after_baz
30-
size: 8
14+
type: b16
15+
if: not _io.eof
16+
- id: align
17+
size: 0
18+
- id: qux
19+
type: b16
3120
if: not _io.eof

spec/ks/expr_io_eof_bits.kst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
id: expr_io_eof_bits
22
data: nav_parent_switch.bin
3-
exception: EndOfStreamError
4-
# asserts:
5-
# - actual: foo
6-
# expected: 0x01_42_f
7-
# - actual: bar
8-
# expected: 0xf
3+
asserts:
4+
- actual: foo
5+
expected: 0x01_42_f
6+
- actual: bar
7+
expected: 0xf
8+
- actual: baz
9+
expected: 'null'
10+
- actual: align
11+
expected: '[].as<bytes>'
12+
- actual: qux
13+
expected: 'null'

spec/python/spec/test_expr_io_eof_bits.py

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/python/specwrite/test_expr_io_eof_bits.py

Lines changed: 2 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)