@@ -36,7 +36,7 @@ import (
3636 "cuelang.org/go/internal/tdtest"
3737)
3838
39- func getInstance (t * testing.T , body string ) * Instance {
39+ func getValue (t * testing.T , body string ) Value {
4040 t .Helper ()
4141
4242 var r Runtime // TODO: use Context and return Value
@@ -45,7 +45,7 @@ func getInstance(t *testing.T, body string) *Instance {
4545 if err != nil {
4646 t .Fatalf ("unexpected parse error: %v" , err )
4747 }
48- return inst
48+ return inst . Value ()
4949}
5050
5151func TestAPI (t * testing.T ) {
@@ -340,7 +340,7 @@ func TestValueType(t *testing.T) {
340340 }}
341341 for _ , tc := range testCases {
342342 t .Run (tc .value , func (t * testing.T ) {
343- inst := getInstance (t , tc .value )
343+ inst := getValue (t , tc .value )
344344 v := inst .Lookup ("v" )
345345 if got := v .Kind (); got != tc .kind {
346346 t .Errorf ("Kind: got %x; want %x" , int (got ), int (tc .kind ))
@@ -407,7 +407,7 @@ func TestInt(t *testing.T) {
407407 }}
408408 for _ , tc := range testCases {
409409 t .Run (tc .value , func (t * testing.T ) {
410- n := getInstance (t , tc .value ). Value ( )
410+ n := getValue (t , tc .value )
411411 base := 10
412412 if tc .base > 0 {
413413 base = tc .base
@@ -546,7 +546,7 @@ func TestFloat(t *testing.T) {
546546 }}
547547 for _ , tc := range testCases {
548548 t .Run (tc .value , func (t * testing.T ) {
549- n := getInstance (t , tc .value ). Value ( )
549+ n := getValue (t , tc .value )
550550 if n .Kind () != tc .kind {
551551 t .Fatal ("Not a number" )
552552 }
@@ -597,19 +597,19 @@ func TestString(t *testing.T) {
597597 }}
598598 for _ , tc := range testCases {
599599 t .Run (tc .value , func (t * testing.T ) {
600- str , err := getInstance (t , tc .value ). Value ( ).String ()
600+ str , err := getValue (t , tc .value ).String ()
601601 checkFatal (t , err , tc .err , "init" )
602602 if str != tc .str {
603603 t .Errorf ("String: got %q; want %q" , str , tc .str )
604604 }
605605
606- b , err := getInstance (t , tc .value ). Value ( ).Bytes ()
606+ b , err := getValue (t , tc .value ).Bytes ()
607607 checkFatal (t , err , tc .err , "init" )
608608 if got := string (b ); got != tc .str {
609609 t .Errorf ("Bytes: got %q; want %q" , got , tc .str )
610610 }
611611
612- r , err := getInstance (t , tc .value ). Value ( ).Reader ()
612+ r , err := getValue (t , tc .value ).Reader ()
613613 checkFatal (t , err , tc .err , "init" )
614614 b , _ = io .ReadAll (r )
615615 if got := string (b ); got != tc .str {
@@ -634,7 +634,7 @@ func TestError(t *testing.T) {
634634 }}
635635 for _ , tc := range testCases {
636636 t .Run (tc .value , func (t * testing.T ) {
637- err := getInstance (t , tc .value ). Value ( ).Err ()
637+ err := getValue (t , tc .value ).Err ()
638638 checkErr (t , err , tc .err , "init" )
639639 })
640640 }
@@ -658,7 +658,7 @@ func TestNull(t *testing.T) {
658658 }}
659659 for _ , tc := range testCases {
660660 t .Run (tc .value , func (t * testing.T ) {
661- v := getInstance (t , tc .value ).Lookup ("v" )
661+ v := getValue (t , tc .value ).Lookup ("v" )
662662 err := v .Null ()
663663 checkErr (t , err , tc .err , "init" )
664664 wantBool := err == nil
@@ -692,7 +692,7 @@ func TestBool(t *testing.T) {
692692 }}
693693 for _ , tc := range testCases {
694694 t .Run (tc .value , func (t * testing.T ) {
695- got , err := getInstance (t , tc .value ). Value ( ).Bool ()
695+ got , err := getValue (t , tc .value ).Bool ()
696696 if checkErr (t , err , tc .err , "init" ) {
697697 if got != tc .bool {
698698 t .Errorf ("got %v; want %v" , got , tc .bool )
@@ -729,7 +729,7 @@ func TestList(t *testing.T) {
729729 }}
730730 for _ , tc := range testCases {
731731 t .Run (tc .value , func (t * testing.T ) {
732- l , err := getInstance (t , tc .value ). Value ( ).List ()
732+ l , err := getValue (t , tc .value ).List ()
733733 checkFatal (t , err , tc .err , "init" )
734734
735735 buf := []byte {'[' }
@@ -829,7 +829,7 @@ func TestFields(t *testing.T) {
829829 }}
830830 for _ , tc := range testCases {
831831 t .Run (tc .value , func (t * testing.T ) {
832- obj := getInstance (t , tc .value ). Value ( )
832+ obj := getValue (t , tc .value )
833833
834834 iter , err := obj .Fields (tc .opts ... )
835835 checkFatal (t , err , tc .err , "init" )
@@ -890,7 +890,7 @@ func TestAllFields(t *testing.T) {
890890 }}
891891 for _ , tc := range testCases {
892892 t .Run (tc .value , func (t * testing.T ) {
893- obj := getInstance (t , tc .value ). Value ( )
893+ obj := getValue (t , tc .value )
894894
895895 var iter * Iterator // Verify that the returned iterator is a pointer.
896896 iter , err := obj .Fields (All ())
@@ -934,7 +934,7 @@ func TestFieldType(t *testing.T) {
934934 }}
935935 for _ , tc := range testCases {
936936 t .Run (tc .value , func (t * testing.T ) {
937- obj := getInstance (t , tc .value ). Value ( )
937+ obj := getValue (t , tc .value )
938938
939939 iter , err := obj .Fields (All ())
940940 if err != nil {
@@ -1768,7 +1768,7 @@ func TestDefaults(t *testing.T) {
17681768 }}
17691769 for _ , tc := range testCases {
17701770 t .Run (tc .value , func (t * testing.T ) {
1771- v := getInstance (t , "a: " + tc .value ).Lookup ("a" )
1771+ v := getValue (t , "a: " + tc .value ).Lookup ("a" )
17721772
17731773 v = v .Eval ()
17741774 d , ok := v .Default ()
@@ -1821,7 +1821,7 @@ func TestLen(t *testing.T) {
18211821 }}
18221822 for _ , tc := range testCases {
18231823 t .Run (tc .input , func (t * testing.T ) {
1824- v := getInstance (t , "a: " + tc .input ).Lookup ("a" )
1824+ v := getValue (t , "a: " + tc .input ).Lookup ("a" )
18251825
18261826 length := v .Len ()
18271827 if got := fmt .Sprint (length ); got != tc .length {
@@ -1870,7 +1870,7 @@ func TestTemplate(t *testing.T) {
18701870 }}
18711871 for _ , tc := range testCases {
18721872 t .Run ("" , func (t * testing.T ) {
1873- v := getInstance (t , tc .value ). Value ( )
1873+ v := getValue (t , tc .value )
18741874 for _ , p := range tc .path {
18751875 if p == "" {
18761876 v = v .Template ()("label" )
@@ -1928,7 +1928,7 @@ func TestElem(t *testing.T) {
19281928 }}
19291929 for _ , tc := range testCases {
19301930 t .Run ("" , func (t * testing.T ) {
1931- v := getInstance (t , tc .value ). Value ( )
1931+ v := getValue (t , tc .value )
19321932 v .v .Finalize (v .ctx ()) // TODO: do in instance.
19331933 for _ , p := range tc .path {
19341934 if p == "" {
@@ -2057,7 +2057,7 @@ func TestSubsume(t *testing.T) {
20572057 }}
20582058 for _ , tc := range testCases {
20592059 t .Run (tc .value , func (t * testing.T ) {
2060- v := getInstance (t , tc .value )
2060+ v := getValue (t , tc .value )
20612061 a := v .Value ().LookupPath (tc .pathA )
20622062 b := v .Value ().LookupPath (tc .pathB )
20632063 got := a .Subsume (b , tc .options ... ) == nil
@@ -2120,7 +2120,7 @@ func TestSubsumes(t *testing.T) {
21202120 }}
21212121 for _ , tc := range testCases {
21222122 t .Run (tc .value , func (t * testing.T ) {
2123- v := getInstance (t , tc .value )
2123+ v := getValue (t , tc .value )
21242124 a := v .Lookup (tc .pathA ... )
21252125 b := v .Lookup (tc .pathB ... )
21262126 got := a .Subsumes (b )
@@ -2191,7 +2191,7 @@ func TestUnify(t *testing.T) {
21912191 }}
21922192 // TODO(tdtest): use cuetest.Run when supported.
21932193 tdtest .Run (t , testCases , func (t * cuetest.T , tc * testCase ) {
2194- v := getInstance (t .T , tc .value ). Value ( )
2194+ v := getValue (t .T , tc .value )
21952195 x := v .LookupPath (ParsePath (tc .pathA ))
21962196 y := v .LookupPath (ParsePath (tc .pathB ))
21972197 b , err := x .Unify (y ).MarshalJSON ()
@@ -2243,7 +2243,7 @@ func TestUnifyAccept(t *testing.T) {
22432243 }}
22442244 // TODO(tdtest): use cuetest.Run when supported.
22452245 tdtest .Run (t , testCases , func (t * cuetest.T , tc * testCase ) {
2246- v := getInstance (t .T , tc .value ). Value ( )
2246+ v := getValue (t .T , tc .value )
22472247 x := v .LookupPath (ParsePath ("#v" ))
22482248 y := v .LookupPath (ParsePath ("#w" ))
22492249 a := v .LookupPath (ParsePath ("#accept" ))
@@ -2584,7 +2584,7 @@ func TestValueLookup(t *testing.T) {
25842584 }}
25852585 for _ , tc := range testCases {
25862586 t .Run (tc .str , func (t * testing.T ) {
2587- v := getInstance (t , tc .config ). Value ( ).Lookup (tc .path ... )
2587+ v := getValue (t , tc .config ).Lookup (tc .path ... )
25882588 if got := ! v .Exists (); got != tc .notExists {
25892589 t .Errorf ("exists: got %v; want %v" , got , tc .notExists )
25902590 }
@@ -2929,7 +2929,7 @@ func TestMarshalJSON(t *testing.T) {
29292929 }}
29302930 for i , tc := range testCases {
29312931 t .Run (fmt .Sprintf ("%d/%v" , i , tc .value ), func (t * testing.T ) {
2932- inst := getInstance (t , tc .value )
2932+ inst := getValue (t , tc .value )
29332933 b , err := inst .Value ().MarshalJSON ()
29342934 checkFatal (t , err , tc .err , "init" )
29352935
@@ -3005,7 +3005,7 @@ func TestWalk(t *testing.T) {
30053005 }}
30063006 for i , tc := range testCases {
30073007 t .Run (fmt .Sprintf ("%d/%v" , i , tc .value ), func (t * testing.T ) {
3008- inst := getInstance (t , tc .value )
3008+ inst := getValue (t , tc .value )
30093009 buf := []byte {}
30103010 stripComma := func () {
30113011 if n := len (buf ) - 1 ; buf [n ] == ',' {
@@ -3749,7 +3749,7 @@ func TestExpr(t *testing.T) {
37493749 }}
37503750 for _ , tc := range testCases {
37513751 t .Run (tc .input , func (t * testing.T ) {
3752- v := getInstance (t , tc .input ).Lookup ("v" )
3752+ v := getValue (t , tc .input ).Lookup ("v" )
37533753 got := exprStr (v )
37543754 if got != tc .want {
37553755 t .Errorf ("\n got %v;\n want %v" , got , tc .want )
0 commit comments