Skip to content

Commit 8f16d1a

Browse files
committed
Remove obsolete PredefJS.mls hack from diff-tests
1 parent 88fd94e commit 8f16d1a

29 files changed

+186
-299
lines changed

hkmc2/shared/src/test/mlscript/bbml/bbGetters.mls

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
:js
22
:noSanityCheck // * For some reason, these cause problems
33

4-
// * For the `log` function
5-
:import ../codegen/PredefJS.mls
6-
//│ Imported 2 member(s)
7-
84
:global
95
:bbml
106
//│ Type: ⊤
117

128

139
:todo
1410
fun test1() =
15-
fun sayHi = log("Hi")
11+
fun sayHi = print("Hi")
1612
sayHi, sayHi, sayHi
1713
//│ ╔══[ERROR] Function definition shape not yet supported for sayHi
18-
//│ ║ l.15: fun sayHi = log("Hi")
19-
//│ ╙── ^^^^^^^^^
14+
//│ ║ l.11: fun sayHi = print("Hi")
15+
//│ ╙── ^^^^^^^^^^^
2016
//│ ╔══[ERROR] Variable not found: sayHi
21-
//│ ║ l.16: sayHi, sayHi, sayHi
17+
//│ ║ l.12: sayHi, sayHi, sayHi
2218
//│ ╙── ^^^^^
2319
//│ ╔══[ERROR] Variable not found: sayHi
24-
//│ ║ l.16: sayHi, sayHi, sayHi
20+
//│ ║ l.12: sayHi, sayHi, sayHi
2521
//│ ╙── ^^^^^
2622
//│ ╔══[ERROR] Variable not found: sayHi
27-
//│ ║ l.16: sayHi, sayHi, sayHi
23+
//│ ║ l.12: sayHi, sayHi, sayHi
2824
//│ ╙── ^^^^^
2925
//│ Type: ⊤
3026

@@ -42,9 +38,9 @@ fun test2() =
4238
n then funny(n - 1) + 1
4339
funny
4440
//│ ╔══[ERROR] Expected a monomorphic type or an instantiable type here, but () ->{⊥} [outer, 'caseScrut, 'eff] -> 'caseScrut ->{'eff} Int found
45-
//│ ║ l.42: n then funny(n - 1) + 1
41+
//│ ║ l.38: n then funny(n - 1) + 1
4642
//│ ║ ^^^^^^^^^^^^^^^^
47-
//│ ║ l.43: funny
43+
//│ ║ l.39: funny
4844
//│ ╙── ^^^^^^^
4945
//│ Type: ⊤
5046

@@ -69,7 +65,7 @@ test2()
6965
:ssjs
7066
test2()(5)
7167
//│ JS:
72-
//│ tmp = test21(); block$res9 = runtime.safeCall(tmp(5)); undefined
68+
//│ tmp = test21(); block$res8 = runtime.safeCall(tmp(5)); undefined
7369
//│ = 5
7470
//│ Type: Int
7571

@@ -103,20 +99,20 @@ fun test2() =
10399
//│ };
104100
//│ ═══[WARNING] Pure expression in statement position
105101
//│ ╔══[ERROR] Function definition shape not yet supported for funny
106-
//│ ║ l.84: case n then funny(n - 1) + 1
102+
//│ ║ l.80: case n then funny(n - 1) + 1
107103
//│ ╙── ^^^^^^^^^^^^^^^^
108104
//│ ╔══[ERROR] Variable not found: funny
109-
//│ ║ l.85: funny
105+
//│ ║ l.81: funny
110106
//│ ╙── ^^^^^
111107
//│ Type: ⊤
112108

113109

114110
:todo
115111
fun test3 =
116-
log("Hi")
112+
print("Hi")
117113
//│ ╔══[ERROR] Function definition shape not yet supported for test3
118-
//│ ║ l.116: log("Hi")
119-
//│ ╙── ^^^^^^^^^
114+
//│ ║ l.112: print("Hi")
115+
//│ ╙── ^^^^^^^^^^^
120116
//│ Type: ⊤
121117

122118

hkmc2/shared/src/test/mlscript/bbml/bbPrelude.mls

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ declare fun (&&): (Bool, Bool) -> Bool
5555
declare fun (||): (Bool, Bool) -> Bool
5656

5757

58+
fun print(x) = @untyped globalThis.console.log(x)
59+
60+

hkmc2/shared/src/test/mlscript/codegen/Arrays.mls

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
:js
22

3-
:import PredefJS.mls
4-
//│ Imported 2 member(s)
5-
63

74
let empty = []
85
//│ empty = []

hkmc2/shared/src/test/mlscript/codegen/BasicTerms.mls

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,42 +33,25 @@
3333
//│ = 2
3434

3535

36-
:fixme // should be a "linking" error
37-
log("Hi")
36+
print("Hi")
3837
//│ JS (unsanitized):
39-
//│ runtime.safeCall(this.log("Hi"))
40-
//│ ═══[RUNTIME ERROR] Error: Access to required field 'log' yielded 'undefined'
38+
//│ Predef.print("Hi")
39+
//│ > Hi
4140

42-
:fixme
4341
:lot
44-
log("Hi")
42+
print("Hi")
4543
2
4644
//│ JS (unsanitized):
47-
//│ let tmp; tmp = runtime.safeCall(this.log("Hi")); 2
45+
//│ let tmp; tmp = Predef.print("Hi"); 2
4846
//│ Lowered:
4947
//│ Program:
5048
//│ imports = Nil
5149
//│ main = Assign:
52-
//│ lhs = $selRes
53-
//│ rhs = Select{member:log}:
54-
//│ qual = Ref of globalThis:globalThis
55-
//│ name = Ident of "log"
56-
//│ rest = Match: \
57-
//│ scrut = Ref of $selRes
58-
//│ arms = Ls of
59-
//│ Tuple2:
60-
//│ _1 = Lit of UnitLit of false
61-
//│ _2 = Throw of Instantiate:
62-
//│ cls = Select:
63-
//│ qual = Ref of globalThis:globalThis
64-
//│ name = Ident of "Error"
65-
//│ args = Ls of
66-
//│ Lit of StrLit of "Access to required field 'log' yielded 'undefined'"
67-
//│ dflt = N
68-
//│ rest = Assign: \
6950
//│ lhs = $tmp
7051
//│ rhs = Call:
71-
//│ fun = Ref of $selRes
52+
//│ fun = Select{member:print}:
53+
//│ qual = Ref of member:Predef
54+
//│ name = Ident of "print"
7255
//│ args = Ls of
7356
//│ Arg:
7457
//│ spread = false
@@ -79,7 +62,8 @@ log("Hi")
7962
//│ rest = Return: \
8063
//│ res = Lit of UnitLit of false
8164
//│ implct = true
82-
//│ ═══[RUNTIME ERROR] Error: Access to required field 'log' yielded 'undefined'
65+
//│ > Hi
66+
//│ = 2
8367

8468

8569
:re

hkmc2/shared/src/test/mlscript/codegen/CaseOfCase.mls

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
:js
22

3-
:import PredefJS.mls
4-
//│ Imported 2 member(s)
5-
63

74
class Some[out A](value: A)
85

@@ -15,8 +12,8 @@ fun test(x) =
1512
Some(v) then Some(v + 1)
1613
None then None
1714
) is
18-
Some(v) then log(v)
19-
None then log("none")
15+
Some(v) then print(v)
16+
None then print("none")
2017
//│ JS (unsanitized):
2118
//│ let test;
2219
//│ test = function test(x) {
@@ -37,10 +34,10 @@ fun test(x) =
3734
//│ if (scrut instanceof Some1.class) {
3835
//│ param01 = scrut.value;
3936
//│ v1 = param01;
40-
//│ return log(v1)
37+
//│ return Predef.print(v1)
4138
//│ } else {
4239
//│ if (scrut instanceof None1) {
43-
//│ return log("none")
40+
//│ return Predef.print("none")
4441
//│ } else {
4542
//│ throw new globalThis.Error("match error");
4643
//│ }

hkmc2/shared/src/test/mlscript/codegen/ClassInClass.mls

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
:js
22

3-
:import PredefJS.mls
4-
//│ Imported 2 member(s)
5-
63

74
:sjs
85
class Outer(a, b) with
96
class Inner(c) with
107
fun i1(d) = [b, c, d]
11-
log(a)
12-
log(c)
13-
log(i1(a))
8+
print(a)
9+
print(c)
10+
print(i1(a))
1411
fun o1(c) = Inner(c)
1512
fun o2(c, d) = Inner(c).i1(d)
1613
val i = Inner(a)
17-
log(i.c)
18-
log(i.i1(1))
14+
print(i.c)
15+
print(i.i1(1))
1916
//│ JS (unsanitized):
2017
//│ let Outer1;
2118
//│ Outer1 = function Outer(a1, b1) { return new Outer.class(a1, b1); };
@@ -30,10 +27,10 @@ class Outer(a, b) with
3027
//│ constructor(c) {
3128
//│ this.c = c;
3229
//│ let tmp3, tmp4, tmp5;
33-
//│ tmp3 = log(this$Outer.a);
34-
//│ tmp4 = log(this.c);
30+
//│ tmp3 = Predef.print(this$Outer.a);
31+
//│ tmp4 = Predef.print(this.c);
3532
//│ tmp5 = this.i1(this$Outer.a);
36-
//│ log(tmp5)
33+
//│ Predef.print(tmp5)
3734
//│ }
3835
//│ i1(d) {
3936
//│ return [
@@ -46,9 +43,9 @@ class Outer(a, b) with
4643
//│ };
4744
//│ tmp = this.Inner(this.a);
4845
//│ this.i = tmp;
49-
//│ tmp1 = log(this.i.c);
46+
//│ tmp1 = Predef.print(this.i.c);
5047
//│ tmp2 = runtime.safeCall(this.i.i1(1));
51-
//│ log(tmp2)
48+
//│ Predef.print(tmp2)
5249
//│ }
5350
//│ o1(c) {
5451
//│ return this.Inner(c)
@@ -65,21 +62,21 @@ class Outer(a, b) with
6562
val o = Outer(100, 200)
6663
//│ > 100
6764
//│ > 100
68-
//│ > [ 200, 100, 100 ]
65+
//│ > [200, 100, 100]
6966
//│ > 100
70-
//│ > [ 200, 100, 1 ]
67+
//│ > [200, 100, 1]
7168
//│ o = Outer(100, 200)
7269

7370
o.o1(30)
7471
//│ > 100
7572
//│ > 30
76-
//│ > [ 200, 30, 100 ]
73+
//│ > [200, 30, 100]
7774
//│ = Inner(30)
7875

7976
o.o2(30, 40)
8077
//│ > 100
8178
//│ > 30
82-
//│ > [ 200, 30, 100 ]
79+
//│ > [200, 30, 100]
8380
//│ = [200, 30, 40]
8481

8582
o.i

hkmc2/shared/src/test/mlscript/codegen/ClassInFun.mls

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
:js
22

3-
:import PredefJS.mls
4-
//│ Imported 2 member(s)
5-
63

74
:sjs
85
fun test(a) =

hkmc2/shared/src/test/mlscript/codegen/ClassMatching.mls

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
:js
22

3-
:import PredefJS.mls
4-
//│ Imported 2 member(s)
5-
63

74
class Some[out A](value: A)
85

@@ -70,7 +67,7 @@ x => if x is Some(x) then x
7067
//│ throw new this.Error("match error");
7168
//│ }
7269
//│ }
73-
//│ = [function block$res10]
70+
//│ = [function block$res9]
7471

7572

7673
class C(a)
@@ -123,7 +120,7 @@ f(M.D(27))
123120
fun f(x) = if x is
124121
Some(x) and x > 0 then 42
125122
None then "ok"
126-
else log("oops")
123+
else print("oops")
127124
//│ JS (unsanitized):
128125
//│ let f4;
129126
//│ f4 = function f(x3) {
@@ -135,13 +132,13 @@ fun f(x) = if x is
135132
//│ if (scrut2 === true) {
136133
//│ return 42
137134
//│ } else {
138-
//│ return log("oops")
135+
//│ return Predef.print("oops")
139136
//│ }
140137
//│ } else {
141138
//│ if (x3 instanceof None1.class) {
142139
//│ return "ok"
143140
//│ } else {
144-
//│ return log("oops")
141+
//│ return Predef.print("oops")
145142
//│ }
146143
//│ }
147144
//│ };
@@ -196,7 +193,7 @@ f(Pair(10, 5))
196193

197194
// UCS term not in tail position
198195
:sjs
199-
fun f(x) = log of if x is
196+
fun f(x) = print of if x is
200197
Some(0) then "0"
201198
None then "ok"
202199
else "oops"
@@ -218,7 +215,7 @@ fun f(x) = log of if x is
218215
//│ tmp9 = "oops";
219216
//│ }
220217
//│ }
221-
//│ return log(tmp9)
218+
//│ return Predef.print(tmp9)
222219
//│ };
223220

224221
f(Some(0))

hkmc2/shared/src/test/mlscript/codegen/Classes.mls

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
:js
22

3-
:import PredefJS.mls
4-
//│ Imported 2 member(s)
5-
63
:global
74
:sjs
85

hkmc2/shared/src/test/mlscript/codegen/CodegenScratch.mls

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
:js
22

3-
:import PredefJS.mls
4-
//│ Imported 2 member(s)
5-
63
:global
74
:sjs
85
:lot

hkmc2/shared/src/test/mlscript/codegen/EarlyReturn.mls

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
:js
22

3-
:import PredefJS.mls
4-
//│ Imported 2 member(s)
5-
63

74
fun f() =
8-
log("--- pre ---")
5+
print("--- pre ---")
96
return 1
10-
log("--- post ---")
7+
print("--- post ---")
118

129

1310
f()
@@ -17,7 +14,7 @@ f()
1714
:sjs
1815
fun f(x) =
1916
if x < 0 do
20-
log("whoops")
17+
print("whoops")
2118
return 0
2219
x + 1
2320
//│ JS (unsanitized):
@@ -26,7 +23,7 @@ fun f(x) =
2623
//│ let scrut, tmp, tmp1;
2724
//│ scrut = x < 0;
2825
//│ if (scrut === true) {
29-
//│ tmp = log("whoops");
26+
//│ tmp = Predef.print("whoops");
3027
//│ return 0
3128
//│ } else {
3229
//│ tmp1 = runtime.Unit;

0 commit comments

Comments
 (0)