From b482ed9c30cddac31dcff2d19e517bf20af30d10 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 27 May 2024 14:47:56 +0200 Subject: More string_view --- tests/nameof.lua | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/nameof.lua b/tests/nameof.lua index 221c893..79d5760 100644 --- a/tests/nameof.lua +++ b/tests/nameof.lua @@ -1,5 +1,25 @@ -lanes = require "lanes".configure() +local lanes = require "lanes".configure() -print( lanes.nameof( {})) -print( lanes.nameof( string.sub)) -print( lanes.nameof( print)) +print("Name of table: ", lanes.nameof({})) +print("Name of string.sub: ", lanes.nameof(string.sub)) +print("Name of print: ", lanes.nameof(print)) + +-- a standalone function without any dependency +local body = function() + local n = 0 + for i = 1, 1e30 do + n = n + 1 + end +end + +-- start the lane without any library +local h = lanes.gen(nil, body)() +lanes.sleep(0.1) +print("Name of lane: ", lanes.nameof(h), "("..h.status..")") +assert(h.status == "running") +-- cancel the lane +h:cancel("line", 1) +lanes.sleep(0.1) +print("Name of lane: ", lanes.nameof(h), "("..h.status..")") +assert(h.status == "cancelled") +print "TEST OK" \ No newline at end of file -- cgit v1.2.3-55-g6feb