1
1
mirror of https://github.com/wader/fq.git synced 2024-11-24 03:05:22 +03:00
fq/pkg/interp/testdata/value.fqtest
Mattias Wadman 377af133e0 fqtest: Cleanup path usage
Make cwd for a test script the directory where the script is.
Use relative paths
2022-05-21 20:03:25 +02:00

271 lines
8.1 KiB
Plaintext

# ffmpeg -f lavfi -i sine -t 10ms test.mp3
# test alt //
$ fq -d mp3 '.headers[].frames[0].flags.unsync // 123' test.mp3
123
$ fq -d mp3 '.headers[].frames[0].size // 123' test.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x00| 00 00| ..|.headers[0].frames[0].size: 15
0x10|00 0f |.. |
# test each in decoded order
$ fq -d mp3 '.headers[0][]' test.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x0|49 44 33 |ID3 |.headers[0].magic: "ID3" (valid)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x0| 04 | . |.headers[0].version: 4
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x0| 00 | . |.headers[0].revision: 0
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.headers[0].flags{}:
0x0| 00 | . | unsynchronisation: false
0x0| 00 | . | extended_header: false
0x0| 00 | . | experimental_indicator: false
0x0| 00 | . | unused: 0
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x0| 00 00 00 23 | ...# |.headers[0].size: 35
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.headers[0].frames[0:1]:
0x00| 54 53 53 45 00 00| TSSE..| [0]{}: frame
0x10|00 0f 00 00 03 4c 61 76 66 35 38 2e 34 35 2e 31|.....Lavf58.45.1|
0x20|30 30 00 |00. |
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x20| 00 00 00 00 00 00 00 00 00 00 | .......... |.headers[0].padding: raw bits (all zero)
# TODO: proper buffer_root test
$ fq -d mp3 -i . test.mp3
mp3> .frames[0].header.mpeg_version | (topath | path_to_expr), tovalue, toactual, tosym, todescription
".frames[0].header.mpeg_version"
"1"
3
"1"
"MPEG Version 1"
mp3> .frames[0].header.bitrate | (topath | path_to_expr), tovalue, toactual, tosym, todescription
".frames[0].header.bitrate"
56000
4
56000
null
mp3> . | (root, buffer_root, format_root, parent | try (topath | path_to_expr) catch .), [parents | topath | path_to_expr]
"."
"."
"."
"expected decode value but got: null (null)"
[]
mp3> .headers[0].magic | (root, buffer_root, format_root, parent | topath | path_to_expr), [parents | topath | path_to_expr]
"."
"."
".headers[0]"
".headers[0]"
[
".headers[0]",
".headers",
"."
]
mp3> .frames[0].side_info.granules[1] | (root, buffer_root, format_root, parent | topath | path_to_expr), [parents | topath | path_to_expr]
"."
"."
".frames[0]"
".frames[0].side_info.granules"
[
".frames[0].side_info.granules",
".frames[0].side_info",
".frames[0]",
".frames",
"."
]
mp3> 123 | root
error: expected decode value but got: number (123)
mp3> 123 | buffer_root
error: expected decode value but got: number (123)
mp3> 123 | format_root
error: expected decode value but got: number (123)
mp3> 123 | parent
error: expected decode value but got: number (123)
mp3> 123 | parents
error: expected decode value but got: number (123)
mp3> ^D
$ fq -d mp3 -i . test.mp3
mp3> . as $c | ("headers", 0, "abc") as $n | $n, try ($c | has($n)) catch .
"headers"
true
0
"cannot check whether object has a key: 0"
"abc"
false
mp3> .headers as $c | (0, "abc") as $n | $n, try ($c | has($n)) catch .
0
true
"abc"
"cannot check whether array has a key: abc"
mp3> .headers[0].magic as $c | (0, "abc") as $n | $n, try ($c | has($n)) catch .
0
"has cannot be applied to: string"
"abc"
"has cannot be applied to: string"
mp3> . as $c | ("_start", "_stop", "_len", "_name", "_root", "_buffer_root", "_format_root", "_parent", "_sym", "_description", "_path", "_bits", "_bytes", "_error", "_unknown", "_format", "_abc") as $n | $n, try ($c | has($n)) catch .
"_start"
true
"_stop"
true
"_len"
true
"_name"
true
"_root"
true
"_buffer_root"
true
"_format_root"
true
"_parent"
true
"_sym"
true
"_description"
true
"_path"
true
"_bits"
true
"_bytes"
true
"_error"
true
"_unknown"
true
"_format"
true
"_abc"
"expected a extkey but got: _abc"
mp3> .headers as $c | ("_start", "_stop", "_len", "_name", "_root", "_buffer_root", "_format_root", "_parent", "_sym", "_description", "_path", "_bits", "_bytes", "_error", "_unknown", "_format", "_abc") as $n | $n, try ($c | has($n)) catch .
"_start"
true
"_stop"
true
"_len"
true
"_name"
true
"_root"
true
"_buffer_root"
true
"_format_root"
true
"_parent"
true
"_sym"
true
"_description"
true
"_path"
true
"_bits"
true
"_bytes"
true
"_error"
true
"_unknown"
true
"_format"
true
"_abc"
"expected a extkey but got: _abc"
mp3> .headers[0].magic as $c | ("_start", "_stop", "_len", "_name", "_root", "_buffer_root", "_format_root", "_parent", "_sym", "_description", "_path", "_bits", "_bytes", "_error", "_unknown", "_format", "_abc") as $n | $n, try ($c | has($n)) catch .
"_start"
true
"_stop"
true
"_len"
true
"_name"
true
"_root"
true
"_buffer_root"
true
"_format_root"
true
"_parent"
true
"_sym"
true
"_description"
true
"_path"
true
"_bits"
true
"_bytes"
true
"_error"
true
"_unknown"
true
"_format"
true
"_abc"
"expected a extkey but got: _abc"
mp3> ^D
$ fq -d mp3 -i . test.mp3
mp3> ._start
0
mp3> ._stop
5152
mp3> ._len
5152
mp3> ._name
""
mp3> ._root
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: test.mp3 (mp3)
0x000|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..| headers[0:1]:
* |until 0x2c.7 (45) | |
0x020| ff fb 40| ..@| frames[0:3]:
0x030|c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
* |until 0x283.7 (end) (599) | |
| | | footers[0:0]:
mp3> ._buffer_root
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: test.mp3 (mp3)
0x000|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..| headers[0:1]:
* |until 0x2c.7 (45) | |
0x020| ff fb 40| ..@| frames[0:3]:
0x030|c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
* |until 0x283.7 (end) (599) | |
| | | footers[0:0]:
mp3> ._format_root
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: test.mp3 (mp3)
0x000|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..| headers[0:1]:
* |until 0x2c.7 (45) | |
0x020| ff fb 40| ..@| frames[0:3]:
0x030|c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
* |until 0x283.7 (end) (599) | |
| | | footers[0:0]:
mp3> ._parent
null
mp3> ._sym
null
mp3> todescription
"test.mp3"
mp3> topath
[]
mp3> ._bits
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x000|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..|.: raw bits 0x0-0x283.7 (644)
* |until 0x283.7 (end) (644) | |
mp3> ._bytes
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x000|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..|.: raw bits 0x0-0x283.7 (644)
* |until 0x283.7 (end) (644) | |
mp3> ._error
null
mp3> ._unknown
false
mp3> ._format
"mp3"
mp3> ._abc
error: expected a extkey but got: _abc
mp3> fgrep("toc") | arrays[10]._index
10
mp3> .headers._index
error: expected a extkey but got: _index
mp3> ._index
error: expected a extkey but got: _index
mp3> ^D