aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/fibonacci.lua16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/fibonacci.lua b/tests/fibonacci.lua
index a5e0b2a..5cdb4be 100644
--- a/tests/fibonacci.lua
+++ b/tests/fibonacci.lua
@@ -24,11 +24,16 @@ end
24-- 24--
25local KNOWN= { [0]=0, 1,1,2,3,5,8,13,21,34,55,89,144 } 25local KNOWN= { [0]=0, 1,1,2,3,5,8,13,21,34,55,89,144 }
26 26
27-- 27-- dummy function so that we don't error when fib() is launched from the master state
28set_debug_threadname = function ( ...)
29end
30
31 --
28-- uint= fib( n_uint ) 32-- uint= fib( n_uint )
29-- 33--
30local function fib( n ) 34local function fib( n )
31 --local lanes = require"lanes".configure() 35 set_debug_threadname( "fib(" .. n .. ")")
36 local lanes = require"lanes".configure()
32 -- 37 --
33 local sum 38 local sum
34 local floor= assert(math.floor) 39 local floor= assert(math.floor)
@@ -40,11 +45,7 @@ local function fib( n )
40 else 45 else
41 -- Splits into two; this task remains waiting for the results 46 -- Splits into two; this task remains waiting for the results
42 -- 47 --
43 -- note that lanes is pulled in by upvalue, so we need lanes.core to be available 48 local gen_f= lanes.gen( "*", fib)
44 -- the other solution is to require "lanes" from inside the lane body, as in:
45 -- local lanes = require"lanes".configure()
46 -- local gen_f= lanes.gen( "*", fib)
47 local gen_f= lanes.gen( "*", {required={"lanes.core"}}, fib)
48 49
49 local n1=floor(n/2) +1 50 local n1=floor(n/2) +1
50 local n2=floor(n/2) -1 + n%2 51 local n2=floor(n/2) -1 + n%2
@@ -93,4 +94,3 @@ local N= 80
93local res= fib(N) 94local res= fib(N)
94print( right[N], res ) 95print( right[N], res )
95-- assert( res==right[N] ) -- can't guarantee such a large number will match exactly 96-- assert( res==right[N] ) -- can't guarantee such a large number will match exactly
96