MCPcopy Create free account
hub / github.com/d5/tengo / TestObject_String

Function TestObject_String

objects_test.go:91–128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestObject_String(t *testing.T) {
92 var o tengo.Object = &tengo.Int{Value: 0}
93 require.Equal(t, "0", o.String())
94 o = &tengo.Int{Value: 1}
95 require.Equal(t, "1", o.String())
96 o = &tengo.Float{Value: 0}
97 require.Equal(t, "0", o.String())
98 o = &tengo.Float{Value: 1}
99 require.Equal(t, "1", o.String())
100 o = &tengo.Char{Value: ' '}
101 require.Equal(t, " ", o.String())
102 o = &tengo.Char{Value: 'T'}
103 require.Equal(t, "T", o.String())
104 o = &tengo.String{Value: ""}
105 require.Equal(t, `""`, o.String())
106 o = &tengo.String{Value: " "}
107 require.Equal(t, `" "`, o.String())
108 o = &tengo.Array{Value: nil}
109 require.Equal(t, "[]", o.String())
110 o = &tengo.Map{Value: nil}
111 require.Equal(t, "{}", o.String())
112 o = &tengo.Error{Value: nil}
113 require.Equal(t, "error", o.String())
114 o = &tengo.Error{Value: &tengo.String{Value: "error 1"}}
115 require.Equal(t, `error: "error 1"`, o.String())
116 o = &tengo.StringIterator{}
117 require.Equal(t, "<string-iterator>", o.String())
118 o = &tengo.ArrayIterator{}
119 require.Equal(t, "<array-iterator>", o.String())
120 o = &tengo.MapIterator{}
121 require.Equal(t, "<map-iterator>", o.String())
122 o = &tengo.Undefined{}
123 require.Equal(t, "<undefined>", o.String())
124 o = &tengo.Bytes{}
125 require.Equal(t, "", o.String())
126 o = &tengo.Bytes{Value: []byte("foo")}
127 require.Equal(t, "foo", o.String())
128}
129
130func TestObject_BinaryOp(t *testing.T) {
131 var o tengo.Object = &tengo.Char{}

Callers

nothing calls this directly

Calls 2

StringMethod · 0.95
EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…