(t *testing.T)
| 332 | } |
| 333 | |
| 334 | func TestAddDeclFnError(t *testing.T) { |
| 335 | eval, err := NewEvaluator() |
| 336 | if err != nil { |
| 337 | t.Fatalf("NewEvaluator() failed with: %v", err) |
| 338 | } |
| 339 | |
| 340 | err = eval.AddDeclFn("fn", []letFunctionParam{ |
| 341 | {identifier: "x", typeHint: mustParseType(t, "int")}, |
| 342 | {identifier: "y", typeHint: mustParseType(t, "int")}}, |
| 343 | mustParseType(t, "int")) |
| 344 | |
| 345 | if err != nil { |
| 346 | t.Errorf("eval.AddDeclFn('fn(x:int, y:int): int') got error %v wanted nil", err) |
| 347 | } |
| 348 | |
| 349 | err = eval.AddLetVar("z", "fn(1, 2)", nil) |
| 350 | |
| 351 | if err != nil { |
| 352 | t.Errorf("eval.AddLetVar('z = fn(1, 2)') got error %v wanted nil", err) |
| 353 | } |
| 354 | |
| 355 | err = eval.AddDeclFn("fn", []letFunctionParam{ |
| 356 | {identifier: "x", typeHint: mustParseType(t, "string")}, |
| 357 | {identifier: "y", typeHint: mustParseType(t, "string")}}, |
| 358 | mustParseType(t, "int")) |
| 359 | |
| 360 | if err == nil { |
| 361 | t.Errorf("eval.AddDeclFn('fn(x:string, y:string): int') got nil wanted error") |
| 362 | } |
| 363 | |
| 364 | } |
| 365 | |
| 366 | func TestDelLetFn(t *testing.T) { |
| 367 | eval, err := NewEvaluator() |
nothing calls this directly
no test coverage detected