Skip to content

Commit

Permalink
Remove machine-dependent contents from diff-test output
Browse files Browse the repository at this point in the history
  • Loading branch information
LPTK committed Oct 28, 2024
1 parent 91bcbc3 commit de0b196
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 61 deletions.
18 changes: 10 additions & 8 deletions hkmc2/jvm/src/test/scala/hkmc2/JSBackendDiffMaker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ abstract class JSBackendDiffMaker extends MLsDiffMaker:
val js = NullaryCommand("js")
val sjs = NullaryCommand("sjs")
val showRepl = NullaryCommand("showRepl")
val silent = NullaryCommand("silent")

private val baseScp: codegen.js.Scope =
codegen.js.Scope.empty
Expand Down Expand Up @@ -64,14 +65,15 @@ abstract class JSBackendDiffMaker extends MLsDiffMaker:
val (reply, stderr) = host.query(queryStr)
reply match
case ReplHost.Result(content, stdout) =>
stdout match
case None | Some("") =>
case Some(str) =>
str.splitSane('\n').foreach: line =>
output(s"> ${line}")
content match
case "undefined" =>
case _ => output(s"$prefix= ${content}")
if silent.isUnset then
stdout match
case None | Some("") =>
case Some(str) =>
str.splitSane('\n').foreach: line =>
output(s"> ${line}")
content match
case "undefined" =>
case _ => output(s"$prefix= ${content}")
case ReplHost.Empty =>
case ReplHost.Unexecuted(message) => ???
case ReplHost.Error(isSyntaxError, message) =>
Expand Down
29 changes: 1 addition & 28 deletions hkmc2/shared/src/test/mlscript/codegen/ConsoleLog.mls
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,10 @@
:sjs


// FIXME multiline result is treated as part stdout
:silent
declare val console
//│ JS:
//│ undefined
//│ > Object [console] {
//│ > log: [Function: log],
//│ > warn: [Function: warn],
//│ > error: [Function: error],
//│ > dir: [Function: dir],
//│ > time: [Function: time],
//│ > timeEnd: [Function: timeEnd],
//│ > timeLog: [Function: timeLog],
//│ > trace: [Function: trace],
//│ > assert: [Function: assert],
//│ > clear: [Function: clear],
//│ > count: [Function: count],
//│ > countReset: [Function: countReset],
//│ > group: [Function: group],
//│ > groupEnd: [Function: groupEnd],
//│ > table: [Function: table],
//│ > debug: [Function: debug],
//│ > info: [Function: error],
//│ > dirxml: [Function: dirxml],
//│ > groupCollapsed: [Function: groupCollapsed],
//│ > Console: [Function: Console],
//│ > profile: [Function: profile],
//│ > profileEnd: [Function: profileEnd],
//│ > timeStamp: [Function: timeStamp],
//│ > context: [Function: context],
//│ > createTask: [Function: createTask]
//│ console = }


console.log("a")
Expand Down
9 changes: 2 additions & 7 deletions hkmc2/shared/src/test/mlscript/codegen/ImportJSClass.mls
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@



:sjs
import "../../js/MyClass.mjs"
//│ JS:
//│ this.MyClass = await import("/Users/parreaux/work/Research/experiments/hkmc2/hkmc2/shared/src/test/js/MyClass.mjs");
//│ if (this.MyClass.default !== undefined) this.MyClass = this.MyClass.default;
//│ undefined
//│ MyClass = [class MyClass]

MyClass
Expand All @@ -19,7 +14,7 @@ new MyClass("Bob")
:todo
let C = MyClass
//│ ╔══[ERROR] Unsupported let binding shape
//│ ║ l.20: let C = MyClass
//│ ║ l.15: let C = MyClass
//│ ╙── ^^^^^^^^^^^

let c = MyClass
Expand All @@ -38,7 +33,7 @@ fun foo() =
import "../../js/MyClass.mjs"
()
//│ ╔══[COMPILATION ERROR] Imports must be at the top level
//│ ║ l.38: import "../../js/MyClass.mjs"
//│ ║ l.33: import "../../js/MyClass.mjs"
//│ ╙── ^^^^^^^^^^^^^^^^^^^^^^


5 changes: 0 additions & 5 deletions hkmc2/shared/src/test/mlscript/codegen/ImportJSModule.mls
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
:js

:sjs
import "../../js/Test.mjs"
//│ JS:
//│ this.Test = await import("/Users/parreaux/work/Research/experiments/hkmc2/hkmc2/shared/src/test/js/Test.mjs");
//│ if (this.Test.default !== undefined) this.Test = this.Test.default;
//│ undefined
//│ Test = [Module: null prototype] { greet: [Function: greet] }

Test
Expand Down
27 changes: 14 additions & 13 deletions hkmc2/shared/src/test/mlscript/codegen/Pwd.mls
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@

// * Note: `||` is currently not shortcircuiting
:sjs
let folderName = process.cwd().split("/").pop() in
folderName === "hkmc2" || folderName === "jvm"
let folderName1 = process.env.PWD.split("/").pop()
in let folderName2 = process.cwd().split("/").pop()
in folderName2 === folderName1 || folderName2 === "jvm"
//│ JS:
//│ let tmp, tmp1, tmp2, tmp3, tmp4;
//│ tmp = process.cwd();
//│ tmp1 = tmp.split("/");
//│ tmp2 = tmp1.pop();
//│ this.folderName = tmp2;
//│ tmp3 = this.folderName === "hkmc2";
//│ tmp4 = this.folderName === "jvm";
//│ tmp3 || tmp4
//│ let tmp, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
//│ tmp = process.env.PWD.split("/");
//│ tmp1 = tmp.pop();
//│ this.folderName1 = tmp1;
//│ tmp2 = process.cwd();
//│ tmp3 = tmp2.split("/");
//│ tmp4 = tmp3.pop();
//│ this.folderName2 = tmp4;
//│ tmp5 = this.folderName2 === this.folderName1;
//│ tmp6 = this.folderName2 === "jvm";
//│ tmp5 || tmp6
//│ = true

process.env.PWD.split("/").pop()
//│ = 'hkmc2'


11 changes: 11 additions & 0 deletions hkmc2/shared/src/test/mlscript/codegen/Repl.mls
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ let x = 1, log(x), x
//│ x = 1


// FIXME multiline result is treated as part stdout
["***", "***", "***", "***", "***", "***", "***", "***", "***", "***", "***", "***", "***", "***", "***"]
//│ > [
//│ > '***', '***', '***',
//│ > '***', '***', '***',
//│ > '***', '***', '***',
//│ > '***', '***', '***',
//│ > '***', '***', '***'
//│ = ]


0 comments on commit de0b196

Please sign in to comment.