From 8700f5fdf3a773d3fea649c31b0307ac8d90f743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcial=20Gai=C3=9Fert?= Date: Tue, 4 Jul 2023 14:33:59 +0200 Subject: [PATCH] Also allow file --- effekt/jvm/src/test/scala/effekt/TyperTests.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/effekt/jvm/src/test/scala/effekt/TyperTests.scala b/effekt/jvm/src/test/scala/effekt/TyperTests.scala index c9f655e21..6d1950a9a 100644 --- a/effekt/jvm/src/test/scala/effekt/TyperTests.scala +++ b/effekt/jvm/src/test/scala/effekt/TyperTests.scala @@ -1,7 +1,7 @@ package effekt import effekt.context.Annotations import effekt.context.Context -import kiama.util.StringSource +import kiama.util.{Source, StringSource, FileSource} import effekt.typer.{Typer,Wellformedness} import effekt.namer.Namer import effekt.lifted.ModuleDecl @@ -10,10 +10,10 @@ import effekt.context.IOModuleDB abstract class AbstractTyperTests extends munit.FunSuite { + /** A test that first runs the frontend on `input` and then `body`, where the [[Context]] is made available */ - def testTyper(name: String)(input: String)(body: Context => Unit): Unit = { + def testTyper(name: String)(src: Source)(body: Context => Unit): Unit = { test(name) { - val src = StringSource(input, name) val compiler = new effekt.Driver {} val configs = compiler.createConfig(Seq( "--server" @@ -34,6 +34,10 @@ abstract class AbstractTyperTests extends munit.FunSuite { } } } + def testTyper(name: String)(input: String)(body: Context => Unit): Unit = + testTyper(name)(StringSource(input, name))(body) + def testTyperFile(name: String)(filename: String)(body: Context => Unit): Unit = + testTyper(name)(FileSource(filename))(body) extension(C: Context) { /** Assert that the unique symbol named `name` has the expected value type */ def assertValueType(name: String, expected: String, clue: => Any = "value types don't match"): Unit = {