| 255 | } |
| 256 | |
| 257 | func TestAbbrevsCompiled(t *testing.T) { |
| 258 | // Test whether abbreviations successfully resolve at type-check time (compile time). |
| 259 | env := testEnv(t, |
| 260 | Abbrevs("qualified.identifier.name"), |
| 261 | Variable("qualified.identifier.name.first", StringType), |
| 262 | ) |
| 263 | prg := compile(t, env, `"hello "+ name.first`) // abbreviation resolved here. |
| 264 | out, _, err := prg.Eval( |
| 265 | map[string]any{ |
| 266 | "qualified.identifier.name.first": "Jim", |
| 267 | }, |
| 268 | ) |
| 269 | if err != nil { |
| 270 | t.Fatal(err) |
| 271 | } |
| 272 | if out.Value() != "hello Jim" { |
| 273 | t.Errorf("got %v, wanted 'hello Jim'", out) |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | func TestAbbrevsParsed(t *testing.T) { |
| 278 | // Test whether abbreviations are resolved properly at evaluation time. |