1
1
mirror of https://github.com/wader/fq.git synced 2024-12-29 00:22:38 +03:00
fq/pkg/interp/testdata/value_boolean.fqtest
Mattias Wadman af35b2848d gojq: Preserve keys order for to_entries when used with JQValue
Feels like what one would expect when doing to_entries on a decode value struct etc,
that is get the pairs in same order as decoder wants.

Quite sure this used to the case but was change to sorted key order when
to_entries was move from bein implemented in jq to be internal for performance
reasons. Now internal gojq to_entries has a special case for JQValue objects.

Also use new gojq.JQType* constants for type strings and switch binary type
to look more like strings. Can still use _exttype to get "binary".
2022-07-26 15:55:58 +02:00

108 lines
3.9 KiB
Plaintext

$ fq -i -d mp3 . test.mp3
mp3> .headers[0].flags.unsynchronisation | ., tovalue, type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x0| 00 | . |.headers[0].flags.unsynchronisation: false
false
"boolean"
mp3> .headers[0].flags.unsynchronisation[0] | ., type, length?
error: expected an array but got: boolean
mp3> .headers[0].flags.unsynchronisation[-1000] | ., type, length?
error: expected an array but got: boolean
mp3> .headers[0].flags.unsynchronisation[1000] | ., type, length?
error: expected an array but got: boolean
mp3> .headers[0].flags.unsynchronisation[1:3] | ., type, length?
error: expected an array but got: boolean
mp3> .headers[0].flags.unsynchronisation[0:-1] | ., type, length?
error: expected an array but got: boolean
mp3> .headers[0].flags.unsynchronisation[-1000:2000] | ., type, length?
error: expected an array but got: boolean
mp3> .headers[0].flags.unsynchronisation["test"] | ., type, length?
error: expected an object but got: boolean
mp3> [.headers[0].flags.unsynchronisation[]] | type, length?
error: cannot iterate over: boolean
mp3> .headers[0].flags.unsynchronisation | keys
error: keys cannot be applied to: boolean
mp3> .headers[0].flags.unsynchronisation | has("a")
error: has cannot be applied to: boolean
mp3> .headers[0].flags.unsynchronisation | has(0)
error: has cannot be applied to: boolean
mp3> .headers[0].flags.unsynchronisation | type
"boolean"
mp3> .headers[0].flags.unsynchronisation | tonumber
error: tonumber cannot be applied to: boolean
mp3> .headers[0].flags.unsynchronisation | tostring
"false"
mp3> .headers[0].flags.unsynchronisation + ""
error: cannot add: boolean (false) and string ("")
mp3> .headers[0].flags.unsynchronisation + 1
error: cannot add: boolean (false) and number (1)
mp3> .headers[0].flags.unsynchronisation._start | ., type, length?
40
"number"
40
mp3> .headers[0].flags.unsynchronisation._stop | ., type, length?
41
"number"
41
mp3> .headers[0].flags.unsynchronisation._len | ., type, length?
1
"number"
1
mp3> .headers[0].flags.unsynchronisation._name | ., type, length?
"unsynchronisation"
"string"
17
mp3> .headers[0].flags.unsynchronisation._sym | ., type, length?
null
"null"
0
mp3> .headers[0].flags.unsynchronisation._description | ., type, length?
null
"null"
0
mp3> .headers[0].flags.unsynchronisation._path | ., type, length?
[
"headers",
0,
"flags",
"unsynchronisation"
]
"array"
4
mp3> .headers[0].flags.unsynchronisation._bits | ., type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x0| 00 | . |.: raw bits 0x5-0x5 (0.1)
"string"
1
mp3>
mp3> .headers[0].flags.unsynchronisation._bytes | ., type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x0| 00 | . |.: raw bits 0x5-0x5 (0.1)
"string"
0
mp3>
mp3> .headers[0].flags.unsynchronisation._error | ., type, length?
null
"null"
0
mp3> .headers[0].flags.unsynchronisation._unknown | ., type, length?
false
"boolean"
mp3> .headers[0].flags.unsynchronisation.a = 1
error: expected an object but got: boolean (false)
mp3> .headers[0].flags.unsynchronisation[0] = 1
error: expected an array but got: boolean (false)
mp3> .headers[0].flags.unsynchronisation.a |= empty
error: expected an object but got: boolean
mp3> .headers[0].flags.unsynchronisation[0] |= empty
error: expected an array but got: boolean
mp3> .headers[0].flags.unsynchronisation | setpath(["a"]; 1)
error: expected an object but got: boolean (false)
mp3> .headers[0].flags.unsynchronisation | setpath([0]; 1)
error: expected an array but got: boolean (false)
mp3> .headers[0].flags.unsynchronisation | delpaths([["a"]])
error: expected an object but got: boolean (false)
mp3> .headers[0].flags.unsynchronisation | delpaths([[0]])
error: expected an array but got: boolean (false)
mp3> ^D