forked from fwcd/kotlin-language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CompiledFileTest.kt
27 lines (22 loc) · 919 Bytes
/
CompiledFileTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package org.javacs.kt
import org.hamcrest.Matchers.equalTo
import org.junit.Assert.assertThat
import org.junit.Test
import java.nio.file.Files
class CompiledFileTest {
val compiledFile = compileFile()
fun compileFile(): CompiledFile {
val compiler = Compiler(setOf())
val file = testResourcesRoot().resolve("compiledFile/CompiledFileExample.kt")
val content = Files.readAllLines(file).joinToString("\n")
val parse = compiler.createFile(content, file)
val classPath = CompilerClassPath()
val sourcePath = listOf(parse)
val (context, container) = compiler.compileFiles(sourcePath, sourcePath)
return CompiledFile(content, parse, context, container, sourcePath, classPath)
}
@Test fun `typeAtPoint should return type for x`() {
val type = compiledFile.typeAtPoint(87)!!
assertThat(type.toString(), equalTo("Int"))
}
}