From d02af539068ef7b01b4df7fc03010af614edd96d Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Wed, 12 Feb 2020 09:38:27 +0800 Subject: [PATCH] feat: add multiple import together support --- .../ast/goast/GoFullIdentListenerTest.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/chapi-ast-go/src/test/kotlin/chapi/ast/goast/GoFullIdentListenerTest.kt b/chapi-ast-go/src/test/kotlin/chapi/ast/goast/GoFullIdentListenerTest.kt index 254ea34e..7c49c9b9 100644 --- a/chapi-ast-go/src/test/kotlin/chapi/ast/goast/GoFullIdentListenerTest.kt +++ b/chapi-ast-go/src/test/kotlin/chapi/ast/goast/GoFullIdentListenerTest.kt @@ -42,4 +42,23 @@ import . "time" assertEquals(codeFile.Imports[1].Source, "time") assertEquals(codeFile.Imports[1].AsName, ".") } + + @Test + internal fun shouldIdentifyMultipleTogetherImport() { + var code = """ +package main + +import ( + "fmt" + "html/template" + "os" +) +""" + + val codeFile = GoAnalyser().analysis(code, "") + assertEquals(codeFile.Imports.size, 3) + assertEquals(codeFile.Imports[0].Source, "fmt") + assertEquals(codeFile.Imports[1].Source, "html/template") + assertEquals(codeFile.Imports[2].Source, "os") + } }