| 151 | } |
| 152 | |
| 153 | func TestAbbrevsCompiled(t *testing.T) { |
| 154 | // Test whether abbreviations successfully resolve at type-check time (compile time). |
| 155 | env := testEnv(t, |
| 156 | Abbrevs("qualified.identifier.name"), |
| 157 | Variable("qualified.identifier.name.first", StringType), |
| 158 | ) |
| 159 | prg := compile(t, env, `"hello "+ name.first`) // abbreviation resolved here. |
| 160 | out, _, err := prg.Eval( |
| 161 | map[string]any{ |
| 162 | "qualified.identifier.name.first": "Jim", |
| 163 | }, |
| 164 | ) |
| 165 | if err != nil { |
| 166 | t.Fatal(err) |
| 167 | } |
| 168 | if out.Value() != "hello Jim" { |
| 169 | t.Errorf("got %v, wanted 'hello Jim'", out) |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | func TestAbbrevsParsed(t *testing.T) { |
| 174 | // Test whether abbreviations are resolved properly at evaluation time. |