diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-06 13:54:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-06 13:54:01 -0300 |
commit | d39ea8b3ce684728c1ad5005192766d39d2e8baa (patch) | |
tree | a6366af9c0fb14af5b244b609cbc3da2b652b798 /testes | |
parent | 6298903e35217ab69c279056f925fb72900ce0b7 (diff) | |
download | lua-d39ea8b3ce684728c1ad5005192766d39d2e8baa.tar.gz lua-d39ea8b3ce684728c1ad5005192766d39d2e8baa.tar.bz2 lua-d39ea8b3ce684728c1ad5005192766d39d2e8baa.zip |
Make sure that main thread is non yieldable
Main thread must be non yieldable even at "level 0" (bare API), outside
the 'pcall' from 'lua.c'.
Diffstat (limited to 'testes')
-rw-r--r-- | testes/coroutine.lua | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 0a4c2ef3..955f6776 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua | |||
@@ -407,7 +407,8 @@ assert(_G.f() == 12) | |||
407 | 407 | ||
408 | 408 | ||
409 | if not T then | 409 | if not T then |
410 | (Message or print)('\n >>> testC not active: skipping yield/hook tests <<<\n') | 410 | (Message or print) |
411 | ('\n >>> testC not active: skipping coroutine API tests <<<\n') | ||
411 | else | 412 | else |
412 | print "testing yields inside hooks" | 413 | print "testing yields inside hooks" |
413 | 414 | ||
@@ -564,8 +565,17 @@ else | |||
564 | c == "ERRRUN" and d == 4) | 565 | c == "ERRRUN" and d == 4) |
565 | 566 | ||
566 | 567 | ||
567 | -- using a main thread as a coroutine | 568 | -- using a main thread as a coroutine (dubious use!) |
568 | local state = T.newstate() | 569 | local state = T.newstate() |
570 | |||
571 | -- check that yielddable is working correctly | ||
572 | assert(T.testC(state, "newthread; isyieldable -1; remove 1; return 1")) | ||
573 | |||
574 | -- main thread is not yieldable | ||
575 | assert(not T.testC(state, "rawgeti R 1; isyieldable -1; remove 1; return 1")) | ||
576 | |||
577 | T.testC(state, "settop 0") | ||
578 | |||
569 | T.loadlib(state) | 579 | T.loadlib(state) |
570 | 580 | ||
571 | assert(T.doremote(state, [[ | 581 | assert(T.doremote(state, [[ |