Skip to content

Commit df28c49

Browse files
committed
Added (and commented) parallelism test that fails
1 parent c9b47f4 commit df28c49

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

source/ports/scala_port/src/test/scala/MetaCallSpec.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,29 @@ class MetaCallSpec extends AnyFlatSpec {
408408
assert(ret == LongValue(2L))
409409
}
410410

411+
/* TODO: Parallelism doesn't work
412+
"Parallel function calls" should "not fail" in {
413+
val ranges: List[Vector[Int]] =
414+
List.range(1, 1000).map(n => Vector.range(1, n))
415+
416+
val rangeValues: List[ArrayValue] =
417+
ranges.map(range => ArrayValue(range map IntValue.apply))
418+
419+
import scala.concurrent._, duration._
420+
import ExecutionContext.Implicits.global
421+
422+
val resSum = rangeValues
423+
.traverse { range =>
424+
Future(Caller.call("sumList", Vector(range))) map {
425+
case n: NumericValue[_] => n.long.value
426+
case _ => fail("Returned value should be a number")
427+
}
428+
}
429+
.map(_.sum)
430+
431+
println("REsult: " + Await.result(resSum, 10.seconds))
432+
}*/
433+
411434
"MetaCall" should "be destroyed successfully" in {
412435
require(
413436
metacall.metacall_destroy() == 0,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
from imported_fns import imported_fn
22

3+
34
def hello_scala_from_python(a, b):
45
return a + b
56

7+
68
def fail():
79
raise Exception('Failed!')
810

11+
912
def apply_fn_to_str(fn):
1013
return fn('hellooo')
1114

15+
1216
def apply_fn_to_one(fn):
1317
return fn(1)
1418

19+
1520
def apply_fn_to_two(fn):
1621
return fn(1, 3)
1722

23+
1824
def get_function_test(a):
1925
return a
26+
27+
28+
def sumList(list: list):
29+
return sum(list)

0 commit comments

Comments
 (0)