MCPcopy Create free account
hub / github.com/dop251/goja / TestGoReflectCustomIntValueOf

Function TestGoReflectCustomIntValueOf

object_goreflect_test.go:170–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

168}
169
170func TestGoReflectCustomIntValueOf(t *testing.T) {
171 const SCRIPT = `
172 if (i instanceof Number) {
173 i.valueOf();
174 } else {
175 throw new Error("Value is not a number");
176 }
177 `
178
179 type CustomInt int
180 var i CustomInt = 42
181
182 r := New()
183 r.Set("i", i)
184 v, err := r.RunString(SCRIPT)
185 if err != nil {
186 t.Fatal(err)
187 }
188
189 if !v.StrictEquals(intToValue(42)) {
190 t.Fatalf("Expected int 42, got %v", v)
191 }
192}
193
194func TestGoReflectEqual(t *testing.T) {
195 const SCRIPT = `

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
intToValueFunction · 0.85
RunStringMethod · 0.80
SetMethod · 0.65
StrictEqualsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…