...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package runtime
16
17 import (
18 "testing"
19
20 "cuelang.org/go/cue/ast"
21 "cuelang.org/go/cue/build"
22 )
23
24
25
26 func TestPartiallyResolved(t *testing.T) {
27 const importPath = "mod.test/foo"
28 spec1 := &ast.ImportSpec{
29 Path: ast.NewString(importPath),
30 }
31 spec2 := &ast.ImportSpec{
32 Name: ast.NewIdent("bar"),
33 Path: ast.NewString(importPath),
34 }
35
36 f := &ast.File{
37 Decls: []ast.Decl{
38 &ast.ImportDecl{Specs: []*ast.ImportSpec{spec1, spec2}},
39 &ast.Field{
40 Label: ast.NewIdent("X"),
41 Value: &ast.Ident{Name: "foo", Node: spec1},
42 },
43 &ast.Alias{
44 Ident: ast.NewIdent("Y"),
45 Expr: &ast.Ident{Name: "bar", Node: spec2},
46 },
47 },
48 Imports: []*ast.ImportSpec{spec1, spec2},
49 }
50
51 err := resolveFile(nil, f, &build.Instance{
52 Imports: []*build.Instance{{
53 ImportPath: importPath,
54 PkgName: "foo",
55 }},
56 }, map[string]ast.Node{})
57
58 if err != nil {
59 t.Errorf("exected no error, found %v", err)
60 }
61 }
62
View as plain text