I’ve made a solution on my home laptop and tried submitting it for completion into busted but I routinely receive.
./cars-assemble.lua:10: unexpected symbol near ‘/’
./cars-assemble.lua:15: unexpected symbol near ‘/’
Both of which solutions use the floor operator, //. I checked the solutions just to be sure what I was using had been used before and sure enough my solution looks almost identical. Still received the same error. I had some time at work to test this again and just pulled an old solution from two months ago and ran it through busted and received the same error again twice. I think there might be a bug here that is causing issues with busted not properly parsing the solution and kicking back errors. I’ll likely submit the solution without a problem but I just wanted to bring this to attention with busted.
local cars = {}
-- returns the amount of working cars produced by the assembly line every hour
function cars.calculate_working_cars_per_hour(production_rate, success_rate)
return production_rate * success_rate / 100
end
-- returns the amount of working cars produced by the assembly line every minute
function cars.calculate_working_cars_per_minute(production_rate, success_rate)
return cars.calculate_working_cars_per_hour(production_rate, success_rate) // 60
end
-- returns the cost of producing the given number of cars
function cars.calculate_cost(cars_count)
return (cars_count // 10) * 95000 + (cars_count % 10) * 10000
end
return cars
I did a bit more testing now that I am home. I commented out the last two functions that include // and ran busted and received a single success. With both, or either, uncommented, I receive no success on the first function that does not use //.
With everything uncommented:
0 successes / 0 failures / 1 error / 0 pending : 0.000436 seconds
Error → ./cars-assemble_spec.lua @ 1
suite ./cars-assemble_spec.lua
./cars-assemble_spec.lua:1: error loading module 'cars-assemble' from file './cars-assemble.lua':
./cars-assemble.lua:10: unexpected symbol near '/'
When commented:
1 success / 0 failures / 2 errors / 0 pending : 0.00164 seconds
Error → ./cars-assemble_spec.lua @ 12
cars assemble should return the amount of working cars produced by the assembly line every minute
./cars-assemble_spec.lua:13: attempt to call field 'calculate_working_cars_per_minute' (a nil value)
Error → ./cars-assemble_spec.lua @ 20
cars assemble should return the cost of producing the given number of cars
./cars-assemble_spec.lua:21: attempt to call field 'calculate_cost' (a nil value)
I managed to figure out the issue and it was due to the fact that luarocks in the mantic repository for ubuntu was using lua 5.1 to build against, it would dl it every time I would install.
I uninstalled all versions of lua except 5.4, and dled lua5.3 and bleeding edge luarocks, i had to compile from source. When I installed busted it used 5.3 and when I reran busted it worked successfully.