Skip to content

Commit f92d229

Browse files
authored
Revise ignored LLVM tests (#776)
Eventually closes #740
1 parent acb9c98 commit f92d229

File tree

16 files changed

+105
-93
lines changed

16 files changed

+105
-93
lines changed

effekt/jvm/src/test/scala/effekt/LLVMTests.scala

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class LLVMTests extends EffektTests {
2020
)
2121

2222
lazy val bugs: List[File] = List(
23-
// names not sanitized (even?)
24-
examplesDir / "pos" / "special_names.effekt",
2523
// Jump to the invalid address stated on the next line
2624
examplesDir / "benchmarks" / "input_output" / "dyck_one.effekt",
2725
examplesDir / "benchmarks" / "input_output" / "number_matrix.effekt",
@@ -33,36 +31,14 @@ class LLVMTests extends EffektTests {
3331
* Documentation of currently failing tests and their reason
3432
*/
3533
lazy val missingFeatures: List[File] = List(
36-
37-
// now show instance for records / datatypes
38-
examplesDir / "pos" / "builtins.effekt",
39-
examplesDir / "pos" / "namespaces.effekt",
40-
examplesDir / "pos" / "triples.effekt",
41-
examplesDir / "pos" / "either.effekt",
42-
43-
// inspect
44-
examplesDir / "pos" / "probabilistic.effekt",
45-
examplesDir / "pos" / "nim.effekt",
46-
examplesDir / "pos" / "exists.effekt",
47-
48-
// arrays
49-
examplesDir / "pos" / "arrays.effekt",
50-
examplesDir / "pos" / "raytracer.effekt",
51-
examplesDir / "pos" / "issue319.effekt",
52-
examplesDir / "pos" / "array",
53-
5434
// Regex
5535
examplesDir / "pos" / "simpleparser.effekt",
5636

57-
// tuples
58-
examplesDir / "pos" / "records.effekt",
59-
6037
// toplevel def and let bindings
6138
examplesDir / "pos" / "capture" / "mbed.effekt",
6239

6340
// unsafe cont
6441
examplesDir / "pos" / "propagators.effekt",
65-
examplesDir / "pos" / "unsafe_cont.effekt",
6642

6743
// Only JS (tests should be moved to a JS folder)
6844
examplesDir / "pos" / "genericcompare.effekt",
@@ -71,9 +47,6 @@ class LLVMTests extends EffektTests {
7147
examplesDir / "pos" / "capture" / "resources.effekt",
7248
examplesDir / "pos" / "io",
7349

74-
// first class functions closing over capabilities
75-
examplesDir / "pos" / "capture" / "state_eff.effekt",
76-
7750
// higher order foreign functions are not supported
7851
examplesDir / "pos" / "capture" / "ffi_blocks.effekt",
7952

effekt/jvm/src/test/scala/effekt/ReplTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class ReplTests extends munit.FunSuite {
9090
|Imported Functions
9191
|==================
9292
|def main(): Unit / {}
93+
|def show(c: Color): String / {}
9394
|""".stripMargin
9495

9596
assertNoDiff(runRepl("import examples/pos/builtins"), expected)

effekt/shared/src/main/scala/effekt/generator/llvm/PrettyPrinter.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ ${indentedLines(instructions.map(show).mkString("\n"))}
150150
case Parameter(tpe, name) => s"${show(tpe)} ${localName(name)}"
151151
}
152152

153-
def localName(name: String): LLVMString = "%" + name
154-
def globalName(name: String): LLVMString = "@" + name
153+
def sanitize(name: String): String = name.replace("?", "Q").replace("!", "B")
154+
155+
def localName(name: String): LLVMString = "%" + sanitize(name)
156+
def globalName(name: String): LLVMString = "@" + sanitize(name)
155157

156158
// indent all lines with four spaces
157159
def indentedLines(text: String): String = text.split("\n").map(" " + _).mkString("\n")

examples/pos/array/list_conversion.effekt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
11
module examples/pos/list/collect
22

3-
def listToArrayAndBack[A](list: List[A]): Unit = {
4-
list.foreach { x => inspect(x) }
3+
import array
4+
5+
def listToArrayAndBack(list: List[Int]): Unit = {
6+
list.foreach { x => println(x) }
57
println("")
68

7-
val arr = fromList(list)
9+
val arr = array::fromList(list)
810
println("size " ++ show(arr.size))
911
arr.foreachIndex { (i, x) =>
1012
println(i)
11-
inspect(x)
13+
println(x)
1214
}
1315
println("")
1416

1517
val reconstructedList = arr.toList()
16-
reconstructedList.foreach { x => inspect(x) }
18+
reconstructedList.foreach { x => println(x) }
1719
println("")
1820
}
1921

20-
def arrayToListAndBack[A](arr: Array[A]): Unit = {
22+
def arrayToListAndBack(arr: Array[Int]): Unit = {
2123
println("size " ++ show(arr.size))
2224
arr.foreachIndex { (i, x) =>
2325
println(i)
24-
inspect(x)
26+
println(x)
2527
}
2628
println("")
2729

2830
val list = arr.toList
29-
list.foreach { x => inspect(x) }
31+
list.foreach { x => println(x) }
3032
println("")
3133

3234
val reconstructedArray = fromList(list)
3335
println("size " ++ show(reconstructedArray.size))
3436
reconstructedArray.foreachIndex { (i, x) =>
3537
println(i)
36-
inspect(x)
38+
println(x)
3739
}
3840
println("")
3941
}

examples/pos/array/sum.effekt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module examples/pos/array/sum
22

3+
import array
4+
35
def main() = {
46
val emptyArray: Array[Int] = array::allocate(0)
57
println(emptyArray.sum())

examples/pos/arrays.effekt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module examples/pos/arrays
22

3+
import array
4+
35
def main() = {
46
val arr = array::allocate[String](5);
57

examples/pos/builtins.effekt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ module examples/pos/builtins
22

33
type Color { Red(); Green(); Blue() }
44

5+
def show(c: Color): String = c match {
6+
case Red() => "Red()"
7+
case Green() => "Green()"
8+
case Blue() => "Blue()"
9+
}
10+
511
def main() = {
612
println(1);
713
println("foo");
814
println(true);
915
println(1 == 2);
10-
inspect(Red())
16+
println(show(Red()))
1117
}

examples/pos/either.effekt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ type Either[A, B] {
55
Right(value: B)
66
}
77

8+
def show(either: Either[Int, String]): String = either match {
9+
case Left(value) => "Left(" ++ show(value) ++ ")"
10+
case Right(value) => "Right(" ++ value ++ ")"
11+
}
12+
813
def main() = {
914
val l: Either[Int, String] = Left(42);
1015
val l2 = Left[Int, String](42);
11-
inspect(l);
12-
inspect(l2)
16+
println(show(l));
17+
println(show(l2))
1318
}

examples/pos/exists.effekt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
type Exists {
2-
Op[Z](el: Z, combine: (Z, Z) => Z at {})
2+
Op[Z](el: Z, combine: (Z, Z) => Z at {}, show: Z => String at {})
33
}
44

55

66
def test1() = {
7-
val intBox = Op(1, box { (x, y) => x + y });
8-
val stringBox = Op("hello!", box { (x, y) => x ++ y });
7+
val intBox = Op(1, box { (x, y) => x + y }, box { e => show(e) });
8+
val stringBox = Op("hello!", box { (x, y) => x ++ y }, box { e => e});
99

1010
def combineAndPrint(op: Exists): Unit = op match {
11-
case Op(el, combine) => inspect(combine(el, el))
11+
case Op(el, combine, show) => println(show(combine(el, el)))
1212
}
1313

1414
combineAndPrint(intBox)
1515
combineAndPrint(stringBox)
1616
}
1717

1818
def test2() = {
19-
val intBox = Op(1, box { (x, y) => x + y });
20-
val stringBox = Op("hello!", box { (x, y) => x ++ y });
19+
val intBox = Op(1, box { (x, y) => x + y }, box { e => show(e) });
20+
val stringBox = Op("hello!", box { (x, y) => x ++ y }, box { e => e });
2121

2222
def repack(op: Exists): Exists = op match {
23-
case Op(el, combine) => Op(el, combine)
23+
case Op(el, combine, show) => Op(el, combine, show)
2424
}
2525

2626
def combineAndPrint(op: Exists): Unit = op match {
27-
case Op(el, combine) => inspect(combine(el, el))
27+
case Op(el, combine, show) => println(show(combine(el, el)))
2828
}
2929

3030
combineAndPrint(repack(intBox))

examples/pos/issue319.effekt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import array
2+
13
def main() = {
2-
val array = fromList([1,2,3]);
3-
inspect(array.toList)
4+
val array = array::fromList([1,2,3]);
5+
println(array.toList)
46
}

0 commit comments

Comments
 (0)