File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
source/ports/scala_port/src/test/scala Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff line change 11from imported_fns import imported_fn
22
3+
34def hello_scala_from_python (a , b ):
45 return a + b
56
7+
68def fail ():
79 raise Exception ('Failed!' )
810
11+
912def apply_fn_to_str (fn ):
1013 return fn ('hellooo' )
1114
15+
1216def apply_fn_to_one (fn ):
1317 return fn (1 )
1418
19+
1520def apply_fn_to_two (fn ):
1621 return fn (1 , 3 )
1722
23+
1824def get_function_test (a ):
1925 return a
26+
27+
28+ def sumList (list : list ):
29+ return sum (list )
You can’t perform that action at this time.
0 commit comments