mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-14 10:09:09 -06:00
Add codegen test too
This commit is contained in:
@@ -244,3 +244,37 @@ func TestMakeGoIdentifier(t *testing.T) {
|
||||
assert.Equal("he_llo", makeGoIdentifier("he\u2318llo"))
|
||||
|
||||
}
|
||||
|
||||
func TestCanUseDefFromImport(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
cs := chunks.NewMemoryStore()
|
||||
|
||||
dir, err := ioutil.TempDir("", "")
|
||||
assert.NoError(err)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
byPathNomDL := filepath.Join(dir, "filedep.noms")
|
||||
err = ioutil.WriteFile(byPathNomDL, []byte("struct FromFile{i:Int8}"), 0600)
|
||||
assert.NoError(err)
|
||||
|
||||
r1 := strings.NewReader(`
|
||||
struct A {
|
||||
B: B
|
||||
}
|
||||
struct B {
|
||||
X: Int64
|
||||
}`)
|
||||
pkg1 := pkg.ParseNomDL("test1", r1, dir, cs)
|
||||
pkgRef1 := types.WriteValue(pkg1.Package, cs)
|
||||
|
||||
r2 := strings.NewReader(fmt.Sprintf(`
|
||||
alias Other = import "%s"
|
||||
struct C {
|
||||
C: Map<Int64, Other.A>
|
||||
}
|
||||
`, pkgRef1))
|
||||
pkg2 := pkg.ParseNomDL("test2", r2, dir, cs)
|
||||
gen2 := newCodeGen(nil, "test2", map[string]bool{}, depsMap{pkg1.Ref(): pkg1.Package}, pkg2)
|
||||
|
||||
assert.True(gen2.canUseDef(pkg2.Types()[0], gen2.pkg.Package))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user