(t *testing.T)
| 416 | } |
| 417 | |
| 418 | func TestInstanceFunction(t *testing.T) { |
| 419 | eval, err := NewEvaluator() |
| 420 | if err != nil { |
| 421 | t.Fatalf("NewEvaluator() failed with: %v", err) |
| 422 | } |
| 423 | |
| 424 | err = eval.AddLetFn("int.plus", []letFunctionParam{ |
| 425 | {identifier: "y", typeHint: mustParseType(t, "int")}}, |
| 426 | mustParseType(t, "int"), |
| 427 | "this + y") |
| 428 | |
| 429 | if err != nil { |
| 430 | t.Fatalf("eval.AddLetFn('int.plus(y : int): int -> this + y') failed: %s", err) |
| 431 | } |
| 432 | |
| 433 | val, _, err := eval.Evaluate("40.plus(2)") |
| 434 | if err != nil { |
| 435 | t.Errorf("eval.Eval('40.plus(2)') got error %v, wanted nil", err) |
| 436 | } |
| 437 | if val.Value().(int64) != 42 { |
| 438 | t.Errorf("eval.Eval('40.plus(2)') got %s, wanted 42", val) |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | type testContainerOption struct { |
| 443 | container string |
nothing calls this directly
no test coverage detected