| 171 | } |
| 172 | |
| 173 | func TestAbbrevsCompiled(t *testing.T) { |
| 174 | // Test whether abbreviations successfully resolve at type-check time (compile time). |
| 175 | env := testEnv(t, |
| 176 | Abbrevs("qualified.identifier.name"), |
| 177 | Variable("qualified.identifier.name.first", StringType), |
| 178 | ) |
| 179 | prg := compile(t, env, `"hello "+ name.first`) // abbreviation resolved here. |
| 180 | out, _, err := prg.Eval( |
| 181 | map[string]any{ |
| 182 | "qualified.identifier.name.first": "Jim", |
| 183 | }, |
| 184 | ) |
| 185 | if err != nil { |
| 186 | t.Fatal(err) |
| 187 | } |
| 188 | if out.Value() != "hello Jim" { |
| 189 | t.Errorf("got %v, wanted 'hello Jim'", out) |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | func TestAbbrevsParsed(t *testing.T) { |
| 194 | // Test whether abbreviations are resolved properly at evaluation time. |