@@ -34,14 +34,7 @@ class RunScriptTests extends AnyWordSpec with Matchers {
3434 " execute a simple script" in new Fixture {
3535 def test (scriptFile : Path , outputFile : Path ) = {
3636 val escScriptPath = outputFile.toString.replace(" \\ " , " \\\\ " )
37- Files .writeString(
38- scriptFile,
39- s """
40- |val fw = new java.io.FileWriter(" $escScriptPath", true)
41- |fw.write("michael was here")
42- |fw.close()
43- """ .stripMargin
44- )
37+ Files .writeString(scriptFile, s """ "michael was here" #> " $escScriptPath" """ .stripMargin)
4538
4639 ReplBridge .main(Array (" --script" , scriptFile.toString))
4740
@@ -57,9 +50,7 @@ class RunScriptTests extends AnyWordSpec with Matchers {
5750 scriptFile,
5851 s """
5952 |@main def foo(outFile: String, magicNumber: Int) = {
60- | val fw = new java.io.FileWriter(outFile, true)
61- | fw.write(magicNumber.toString)
62- | fw.close()
53+ | magicNumber #> outFile
6354 |}
6455 """ .stripMargin
6556 )
@@ -88,14 +79,10 @@ class RunScriptTests extends AnyWordSpec with Matchers {
8879 scriptFile,
8980 s """
9081 |@main def foo() = {
91- | val fw = new java.io.FileWriter(" $escScriptPath", true)
92- | fw.write("foo was called")
93- | fw.close()
82+ | "foo was called" #> " $escScriptPath"
9483 |}
9584 |@main def bar() = {
96- | val fw = new java.io.FileWriter(" $escScriptPath", true)
97- | fw.write("bar was called")
98- | fw.close()
85+ | "bar was called" #> " $escScriptPath"
9986 |}
10087 """ .stripMargin
10188 )
@@ -116,9 +103,7 @@ class RunScriptTests extends AnyWordSpec with Matchers {
116103 scriptFile,
117104 s """
118105 |//> using file $additionalImportFile
119- |val fw = new java.io.FileWriter(" $escScriptPath", true)
120- |fw.write(sayHello("michael")) //function defined in additionalImportFile
121- |fw.close()
106+ |sayHello("michael") #> " $escScriptPath"
122107 """ .stripMargin
123108 )
124109
@@ -137,9 +122,7 @@ class RunScriptTests extends AnyWordSpec with Matchers {
137122 Files .writeString(
138123 scriptFile,
139124 s """
140- |val fw = new java.io.FileWriter(" $escScriptPath", true)
141- |fw.write(sayHello("michael")) //function defined in additionalImportFile
142- |fw.close()
125+ |sayHello("michael") #> " $escScriptPath"
143126 """ .stripMargin
144127 )
145128
0 commit comments