(t *testing.T)
| 383 | } |
| 384 | |
| 385 | func TestExtendStdlibFunction(t *testing.T) { |
| 386 | env := testEnv(t, |
| 387 | Function(overloads.Contains, |
| 388 | MemberOverload("bytes_contains_bytes", []*Type{BytesType, BytesType}, BoolType, |
| 389 | BinaryBinding(func(bstr, bsub ref.Val) ref.Val { |
| 390 | return types.Bool(bytes.Contains([]byte(bstr.(types.Bytes)), []byte(bsub.(types.Bytes)))) |
| 391 | }))), |
| 392 | ) |
| 393 | prg := compile(t, env, `b'string'.contains(b'tri') && 'string'.contains('tri')`) |
| 394 | out, _, err := prg.Eval(NoVars()) |
| 395 | if err != nil { |
| 396 | t.Fatalf("contains check errored: %v", err) |
| 397 | } |
| 398 | if out != types.True { |
| 399 | t.Errorf("contains check got %v, wanted true", out) |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | func TestSubsetStdLib(t *testing.T) { |
| 404 | env, err := NewCustomEnv( |
nothing calls this directly
no test coverage detected