mirror of
https://github.com/wader/fq.git
synced 2025-01-08 23:59:50 +03:00
interp: Make to{actual,sym} behave similar to tovalue
Before if you did toactual it behaved differently and even gave error for a scalar that only had actual value set. Now both to{actal,sym} works similar to tovalue but will force if actual or sym value should be used.
This commit is contained in:
parent
2bda12e4b4
commit
00ee10a1a1
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -154,14 +154,18 @@
|
||||
"tfhd",
|
||||
"tfra",
|
||||
"tmpl",
|
||||
"toactual",
|
||||
"toarray",
|
||||
"toboolean",
|
||||
"tobytes",
|
||||
"tobytesrange",
|
||||
"todescription",
|
||||
"toimage",
|
||||
"tojson",
|
||||
"tojvalue",
|
||||
"topath",
|
||||
"torepr",
|
||||
"tosym",
|
||||
"tovalue",
|
||||
"toxml",
|
||||
"toxmlentities",
|
||||
|
@ -372,8 +372,8 @@ unary uses input and if more than one argument all as arguments ignoring the inp
|
||||
- `parents` output parents of value
|
||||
- `topath` path of value. Use `path_to_expr` to get a string representation.
|
||||
- `tovalue`, `tovalue($opts)` symbolic value if available otherwise actual value
|
||||
- `toactual` actual value (decoded etc)
|
||||
- `tosym` symbolic value (mapped etc)
|
||||
- `toactual`, `toactual($opts)` actual value (usually the decoded value)
|
||||
- `tosym`, `tosym($opts)` symbolic value (mapped etc)
|
||||
- `todescription` description of value
|
||||
- `torepr` convert decode value into what it reptresents. For example convert msgpack decode value
|
||||
into a value representing its JSON representation.
|
||||
|
@ -289,7 +289,7 @@ func (i *Interp) _decode(c any, format string, opts decodeOpts) any {
|
||||
}
|
||||
}
|
||||
|
||||
return makeDecodeValueOut(dv, formatOutMap)
|
||||
return makeDecodeValueOut(dv, decodeValueValue, formatOutMap)
|
||||
}
|
||||
|
||||
func valueKey(name string, a, b func(name string) any) any {
|
||||
@ -326,11 +326,19 @@ func toValue(optsFn func() Options, v any) (any, bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func makeDecodeValue(dv *decode.Value) any {
|
||||
return makeDecodeValueOut(dv, nil)
|
||||
type decodeValueKind int
|
||||
|
||||
const (
|
||||
decodeValueValue decodeValueKind = iota
|
||||
decodeValueActual
|
||||
decodeValueSym
|
||||
)
|
||||
|
||||
func makeDecodeValue(dv *decode.Value, kind decodeValueKind) any {
|
||||
return makeDecodeValueOut(dv, kind, nil)
|
||||
}
|
||||
|
||||
func makeDecodeValueOut(dv *decode.Value, out any) any {
|
||||
func makeDecodeValueOut(dv *decode.Value, kind decodeValueKind, out any) any {
|
||||
switch vv := dv.V.(type) {
|
||||
case *decode.Compound:
|
||||
if vv.IsArray {
|
||||
@ -338,7 +346,18 @@ func makeDecodeValueOut(dv *decode.Value, out any) any {
|
||||
}
|
||||
return NewStructDecodeValue(dv, out, vv)
|
||||
case *scalar.S:
|
||||
switch vv := vv.Value().(type) {
|
||||
// TODO: rethink value/actual/sym handling
|
||||
var vvv any
|
||||
switch kind {
|
||||
case decodeValueValue:
|
||||
vvv = vv.Value()
|
||||
case decodeValueActual:
|
||||
vvv = vv.Actual
|
||||
case decodeValueSym:
|
||||
vvv = vv.Sym
|
||||
}
|
||||
|
||||
switch vvv := vvv.(type) {
|
||||
case bitio.ReaderAtSeeker:
|
||||
// is lazy so that in situations where the decode value is only used to
|
||||
// create another binary we don't have to read and create a string, ex:
|
||||
@ -349,11 +368,11 @@ func makeDecodeValueOut(dv *decode.Value, out any) any {
|
||||
IsScalar: true,
|
||||
Fn: func() (gojq.JQValue, error) {
|
||||
buf := &bytes.Buffer{}
|
||||
vvC, err := bitio.CloneReader(vv)
|
||||
vvvC, err := bitio.CloneReader(vvv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := bitioex.CopyBits(buf, vvC); err != nil {
|
||||
if _, err := bitioex.CopyBits(buf, vvvC); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return gojqex.String([]rune(buf.String())), nil
|
||||
@ -364,42 +383,42 @@ func makeDecodeValueOut(dv *decode.Value, out any) any {
|
||||
}
|
||||
case bool:
|
||||
return decodeValue{
|
||||
JQValue: gojqex.Boolean(vv),
|
||||
JQValue: gojqex.Boolean(vvv),
|
||||
decodeValueBase: decodeValueBase{dv: dv},
|
||||
}
|
||||
case int:
|
||||
return decodeValue{
|
||||
JQValue: gojqex.Number{V: vv},
|
||||
JQValue: gojqex.Number{V: vvv},
|
||||
decodeValueBase: decodeValueBase{dv: dv},
|
||||
}
|
||||
case int64:
|
||||
return decodeValue{
|
||||
JQValue: gojqex.Number{V: big.NewInt(vv)},
|
||||
JQValue: gojqex.Number{V: big.NewInt(vvv)},
|
||||
decodeValueBase: decodeValueBase{dv: dv},
|
||||
}
|
||||
case uint64:
|
||||
return decodeValue{
|
||||
JQValue: gojqex.Number{V: new(big.Int).SetUint64(vv)},
|
||||
JQValue: gojqex.Number{V: new(big.Int).SetUint64(vvv)},
|
||||
decodeValueBase: decodeValueBase{dv: dv},
|
||||
}
|
||||
case float64:
|
||||
return decodeValue{
|
||||
JQValue: gojqex.Number{V: vv},
|
||||
JQValue: gojqex.Number{V: vvv},
|
||||
decodeValueBase: decodeValueBase{dv: dv},
|
||||
}
|
||||
case string:
|
||||
return decodeValue{
|
||||
JQValue: gojqex.String(vv),
|
||||
JQValue: gojqex.String(vvv),
|
||||
decodeValueBase: decodeValueBase{dv: dv},
|
||||
}
|
||||
case []any:
|
||||
return decodeValue{
|
||||
JQValue: gojqex.Array(vv),
|
||||
JQValue: gojqex.Array(vvv),
|
||||
decodeValueBase: decodeValueBase{dv: dv},
|
||||
}
|
||||
case map[string]any:
|
||||
return decodeValue{
|
||||
JQValue: gojqex.Object(vv),
|
||||
JQValue: gojqex.Object(vvv),
|
||||
decodeValueBase: decodeValueBase{dv: dv},
|
||||
}
|
||||
case nil:
|
||||
@ -409,11 +428,11 @@ func makeDecodeValueOut(dv *decode.Value, out any) any {
|
||||
}
|
||||
case *big.Int:
|
||||
return decodeValue{
|
||||
JQValue: gojqex.Number{V: vv},
|
||||
JQValue: gojqex.Number{V: vvv},
|
||||
decodeValueBase: decodeValueBase{dv: dv},
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("unreachable vv %#+v", vv))
|
||||
panic(fmt.Sprintf("unreachable vv %#+v", vvv))
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("unreachable dv %#+v", dv))
|
||||
@ -482,37 +501,29 @@ func (dvb decodeValueBase) JQValueKey(name string) any {
|
||||
case "_name":
|
||||
return dv.Name
|
||||
case "_root":
|
||||
return makeDecodeValue(dv.Root())
|
||||
return makeDecodeValue(dv.Root(), decodeValueValue)
|
||||
case "_buffer_root":
|
||||
// TODO: rename?
|
||||
return makeDecodeValue(dv.BufferRoot())
|
||||
return makeDecodeValue(dv.BufferRoot(), decodeValueValue)
|
||||
case "_format_root":
|
||||
// TODO: rename?
|
||||
return makeDecodeValue(dv.FormatRoot())
|
||||
return makeDecodeValue(dv.FormatRoot(), decodeValueValue)
|
||||
case "_parent":
|
||||
if dv.Parent == nil {
|
||||
return nil
|
||||
}
|
||||
return makeDecodeValue(dv.Parent)
|
||||
return makeDecodeValue(dv.Parent, decodeValueValue)
|
||||
case "_actual":
|
||||
switch vv := dv.V.(type) {
|
||||
switch dv.V.(type) {
|
||||
case *scalar.S:
|
||||
jv, ok := gojqex.ToGoJQValue(vv.Actual)
|
||||
if !ok {
|
||||
return fmt.Errorf("can't convert actual value jq value %#+v", vv.Actual)
|
||||
}
|
||||
return jv
|
||||
return makeDecodeValue(dv, decodeValueActual)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
case "_sym":
|
||||
switch vv := dv.V.(type) {
|
||||
switch dv.V.(type) {
|
||||
case *scalar.S:
|
||||
jv, ok := gojqex.ToGoJQValue(vv.Sym)
|
||||
if !ok {
|
||||
return fmt.Errorf("can't convert sym value jq value %#+v", vv.Actual)
|
||||
}
|
||||
return jv
|
||||
return makeDecodeValue(dv, decodeValueSym)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@ -642,19 +653,19 @@ func (v ArrayDecodeValue) JQValueIndex(index int) any {
|
||||
if index < 0 {
|
||||
return nil
|
||||
}
|
||||
return makeDecodeValue((v.Compound.Children)[index])
|
||||
return makeDecodeValue((v.Compound.Children)[index], decodeValueValue)
|
||||
}
|
||||
func (v ArrayDecodeValue) JQValueSlice(start int, end int) any {
|
||||
vs := make([]any, end-start)
|
||||
for i, e := range (v.Compound.Children)[start:end] {
|
||||
vs[i] = makeDecodeValue(e)
|
||||
vs[i] = makeDecodeValue(e, decodeValueValue)
|
||||
}
|
||||
return vs
|
||||
}
|
||||
func (v ArrayDecodeValue) JQValueEach() any {
|
||||
props := make([]gojq.PathValue, len(v.Compound.Children))
|
||||
for i, f := range v.Compound.Children {
|
||||
props[i] = gojq.PathValue{Path: i, Value: makeDecodeValue(f)}
|
||||
props[i] = gojq.PathValue{Path: i, Value: makeDecodeValue(f, decodeValueValue)}
|
||||
}
|
||||
return props
|
||||
}
|
||||
@ -680,7 +691,7 @@ func (v ArrayDecodeValue) JQValueHas(key any) any {
|
||||
func (v ArrayDecodeValue) JQValueToGoJQ() any {
|
||||
vs := make([]any, len(v.Compound.Children))
|
||||
for i, f := range v.Compound.Children {
|
||||
vs[i] = makeDecodeValue(f)
|
||||
vs[i] = makeDecodeValue(f, decodeValueValue)
|
||||
}
|
||||
return vs
|
||||
}
|
||||
@ -711,7 +722,7 @@ func (v StructDecodeValue) JQValueKey(name string) any {
|
||||
}
|
||||
if v.Compound.ByName != nil {
|
||||
if f, ok := v.Compound.ByName[name]; ok {
|
||||
return makeDecodeValue(f)
|
||||
return makeDecodeValue(f, decodeValueValue)
|
||||
}
|
||||
}
|
||||
|
||||
@ -720,7 +731,7 @@ func (v StructDecodeValue) JQValueKey(name string) any {
|
||||
func (v StructDecodeValue) JQValueEach() any {
|
||||
props := make([]gojq.PathValue, len(v.Compound.Children))
|
||||
for i, f := range v.Compound.Children {
|
||||
props[i] = gojq.PathValue{Path: f.Name, Value: makeDecodeValue(f)}
|
||||
props[i] = gojq.PathValue{Path: f.Name, Value: makeDecodeValue(f, decodeValueValue)}
|
||||
}
|
||||
return props
|
||||
}
|
||||
@ -752,7 +763,7 @@ func (v StructDecodeValue) JQValueHas(key any) any {
|
||||
func (v StructDecodeValue) JQValueToGoJQ() any {
|
||||
vm := make(map[string]any, len(v.Compound.Children))
|
||||
for _, f := range v.Compound.Children {
|
||||
vm[f.Name] = makeDecodeValue(f)
|
||||
vm[f.Name] = makeDecodeValue(f, decodeValueValue)
|
||||
}
|
||||
return vm
|
||||
}
|
||||
|
@ -56,8 +56,10 @@ def decode: decode(options.decode_format; {});
|
||||
def topath: _decode_value(._path);
|
||||
def tovalue($opts): _tovalue(options($opts));
|
||||
def tovalue: _tovalue(options({}));
|
||||
def toactual: _decode_value(._actual);
|
||||
def tosym: _decode_value(._sym);
|
||||
def toactual($opts): _decode_value(._actual) | tovalue($opts);
|
||||
def toactual: toactual({});
|
||||
def tosym($opts): _decode_value(._sym) | tovalue($opts);
|
||||
def tosym: tosym({});
|
||||
def todescription: _decode_value(._description);
|
||||
|
||||
# TODO: rename?
|
||||
|
10
pkg/interp/testdata/value_array.fqtest
vendored
10
pkg/interp/testdata/value_array.fqtest
vendored
@ -1,5 +1,5 @@
|
||||
$ fq -i -d mp3 . test.mp3
|
||||
mp3> .headers | ., tovalue, type, length?
|
||||
mp3> .headers | ., tovalue, toactual, tosym, type, length?
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.headers[0:1]:
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
||||
0x00|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..| [0]{}: header (id3v2)
|
||||
@ -40,6 +40,8 @@ mp3> .headers | ., tovalue, type, length?
|
||||
"version": 4
|
||||
}
|
||||
]
|
||||
null
|
||||
null
|
||||
"array"
|
||||
1
|
||||
mp3> .headers[0] | ., type, length?
|
||||
@ -149,6 +151,10 @@ mp3> .headers._name | ., type, length?
|
||||
"headers"
|
||||
"string"
|
||||
7
|
||||
mp3> .headers._actual | ., type, length?
|
||||
null
|
||||
"null"
|
||||
0
|
||||
mp3> .headers._sym | ., type, length?
|
||||
null
|
||||
"null"
|
||||
@ -169,14 +175,12 @@ mp3> .headers._bits | ., type, length?
|
||||
* |until 0x2c.7 (45) | |
|
||||
"string"
|
||||
360
|
||||
mp3>
|
||||
mp3> .headers._bytes | ., type, length?
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
||||
0x00|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..|.: raw bits 0x0-0x2c.7 (45)
|
||||
* |until 0x2c.7 (45) | |
|
||||
"string"
|
||||
45
|
||||
mp3>
|
||||
mp3> .headers._error | ., type, length?
|
||||
null
|
||||
"null"
|
||||
|
13
pkg/interp/testdata/value_boolean.fqtest
vendored
13
pkg/interp/testdata/value_boolean.fqtest
vendored
@ -1,8 +1,10 @@
|
||||
$ fq -i -d mp3 . test.mp3
|
||||
mp3> .headers[0].flags.unsynchronisation | ., tovalue, type, length?
|
||||
mp3> .headers[0].flags.unsynchronisation | ., tovalue, toactual, tosym, 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
|
||||
false
|
||||
null
|
||||
"boolean"
|
||||
mp3> .headers[0].flags.unsynchronisation[0] | ., type, length?
|
||||
error: expected an array but got: boolean
|
||||
@ -52,8 +54,13 @@ mp3> .headers[0].flags.unsynchronisation._name | ., type, length?
|
||||
"unsynchronisation"
|
||||
"string"
|
||||
17
|
||||
mp3> .headers[0].flags.unsynchronisation._actual | ., 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
|
||||
"boolean"
|
||||
mp3> .headers[0].flags.unsynchronisation._sym | ., type, length?
|
||||
null
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
||||
0x0| 00 | . |.headers[0].flags.unsynchronisation: false
|
||||
"null"
|
||||
0
|
||||
mp3> .headers[0].flags.unsynchronisation._description | ., type, length?
|
||||
@ -74,13 +81,11 @@ mp3> .headers[0].flags.unsynchronisation._bits | ., type, length?
|
||||
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"
|
||||
|
10
pkg/interp/testdata/value_json_array.fqtest
vendored
10
pkg/interp/testdata/value_json_array.fqtest
vendored
@ -1,7 +1,9 @@
|
||||
$ fq -i -n '"[]" | json'
|
||||
json> (.) | ., tovalue, type, length?
|
||||
json> (.) | ., tovalue, toactual, tosym, type, length?
|
||||
[]
|
||||
[]
|
||||
[]
|
||||
null
|
||||
"array"
|
||||
0
|
||||
json> (.)[0] | ., type, length?
|
||||
@ -65,6 +67,10 @@ json> (.)._name | ., type, length?
|
||||
""
|
||||
"string"
|
||||
0
|
||||
json> (.)._actual | ., type, length?
|
||||
[]
|
||||
"array"
|
||||
0
|
||||
json> (.)._sym | ., type, length?
|
||||
null
|
||||
"null"
|
||||
@ -82,13 +88,11 @@ json> (.)._bits | ., type, length?
|
||||
0x0|5b 5d| |[]| |.: raw bits 0x0-0x1.7 (2)
|
||||
"string"
|
||||
16
|
||||
json>
|
||||
json> (.)._bytes | ., type, length?
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
||||
0x0|5b 5d| |[]| |.: raw bits 0x0-0x1.7 (2)
|
||||
"string"
|
||||
2
|
||||
json>
|
||||
json> (.)._error | ., type, length?
|
||||
null
|
||||
"null"
|
||||
|
10
pkg/interp/testdata/value_json_object.fqtest
vendored
10
pkg/interp/testdata/value_json_object.fqtest
vendored
@ -1,7 +1,9 @@
|
||||
$ fq -i -n '"{}" | json'
|
||||
json> (.) | ., tovalue, type, length?
|
||||
json> (.) | ., tovalue, toactual, tosym, type, length?
|
||||
{}
|
||||
{}
|
||||
{}
|
||||
null
|
||||
"object"
|
||||
0
|
||||
json> (.)[0] | ., type, length?
|
||||
@ -55,6 +57,10 @@ json> (.)._name | ., type, length?
|
||||
""
|
||||
"string"
|
||||
0
|
||||
json> (.)._actual | ., type, length?
|
||||
{}
|
||||
"object"
|
||||
0
|
||||
json> (.)._sym | ., type, length?
|
||||
null
|
||||
"null"
|
||||
@ -72,13 +78,11 @@ json> (.)._bits | ., type, length?
|
||||
0x0|7b 7d| |{}| |.: raw bits 0x0-0x1.7 (2)
|
||||
"string"
|
||||
16
|
||||
json>
|
||||
json> (.)._bytes | ., type, length?
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
||||
0x0|7b 7d| |{}| |.: raw bits 0x0-0x1.7 (2)
|
||||
"string"
|
||||
2
|
||||
json>
|
||||
json> (.)._error | ., type, length?
|
||||
null
|
||||
"null"
|
||||
|
14
pkg/interp/testdata/value_null.fqtest
vendored
14
pkg/interp/testdata/value_null.fqtest
vendored
@ -1,8 +1,10 @@
|
||||
$ fq -i -d mp3 . test.mp3
|
||||
mp3> .headers[0].padding | ., tovalue, type, length?
|
||||
mp3> .headers[0].padding | ., tovalue, toactual, tosym, type, length?
|
||||
|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)
|
||||
"<10>AAAAAAAAAAAAAA=="
|
||||
"<10>AAAAAAAAAAAAAA=="
|
||||
null
|
||||
"string"
|
||||
10
|
||||
mp3> .headers[0].padding[0] | ., type, length?
|
||||
@ -65,8 +67,14 @@ mp3> .headers[0].padding._name | ., type, length?
|
||||
"padding"
|
||||
"string"
|
||||
7
|
||||
mp3> .headers[0].padding._actual | ., type, length?
|
||||
|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)
|
||||
"string"
|
||||
10
|
||||
mp3> .headers[0].padding._sym | ., type, length?
|
||||
null
|
||||
|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)
|
||||
"null"
|
||||
0
|
||||
mp3> .headers[0].padding._description | ., type, length?
|
||||
@ -86,13 +94,11 @@ mp3> .headers[0].padding._bits | ., type, length?
|
||||
0x20| 00 00 00 00 00 00 00 00 00 00 | .......... |.: raw bits 0x23-0x2c.7 (10)
|
||||
"string"
|
||||
80
|
||||
mp3>
|
||||
mp3> .headers[0].padding._bytes | ., type, length?
|
||||
|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 | .......... |.: raw bits 0x23-0x2c.7 (10)
|
||||
"string"
|
||||
10
|
||||
mp3>
|
||||
mp3> .headers[0].padding._error | ., type, length?
|
||||
null
|
||||
"null"
|
||||
|
14
pkg/interp/testdata/value_number.fqtest
vendored
14
pkg/interp/testdata/value_number.fqtest
vendored
@ -1,8 +1,10 @@
|
||||
$ fq -i -d mp3 . test.mp3
|
||||
mp3> .headers[0].version | ., tovalue, type, length?
|
||||
mp3> .headers[0].version | ., tovalue, toactual, tosym, type, length?
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
||||
0x0| 04 | . |.headers[0].version: 4
|
||||
4
|
||||
4
|
||||
null
|
||||
"number"
|
||||
4
|
||||
mp3> .headers[0].version[0] | ., type, length?
|
||||
@ -53,8 +55,14 @@ mp3> .headers[0].version._name | ., type, length?
|
||||
"version"
|
||||
"string"
|
||||
7
|
||||
mp3> .headers[0].version._actual | ., type, length?
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
||||
0x0| 04 | . |.headers[0].version: 4
|
||||
"number"
|
||||
4
|
||||
mp3> .headers[0].version._sym | ., type, length?
|
||||
null
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
||||
0x0| 04 | . |.headers[0].version: 4
|
||||
"null"
|
||||
0
|
||||
mp3> .headers[0].version._description | ., type, length?
|
||||
@ -74,13 +82,11 @@ mp3> .headers[0].version._bits | ., type, length?
|
||||
0x0| 04 | . |.: raw bits 0x3-0x3.7 (1)
|
||||
"string"
|
||||
8
|
||||
mp3>
|
||||
mp3> .headers[0].version._bytes | ., type, length?
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
||||
0x0| 04 | . |.: raw bits 0x3-0x3.7 (1)
|
||||
"string"
|
||||
1
|
||||
mp3>
|
||||
mp3> .headers[0].version._error | ., type, length?
|
||||
null
|
||||
"null"
|
||||
|
10
pkg/interp/testdata/value_object.fqtest
vendored
10
pkg/interp/testdata/value_object.fqtest
vendored
@ -1,5 +1,5 @@
|
||||
$ fq -i -d mp3 . test.mp3
|
||||
mp3> .headers[0].flags | ., tovalue, type, length?
|
||||
mp3> .headers[0].flags | ., tovalue, toactual, tosym, type, length?
|
||||
|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
|
||||
@ -11,6 +11,8 @@ mp3> .headers[0].flags | ., tovalue, type, length?
|
||||
"unsynchronisation": false,
|
||||
"unused": 0
|
||||
}
|
||||
null
|
||||
null
|
||||
"object"
|
||||
4
|
||||
mp3> .headers[0].flags[0] | ., type, length?
|
||||
@ -69,6 +71,10 @@ mp3> .headers[0].flags._name | ., type, length?
|
||||
"flags"
|
||||
"string"
|
||||
5
|
||||
mp3> .headers[0].flags._actual | ., type, length?
|
||||
null
|
||||
"null"
|
||||
0
|
||||
mp3> .headers[0].flags._sym | ., type, length?
|
||||
null
|
||||
"null"
|
||||
@ -90,13 +96,11 @@ mp3> .headers[0].flags._bits | ., type, length?
|
||||
0x0| 00 | . |.: raw bits 0x5-0x5.7 (1)
|
||||
"string"
|
||||
8
|
||||
mp3>
|
||||
mp3> .headers[0].flags._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.7 (1)
|
||||
"string"
|
||||
1
|
||||
mp3>
|
||||
mp3> .headers[0].flags._error | ., type, length?
|
||||
null
|
||||
"null"
|
||||
|
14
pkg/interp/testdata/value_string.fqtest
vendored
14
pkg/interp/testdata/value_string.fqtest
vendored
@ -1,8 +1,10 @@
|
||||
$ fq -i -d mp3 . test.mp3
|
||||
mp3> .headers[0].magic | ., tovalue, type, length?
|
||||
mp3> .headers[0].magic | ., tovalue, toactual, tosym, type, length?
|
||||
|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)
|
||||
"ID3"
|
||||
"ID3"
|
||||
null
|
||||
"string"
|
||||
3
|
||||
mp3> .headers[0].magic[0] | ., type, length?
|
||||
@ -65,8 +67,14 @@ mp3> .headers[0].magic._name | ., type, length?
|
||||
"magic"
|
||||
"string"
|
||||
5
|
||||
mp3> .headers[0].magic._actual | ., type, length?
|
||||
|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)
|
||||
"string"
|
||||
3
|
||||
mp3> .headers[0].magic._sym | ., type, length?
|
||||
null
|
||||
|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)
|
||||
"null"
|
||||
0
|
||||
mp3> .headers[0].magic._description | ., type, length?
|
||||
@ -86,13 +94,11 @@ mp3> .headers[0].magic._bits | ., type, length?
|
||||
0x0|49 44 33 |ID3 |.: raw bits 0x0-0x2.7 (3)
|
||||
"string"
|
||||
24
|
||||
mp3>
|
||||
mp3> .headers[0].magic._bytes | ., type, length?
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
||||
0x0|49 44 33 |ID3 |.: raw bits 0x0-0x2.7 (3)
|
||||
"string"
|
||||
3
|
||||
mp3>
|
||||
mp3> .headers[0].magic._error | ., type, length?
|
||||
null
|
||||
"null"
|
||||
|
6
pkg/interp/testdata/value_t.fqtest.tmpl
vendored
6
pkg/interp/testdata/value_t.fqtest.tmpl
vendored
@ -1,6 +1,5 @@
|
||||
/test.mp3:
|
||||
$ CMD
|
||||
PROMPT> EXPR | ., tovalue, type, length?
|
||||
PROMPT> EXPR | ., tovalue, toactual, tosym, type, length?
|
||||
PROMPT> EXPR[0] | ., type, length?
|
||||
PROMPT> EXPR[-1000] | ., type, length?
|
||||
PROMPT> EXPR[1000] | ., type, length?
|
||||
@ -21,7 +20,8 @@ PROMPT> EXPR._start | ., type, length?
|
||||
PROMPT> EXPR._stop | ., type, length?
|
||||
PROMPT> EXPR._len | ., type, length?
|
||||
PROMPT> EXPR._name | ., type, length?
|
||||
PROMPT> EXPR._symbol | ., type, length?
|
||||
PROMPT> EXPR._actual | ., type, length?
|
||||
PROMPT> EXPR._sym | ., type, length?
|
||||
PROMPT> EXPR._description | ., type, length?
|
||||
PROMPT> EXPR._path | ., type, length?
|
||||
PROMPT> EXPR._bits | ., type, length?
|
||||
|
12
pkg/interp/testdata/value_t.fqtest.tmpl.sh
vendored
12
pkg/interp/testdata/value_t.fqtest.tmpl.sh
vendored
@ -1,10 +1,10 @@
|
||||
#!/bin/sh
|
||||
sed 's/CMD/fq -i -d mp3 . \/test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers/g' | sed 's/PROMPT/mp3/g' >value_array.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . \/test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers[0].flags.unsynchronisation/g' | sed 's/PROMPT/mp3/g' >value_boolean.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . \/test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers[0].padding/g' | sed 's/PROMPT/mp3/g' >value_null.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . \/test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers[0].version/g' | sed 's/PROMPT/mp3/g' >value_number.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . \/test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers[0].flags/g' | sed 's/PROMPT/mp3/g' >value_object.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . \/test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers[0].magic/g' | sed 's/PROMPT/mp3/g' >value_string.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers/g' | sed 's/PROMPT/mp3/g' >value_array.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers[0].flags.unsynchronisation/g' | sed 's/PROMPT/mp3/g' >value_boolean.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers[0].padding/g' | sed 's/PROMPT/mp3/g' >value_null.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers[0].version/g' | sed 's/PROMPT/mp3/g' >value_number.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers[0].flags/g' | sed 's/PROMPT/mp3/g' >value_object.fqtest
|
||||
sed 's/CMD/fq -i -d mp3 . test.mp3/g' <value_t.fqtest.tmpl | sed 's/EXPR/.headers[0].magic/g' | sed 's/PROMPT/mp3/g' >value_string.fqtest
|
||||
|
||||
sed "s/CMD/fq -i -n '\"[]\" | json'/g" <value_t.fqtest.tmpl | sed 's/EXPR/(.)/g' | sed 's/PROMPT/json/g' >value_json_array.fqtest
|
||||
sed "s/CMD/fq -i -n '\"{}\" | json'/g" <value_t.fqtest.tmpl | sed 's/EXPR/(.)/g' | sed 's/PROMPT/json/g' >value_json_object.fqtest
|
||||
|
Loading…
Reference in New Issue
Block a user