@@ -35,6 +35,10 @@ func TestFormatRoundTrip(t *testing.T) {
3535 t .Fatalf ("expected aggregate plan index to be rebuilt, got %d" , got )
3636 }
3737
38+ if got := decoded .Constants [1 ]; got != runtime .NewDuration (1500 * time .Millisecond ) {
39+ t .Fatalf ("duration constant = %v (%T)" , got , got )
40+ }
41+
3842 if line , col := decoded .Source .LocationAt (source.Span {Start : 7 , End : 7 }); line == 0 || col == 0 {
3943 t .Fatalf ("expected source lines to be rebuilt, got line=%d col=%d" , line , col )
4044 }
@@ -73,6 +77,16 @@ func TestFormatRejectsInvalidConstants(t *testing.T) {
7377 if ! errors .Is (err , bytecode .ErrInvalidConstant ) {
7478 t .Fatalf ("expected ErrInvalidConstant for missing datetime value, got %v" , err )
7579 }
80+
81+ invalidDuration := "not-a-duration"
82+ frame = validFrame ()
83+ frame .Constants = []persist.ConstantFrame {{Type : "duration" , Duration : & invalidDuration }}
84+
85+ data = mustMarshalFrame (t , frame )
86+ _ , err = Default .Unmarshal (data )
87+ if ! errors .Is (err , bytecode .ErrInvalidConstant ) {
88+ t .Fatalf ("expected ErrInvalidConstant for malformed duration, got %v" , err )
89+ }
7690}
7791
7892func TestFormatRejectsDuplicateHostsAndLabels (t * testing.T ) {
@@ -161,6 +175,7 @@ func newTestProgram() *bytecode.Program {
161175 },
162176 Constants : []runtime.Value {
163177 runtime .NewFloat (1.5 ),
178+ runtime .NewDuration (1500 * time .Millisecond ),
164179 runtime .NewString ("hello" ),
165180 runtime .NewBinary ([]byte ("abc" )),
166181 runtime .NewDateTime (time .Unix (1700000000 , 0 ).UTC ()),
0 commit comments