aboutsummaryrefslogtreecommitdiff
path: root/unit_tests/init_and_shutdown.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--unit_tests/init_and_shutdown.cpp620
1 files changed, 354 insertions, 266 deletions
diff --git a/unit_tests/init_and_shutdown.cpp b/unit_tests/init_and_shutdown.cpp
index 384af43..69e4f1b 100644
--- a/unit_tests/init_and_shutdown.cpp
+++ b/unit_tests/init_and_shutdown.cpp
@@ -3,7 +3,7 @@
3 3
4// ################################################################################################# 4// #################################################################################################
5 5
6TEST_CASE("lanes.require 'lanes'") 6TEST_CASE("Lua.require_lanes")
7{ 7{
8 LuaState L{ LuaState::WithBaseLibs{ false }, LuaState::WithFixture{ false } }; 8 LuaState L{ LuaState::WithBaseLibs{ false }, LuaState::WithFixture{ false } };
9 9
@@ -58,7 +58,7 @@ TEST_CASE("lanes.require 'lanes'")
58// ################################################################################################# 58// #################################################################################################
59 59
60// allocator should be "protected", a C function returning a suitable userdata, or nil 60// allocator should be "protected", a C function returning a suitable userdata, or nil
61TEST_CASE("lanes.configure.allocator") 61TEST_CASE("lanes.configure.allocator/bool_number_table_string")
62{ 62{
63 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; 63 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
64 64
@@ -90,49 +90,33 @@ TEST_CASE("lanes.configure.allocator")
90 90
91 // --------------------------------------------------------------------------------------------- 91 // ---------------------------------------------------------------------------------------------
92 92
93 SECTION("allocator = <Lua function>")
94 {
95 L.requireFailure("require 'lanes'.configure{allocator = function() return {}, 12, 'yoy' end}");
96 }
97
98 // ---------------------------------------------------------------------------------------------
99
100 SECTION("allocator = <bad C function>")
101 {
102 // a C function that doesn't return what we expect should cause an error too
103 // TODO: for some reason, we use os.getenv here because using 'print' as the culprit, the tests deadlock in Release builds
104 L.requireFailure("return type(require 'lanes'.configure{allocator = os.getenv})");
105 }
106
107 // ---------------------------------------------------------------------------------------------
108
109 SECTION("allocator = <string with a typo>") 93 SECTION("allocator = <string with a typo>")
110 { 94 {
111 // oops, a typo 95 // oops, a typo
112 L.requireFailure("require 'lanes'.configure{allocator = 'Protected'}"); 96 L.requireFailure("require 'lanes'.configure{allocator = 'Protected'}");
113 } 97 }
98}
99
100// #################################################################################################
101
102TEST_CASE("lanes.configure.allocator/bad_functions")
103{
104 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
114 105
115 // --------------------------------------------------------------------------------------------- 106 // ---------------------------------------------------------------------------------------------
116 107
117 SECTION("allocator = 'protected'") 108 SECTION("allocator = <Lua function>")
118 { 109 {
119 // no typo, should work 110 L.requireFailure("require 'lanes'.configure{allocator = function() return {}, 12, 'yoy' end}");
120 L.requireSuccess("require 'lanes'.configure{allocator = 'protected'}");
121 } 111 }
122 112
123 // --------------------------------------------------------------------------------------------- 113 // ---------------------------------------------------------------------------------------------
124 114
125 SECTION("allocator = <good custom C allocator>") 115 SECTION("allocator = <bad C function>")
126 { 116 {
127 // a function that provides what we expect is fine 117 // a C function that doesn't return what we expect should cause an error too
128 static constexpr lua_CFunction _provideAllocator = +[](lua_State* const L_) { 118 // TODO: for some reason, we use os.getenv here because using 'print' as the culprit, the tests deadlock in Release builds
129 lanes::AllocatorDefinition* const _def{ new (L_) lanes::AllocatorDefinition{} }; 119 L.requireFailure("return type(require 'lanes'.configure{allocator = os.getenv})");
130 _def->initFrom(L_);
131 return 1;
132 };
133 lua_pushcfunction(L, _provideAllocator);
134 lua_setglobal(L, "ProvideAllocator");
135 L.requireSuccess("require 'lanes'.configure{allocator = ProvideAllocator}");
136 } 120 }
137 121
138 // --------------------------------------------------------------------------------------------- 122 // ---------------------------------------------------------------------------------------------
@@ -191,6 +175,39 @@ TEST_CASE("lanes.configure.allocator")
191 175
192// ################################################################################################# 176// #################################################################################################
193 177
178TEST_CASE("lanes.configure.allocator/good_function")
179{
180 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
181
182 SECTION("allocator = <good custom C allocator>")
183 {
184 // a function that provides what we expect is fine
185 static constexpr lua_CFunction _provideAllocator = +[](lua_State* const L_) {
186 lanes::AllocatorDefinition* const _def{ new (L_) lanes::AllocatorDefinition{} };
187 _def->initFrom(L_);
188 return 1;
189 };
190 lua_pushcfunction(L, _provideAllocator);
191 lua_setglobal(L, "ProvideAllocator");
192 L.requireSuccess("require 'lanes'.configure{allocator = ProvideAllocator}");
193 }
194}
195
196// #################################################################################################
197
198// TODO: investigate why this test crashes under AppVerifier on lanes_core.dll unload when running against Lua 5.1, 5.2 and 5.4 RELEASE ONLY!
199// apparently, the mutex of ProtectedAllocator is deemed still in use. Crash goes away if I don't use it in protected_lua_Alloc
200TEST_CASE(("lanes.configure.allocator/protected"))
201{
202 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
203
204 // no typo, should work
205 L.requireSuccess("require 'lanes'.configure{allocator = 'protected'}");
206}
207
208
209// #################################################################################################
210
194TEST_CASE("lanes.configure.internal_allocator") 211TEST_CASE("lanes.configure.internal_allocator")
195{ 212{
196 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; 213 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
@@ -289,6 +306,62 @@ TEST_CASE("lanes.configure.keepers_gc_threshold")
289 306
290// ################################################################################################# 307// #################################################################################################
291 308
309TEST_CASE("lanes.configure.linda_wake_period")
310{
311 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
312
313 // linda_wake_period should be a number > 0, or 'never'
314
315 SECTION("linda_wake_period = <table>")
316 {
317 L.requireFailure("require 'lanes'.configure{linda_wake_period = {}}");
318 }
319
320 // ---------------------------------------------------------------------------------------------
321
322 SECTION("linda_wake_period = <string>")
323 {
324 L.requireFailure("require 'lanes'.configure{linda_wake_period = 'gluh'}");
325 }
326
327 // ---------------------------------------------------------------------------------------------
328
329 SECTION("linda_wake_period = 'never'")
330 {
331 L.requireSuccess("require 'lanes'.configure{linda_wake_period = 'never'}");
332 }
333
334 // ---------------------------------------------------------------------------------------------
335
336 SECTION("linda_wake_period = <negative number>")
337 {
338 L.requireFailure("require 'lanes'.configure{linda_wake_period = -0.001}");
339 }
340
341 // ---------------------------------------------------------------------------------------------
342
343 SECTION("linda_wake_period = 0")
344 {
345 L.requireFailure("require 'lanes'.configure{linda_wake_period = 0}");
346 }
347
348 // ---------------------------------------------------------------------------------------------
349
350 SECTION("linda_wake_period = 0.0001s")
351 {
352 L.requireSuccess("require 'lanes'.configure{linda_wake_period = 0.0001}");
353 }
354
355 // ---------------------------------------------------------------------------------------------
356
357 SECTION("linda_wake_period = 1e30")
358 {
359 L.requireSuccess("require 'lanes'.configure{linda_wake_period = 1e30}");
360 }
361}
362
363// #################################################################################################
364
292TEST_CASE("lanes.configure.nb_user_keepers") 365TEST_CASE("lanes.configure.nb_user_keepers")
293{ 366{
294 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; 367 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
@@ -300,35 +373,35 @@ TEST_CASE("lanes.configure.nb_user_keepers")
300 L.requireFailure("require 'lanes'.configure{nb_user_keepers = {}}"); 373 L.requireFailure("require 'lanes'.configure{nb_user_keepers = {}}");
301 } 374 }
302 375
303 // ----------------------------------------------------------------------------------------- 376 // ---------------------------------------------------------------------------------------------
304 377
305 SECTION("nb_user_keepers = <string>") 378 SECTION("nb_user_keepers = <string>")
306 { 379 {
307 L.requireFailure("require 'lanes'.configure{nb_user_keepers = 'gluh'}"); 380 L.requireFailure("require 'lanes'.configure{nb_user_keepers = 'gluh'}");
308 } 381 }
309 382
310 // ----------------------------------------------------------------------------------------- 383 // ---------------------------------------------------------------------------------------------
311 384
312 SECTION("nb_user_keepers = -1") 385 SECTION("nb_user_keepers = -1")
313 { 386 {
314 L.requireFailure("require 'lanes'.configure{nb_user_keepers = -1}"); 387 L.requireFailure("require 'lanes'.configure{nb_user_keepers = -1}");
315 } 388 }
316 389
317 // ----------------------------------------------------------------------------------------- 390 // ---------------------------------------------------------------------------------------------
318 391
319 SECTION("nb_user_keepers = 0") 392 SECTION("nb_user_keepers = 0")
320 { 393 {
321 L.requireSuccess("require 'lanes'.configure{nb_user_keepers = 0}"); 394 L.requireSuccess("require 'lanes'.configure{nb_user_keepers = 0}");
322 } 395 }
323 396
324 // ----------------------------------------------------------------------------------------- 397 // ---------------------------------------------------------------------------------------------
325 398
326 SECTION("nb_user_keepers = 1") 399 SECTION("nb_user_keepers = 1")
327 { 400 {
328 L.requireSuccess("require 'lanes'.configure{nb_user_keepers = 1}"); 401 L.requireSuccess("require 'lanes'.configure{nb_user_keepers = 1}");
329 } 402 }
330 403
331 // ----------------------------------------------------------------------------------------- 404 // ---------------------------------------------------------------------------------------------
332 405
333 SECTION("nb_user_keepers = 100") 406 SECTION("nb_user_keepers = 100")
334 { 407 {
@@ -345,340 +418,355 @@ TEST_CASE("lanes.configure.nb_user_keepers")
345 418
346// ################################################################################################# 419// #################################################################################################
347 420
348TEST_CASE("lanes.configure.the rest") 421TEST_CASE("lanes.configure.on_state_create/configuration")
349{ 422{
350 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; 423 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
351 424
352 // on_state_create should be a function, either C or Lua, without upvalues 425 // on_state_create should be a function, either C or Lua, without upvalues
353 426
354 SECTION("on_state_create") 427 SECTION("on_state_create = <table>")
355 { 428 {
356 SECTION("on_state_create = <table>") 429 L.requireFailure("require 'lanes'.configure{on_state_create = {}}");
357 { 430 }
358 L.requireFailure("require 'lanes'.configure{on_state_create = {}}");
359 }
360 431
361 // ----------------------------------------------------------------------------------------- 432 // ---------------------------------------------------------------------------------------------
362 433
363 SECTION("on_state_create = <string>") 434 SECTION("on_state_create = <string>")
364 { 435 {
365 L.requireFailure("require 'lanes'.configure{on_state_create = 'gluh'}"); 436 L.requireFailure("require 'lanes'.configure{on_state_create = 'gluh'}");
366 } 437 }
367 438
368 // ----------------------------------------------------------------------------------------- 439 // ---------------------------------------------------------------------------------------------
369 440
370 SECTION("on_state_create = <number>") 441 SECTION("on_state_create = <number>")
371 { 442 {
372 L.requireFailure("require 'lanes'.configure{on_state_create = 1}"); 443 L.requireFailure("require 'lanes'.configure{on_state_create = 1}");
373 } 444 }
374 445
375 // ----------------------------------------------------------------------------------------- 446 // ---------------------------------------------------------------------------------------------
376 447
377 SECTION("on_state_create = false") 448 SECTION("on_state_create = false")
378 { 449 {
379 L.requireFailure("require 'lanes'.configure{on_state_create = false}"); 450 L.requireFailure("require 'lanes'.configure{on_state_create = false}");
380 } 451 }
381 452
382 // ----------------------------------------------------------------------------------------- 453 // ---------------------------------------------------------------------------------------------
383 454
384 SECTION("on_state_create = true") 455 SECTION("on_state_create = true")
385 { 456 {
386 L.requireFailure("require 'lanes'.configure{on_state_create = true}"); 457 L.requireFailure("require 'lanes'.configure{on_state_create = true}");
387 } 458 }
388 459
389 // ----------------------------------------------------------------------------------------- 460 // ---------------------------------------------------------------------------------------------
390 461
391 SECTION("on_state_create = <Lua function>") 462 SECTION("on_state_create = <Lua function>")
392 { 463 {
393 // on_state_create isn't called inside a Keeper state if it's a Lua function (which is good as print() doesn't exist there!) 464 // on_state_create isn't called inside a Keeper state if it's a Lua function (which is good as print() doesn't exist there!)
394 L.requireSuccess("local print = print; require 'lanes'.configure{on_state_create = function() print 'hello' end}"); 465 L.requireSuccess("local print = print; require 'lanes'.configure{on_state_create = function() print 'hello' end}");
395 } 466 }
396 467
397 // ----------------------------------------------------------------------------------------- 468 // ---------------------------------------------------------------------------------------------
398 469
399 SECTION("on_state_create = <C function>") 470 SECTION("on_state_create = <C function>")
400 { 471 {
401 // funnily enough, in Lua 5.3, print() uses global tostring(), that doesn't exist in a keeper since we didn't open libs -> "attempt to call a nil value" 472 // funnily enough, in Lua 5.3, print() uses global tostring(), that doesn't exist in a keeper since we didn't open libs -> "attempt to call a nil value"
402 // conclusion, don't use print() as a fake on_state_create() callback! 473 // conclusion, don't use print() as a fake on_state_create() callback!
403 // assert() should be fine since we pass a non-false argument to on_state_create 474 // assert() should be fine since we pass a non-false argument to on_state_create
404 L.requireSuccess("require 'lanes'.configure{on_state_create = assert}"); 475 L.requireSuccess("require 'lanes'.configure{on_state_create = assert}");
405 }
406 } 476 }
477}
478
479// #################################################################################################
480
481TEST_CASE("lanes.configure.shutdown_timeout")
482{
483 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
407 484
408 // ---------------------------------------------------------------------------------------------
409 // shutdown_timeout should be a number in [0,3600] 485 // shutdown_timeout should be a number in [0,3600]
410 486
411 SECTION("shutdown_timeout") 487 SECTION("shutdown_timeout = <table>")
412 { 488 {
413 SECTION("shutdown_timeout = <table>") 489 L.requireFailure("require 'lanes'.configure{shutdown_timeout = {}}");
414 { 490 }
415 L.requireFailure("require 'lanes'.configure{shutdown_timeout = {}}");
416 }
417 491
418 // ----------------------------------------------------------------------------------------- 492 // ---------------------------------------------------------------------------------------------
419 493
420 SECTION("shutdown_timeout = <string>") 494 SECTION("shutdown_timeout = <string>")
421 { 495 {
422 L.requireFailure("require 'lanes'.configure{shutdown_timeout = 'gluh'}"); 496 L.requireFailure("require 'lanes'.configure{shutdown_timeout = 'gluh'}");
423 } 497 }
424 498
425 // ----------------------------------------------------------------------------------------- 499 // ---------------------------------------------------------------------------------------------
426 500
427 SECTION("shutdown_timeout = <negative number>") 501 SECTION("shutdown_timeout = <negative number>")
428 { 502 {
429 L.requireFailure("require 'lanes'.configure{shutdown_timeout = -0.001}"); 503 L.requireFailure("require 'lanes'.configure{shutdown_timeout = -0.001}");
430 } 504 }
431 505
432 // ----------------------------------------------------------------------------------------- 506 // ---------------------------------------------------------------------------------------------
433 507
434 SECTION("shutdown_timeout = 0") 508 SECTION("shutdown_timeout = 0")
435 { 509 {
436 L.requireSuccess("require 'lanes'.configure{shutdown_timeout = 0}"); 510 L.requireSuccess("require 'lanes'.configure{shutdown_timeout = 0}");
437 } 511 }
438 512
439 // ----------------------------------------------------------------------------------------- 513 // ---------------------------------------------------------------------------------------------
440 514
441 SECTION("shutdown_timeout = 1s") 515 SECTION("shutdown_timeout = 1s")
442 { 516 {
443 L.requireSuccess("require 'lanes'.configure{shutdown_timeout = 1}"); 517 L.requireSuccess("require 'lanes'.configure{shutdown_timeout = 1}");
444 } 518 }
445 519
446 // ----------------------------------------------------------------------------------------- 520 // ---------------------------------------------------------------------------------------------
447 521
448 SECTION("shutdown_timeout = 3600s") 522 SECTION("shutdown_timeout = 3600s")
449 { 523 {
450 L.requireSuccess("require 'lanes'.configure{shutdown_timeout = 3600}"); 524 L.requireSuccess("require 'lanes'.configure{shutdown_timeout = 3600}");
451 } 525 }
452 526
453 // ----------------------------------------------------------------------------------------- 527 // ---------------------------------------------------------------------------------------------
454 528
455 SECTION("shutdown_timeout = <too long>") 529 SECTION("shutdown_timeout = <too long>")
456 { 530 {
457 L.requireFailure("require 'lanes'.configure{shutdown_timeout = 3600.001}"); 531 L.requireFailure("require 'lanes'.configure{shutdown_timeout = 3600.001}");
458 }
459 } 532 }
533}
534
535// #################################################################################################
536
537TEST_CASE("lanes.configure.strip_functions")
538{
539 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
460 540
461 // ---------------------------------------------------------------------------------------------
462 // strip_functions should be a boolean 541 // strip_functions should be a boolean
463 542
464 SECTION("strip_functions") 543 SECTION("strip_functions = <table>")
465 { 544 {
466 SECTION("strip_functions = <table>") 545 L.requireFailure("require 'lanes'.configure{strip_functions = {}}");
467 { 546 }
468 L.requireFailure("require 'lanes'.configure{strip_functions = {}}");
469 }
470 547
471 // ----------------------------------------------------------------------------------------- 548 // ---------------------------------------------------------------------------------------------
472 549
473 SECTION("strip_functions = <string>") 550 SECTION("strip_functions = <string>")
474 { 551 {
475 L.requireFailure("require 'lanes'.configure{strip_functions = 'gluh'}"); 552 L.requireFailure("require 'lanes'.configure{strip_functions = 'gluh'}");
476 } 553 }
477 554
478 // ----------------------------------------------------------------------------------------- 555 // ---------------------------------------------------------------------------------------------
479 556
480 SECTION("strip_functions = <number>") 557 SECTION("strip_functions = <number>")
481 { 558 {
482 L.requireFailure("require 'lanes'.configure{strip_functions = 1}"); 559 L.requireFailure("require 'lanes'.configure{strip_functions = 1}");
483 } 560 }
484 561
485 // ----------------------------------------------------------------------------------------- 562 // ---------------------------------------------------------------------------------------------
486 563
487 SECTION("strip_functions = <C function>") 564 SECTION("strip_functions = <C function>")
488 { 565 {
489 L.requireFailure("require 'lanes'.configure{strip_functions = print}"); 566 L.requireFailure("require 'lanes'.configure{strip_functions = print}");
490 } 567 }
491 568
492 // ----------------------------------------------------------------------------------------- 569 // ---------------------------------------------------------------------------------------------
493 570
494 SECTION("strip_functions = false") 571 SECTION("strip_functions = false")
495 { 572 {
496 L.requireSuccess("require 'lanes'.configure{strip_functions = false}"); 573 L.requireSuccess("require 'lanes'.configure{strip_functions = false}");
497 } 574 }
498 575
499 // ----------------------------------------------------------------------------------------- 576 // ---------------------------------------------------------------------------------------------
500 577
501 SECTION("strip_functions = true") 578 SECTION("strip_functions = true")
502 { 579 {
503 L.requireSuccess("require 'lanes'.configure{strip_functions = true}"); 580 L.requireSuccess("require 'lanes'.configure{strip_functions = true}");
504 }
505 } 581 }
582}
583
584// #################################################################################################
585
586TEST_CASE("lanes.configure.track_lanes")
587{
588 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
506 589
507 // ---------------------------------------------------------------------------------------------
508 // track_lanes should be a boolean 590 // track_lanes should be a boolean
509 591
510 SECTION("track_lanes") 592 SECTION("track_lanes = <table>")
511 { 593 {
512 SECTION("track_lanes = <table>") 594 L.requireFailure("require 'lanes'.configure{track_lanes = {}}");
513 { 595 }
514 L.requireFailure("require 'lanes'.configure{track_lanes = {}}");
515 }
516 596
517 // ----------------------------------------------------------------------------------------- 597 // ---------------------------------------------------------------------------------------------
518 598
519 SECTION("track_lanes = <string>") 599 SECTION("track_lanes = <string>")
520 { 600 {
521 L.requireFailure("require 'lanes'.configure{track_lanes = 'gluh'}"); 601 L.requireFailure("require 'lanes'.configure{track_lanes = 'gluh'}");
522 } 602 }
523 603
524 // ----------------------------------------------------------------------------------------- 604 // ---------------------------------------------------------------------------------------------
525 605
526 SECTION("track_lanes = <number>") 606 SECTION("track_lanes = <number>")
527 { 607 {
528 L.requireFailure("require 'lanes'.configure{track_lanes = 1}"); 608 L.requireFailure("require 'lanes'.configure{track_lanes = 1}");
529 } 609 }
530 610
531 // ----------------------------------------------------------------------------------------- 611 // ---------------------------------------------------------------------------------------------
532 612
533 SECTION("track_lanes = <C function>") 613 SECTION("track_lanes = <C function>")
534 { 614 {
535 L.requireFailure("require 'lanes'.configure{track_lanes = print}"); 615 L.requireFailure("require 'lanes'.configure{track_lanes = print}");
536 } 616 }
537 617
538 // ----------------------------------------------------------------------------------------- 618 // ---------------------------------------------------------------------------------------------
539 619
540 SECTION("track_lanes = false") 620 SECTION("track_lanes = false")
541 { 621 {
542 L.requireSuccess("require 'lanes'.configure{track_lanes = false}"); 622 L.requireSuccess("require 'lanes'.configure{track_lanes = false}");
543 } 623 }
544 624
545 // ----------------------------------------------------------------------------------------- 625 // ---------------------------------------------------------------------------------------------
546 626
547 SECTION("track_lanes = true") 627 SECTION("track_lanes = true")
548 { 628 {
549 L.requireSuccess("require 'lanes'.configure{track_lanes = true}"); 629 L.requireSuccess("require 'lanes'.configure{track_lanes = true}");
550 }
551 } 630 }
631}
632
633// #################################################################################################
634
635TEST_CASE("lanes.configure.verbose_errors")
636{
637 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
552 638
553 // ---------------------------------------------------------------------------------------------
554 // verbose_errors should be a boolean 639 // verbose_errors should be a boolean
555 640
556 SECTION("verbose_errors") 641 SECTION("verbose_errors = <table>")
557 { 642 {
558 SECTION("verbose_errors = <table>") 643 L.requireFailure("require 'lanes'.configure{verbose_errors = {}}");
559 { 644 }
560 L.requireFailure("require 'lanes'.configure{verbose_errors = {}}");
561 }
562 645
563 // ----------------------------------------------------------------------------------------- 646 // ---------------------------------------------------------------------------------------------
564 647
565 SECTION("verbose_errors = <string>") 648 SECTION("verbose_errors = <string>")
566 { 649 {
567 L.requireFailure("require 'lanes'.configure{verbose_errors = 'gluh'}"); 650 L.requireFailure("require 'lanes'.configure{verbose_errors = 'gluh'}");
568 } 651 }
569 652
570 // ----------------------------------------------------------------------------------------- 653 // ---------------------------------------------------------------------------------------------
571 654
572 SECTION("verbose_errors = <number>") 655 SECTION("verbose_errors = <number>")
573 { 656 {
574 L.requireFailure("require 'lanes'.configure{verbose_errors = 1}"); 657 L.requireFailure("require 'lanes'.configure{verbose_errors = 1}");
575 } 658 }
576 659
577 // ----------------------------------------------------------------------------------------- 660 // ---------------------------------------------------------------------------------------------
578 661
579 SECTION("verbose_errors = <C function>") 662 SECTION("verbose_errors = <C function>")
580 { 663 {
581 L.requireFailure("require 'lanes'.configure{verbose_errors = print}"); 664 L.requireFailure("require 'lanes'.configure{verbose_errors = print}");
582 } 665 }
583 666
584 // ----------------------------------------------------------------------------------------- 667 // ---------------------------------------------------------------------------------------------
585 668
586 SECTION("verbose_errors = false") 669 SECTION("verbose_errors = false")
587 { 670 {
588 L.requireSuccess("require 'lanes'.configure{verbose_errors = false}"); 671 L.requireSuccess("require 'lanes'.configure{verbose_errors = false}");
589 } 672 }
590 673
591 // ----------------------------------------------------------------------------------------- 674 // ---------------------------------------------------------------------------------------------
592 675
593 SECTION("verbose_errors = true") 676 SECTION("verbose_errors = true")
594 { 677 {
595 L.requireSuccess("require 'lanes'.configure{verbose_errors = true}"); 678 L.requireSuccess("require 'lanes'.configure{verbose_errors = true}");
596 }
597 } 679 }
680}
681
682// #################################################################################################
683
684TEST_CASE("lanes.configure.with_timers")
685{
686 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
598 687
599 // ---------------------------------------------------------------------------------------------
600 // with_timers should be a boolean 688 // with_timers should be a boolean
601 689
602 SECTION("with_timers") 690 SECTION("with_timers = <table>")
603 { 691 {
604 SECTION("with_timers = <table>") 692 L.requireFailure("require 'lanes'.configure{with_timers = {}}");
605 { 693 }
606 L.requireFailure("require 'lanes'.configure{with_timers = {}}");
607 }
608 694
609 // ----------------------------------------------------------------------------------------- 695 // ---------------------------------------------------------------------------------------------
610 696
611 SECTION("with_timers = <string>") 697 SECTION("with_timers = <string>")
612 { 698 {
613 L.requireFailure("require 'lanes'.configure{with_timers = 'gluh'}"); 699 L.requireFailure("require 'lanes'.configure{with_timers = 'gluh'}");
614 } 700 }
615 701
616 // ----------------------------------------------------------------------------------------- 702 // ---------------------------------------------------------------------------------------------
617 703
618 SECTION("with_timers = <number>") 704 SECTION("with_timers = <number>")
619 { 705 {
620 L.requireFailure("require 'lanes'.configure{with_timers = 1}"); 706 L.requireFailure("require 'lanes'.configure{with_timers = 1}");
621 } 707 }
622 708
623 // ----------------------------------------------------------------------------------------- 709 // ---------------------------------------------------------------------------------------------
624 710
625 SECTION("with_timers = <C function>") 711 SECTION("with_timers = <C function>")
626 { 712 {
627 L.requireFailure("require 'lanes'.configure{with_timers = print}"); 713 L.requireFailure("require 'lanes'.configure{with_timers = print}");
628 } 714 }
629 715
630 // ----------------------------------------------------------------------------------------- 716 // ---------------------------------------------------------------------------------------------
631 717
632 SECTION("with_timers = false") 718 SECTION("with_timers = false")
633 { 719 {
634 L.requireSuccess("require 'lanes'.configure{with_timers = false}"); 720 L.requireSuccess("require 'lanes'.configure{with_timers = false}");
635 } 721 }
636 722
637 // ----------------------------------------------------------------------------------------- 723 // ---------------------------------------------------------------------------------------------
638 724
639 SECTION("with_timers = true") 725 SECTION("with_timers = true")
640 { 726 {
641 L.requireSuccess("require 'lanes'.configure{with_timers = true}"); 727 L.requireSuccess("require 'lanes'.configure{with_timers = true}");
642 }
643 } 728 }
729}
730
731// #################################################################################################
732
733TEST_CASE("lanes.configure.unknown_setting")
734{
735 LuaState L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
644 736
645 // ---------------------------------------------------------------------------------------------
646 // any unknown setting should be rejected 737 // any unknown setting should be rejected
647 738
648 SECTION("unknown_setting") 739 SECTION("table setting")
649 { 740 {
650 SECTION("table setting") 741 L.requireFailure("require 'lanes'.configure{[{}] = {}}");
651 { 742 }
652 L.requireFailure("require 'lanes'.configure{[{}] = {}}");
653 }
654 743
655 // ----------------------------------------------------------------------------------------- 744 // ---------------------------------------------------------------------------------------------
656 745
657 SECTION("boolean setting") 746 SECTION("boolean setting")
658 { 747 {
659 L.requireFailure("require 'lanes'.configure{[true] = 'gluh'}"); 748 L.requireFailure("require 'lanes'.configure{[true] = 'gluh'}");
660 } 749 }
661 750
662 // ----------------------------------------------------------------------------------------- 751 // ---------------------------------------------------------------------------------------------
663 752
664 SECTION("function setting") 753 SECTION("function setting")
665 { 754 {
666 L.requireFailure("require 'lanes'.configure{[function() end] = 1}"); 755 L.requireFailure("require 'lanes'.configure{[function() end] = 1}");
667 } 756 }
668 757
669 // ----------------------------------------------------------------------------------------- 758 // ---------------------------------------------------------------------------------------------
670 759
671 SECTION("number setting") 760 SECTION("number setting")
672 { 761 {
673 L.requireFailure("require 'lanes'.configure{[1] = function() end}"); 762 L.requireFailure("require 'lanes'.configure{[1] = function() end}");
674 } 763 }
675 764
676 // ----------------------------------------------------------------------------------------- 765 // ---------------------------------------------------------------------------------------------
677 766
678 SECTION("unknown string setting") 767 SECTION("unknown string setting")
679 { 768 {
680 L.requireFailure("require 'lanes'.configure{['gluh'] = false}"); 769 L.requireFailure("require 'lanes'.configure{['gluh'] = false}");
681 }
682 } 770 }
683} 771}
684 772
@@ -687,7 +775,7 @@ TEST_CASE("lanes.configure.the rest")
687 775
688#if LUAJIT_FLAVOR() == 0 776#if LUAJIT_FLAVOR() == 0
689// TODO: this test crashes inside S.close() against LuaJIT. to be investigated 777// TODO: this test crashes inside S.close() against LuaJIT. to be investigated
690TEST_CASE("lanes.finally.no fixture") 778TEST_CASE("lanes.finally.no_fixture")
691{ 779{
692 LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; 780 LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
693 // we need Lanes to be up. Since we run several 'scripts', we store it as a global 781 // we need Lanes to be up. Since we run several 'scripts', we store it as a global
@@ -708,7 +796,7 @@ TEST_CASE("lanes.finally.no fixture")
708 796
709// ################################################################################################# 797// #################################################################################################
710 798
711TEST_CASE("lanes.finally.with fixture") 799TEST_CASE("lanes.finally.with_fixture")
712{ 800{
713 LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ true } }; 801 LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ true } };
714 802
@@ -726,7 +814,7 @@ TEST_CASE("lanes.finally.with fixture")
726 814
727// ################################################################################################# 815// #################################################################################################
728 816
729TEST_CASE("lanes.finally.shutdown with an uncooperative lane") 817TEST_CASE("lanes.finally.shutdown_with_an_uncooperative_lane")
730{ 818{
731 LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ true } }; 819 LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ true } };
732 S.requireSuccess("lanes = require 'lanes'.configure()"); 820 S.requireSuccess("lanes = require 'lanes'.configure()");
@@ -775,7 +863,7 @@ namespace
775 863
776// ################################################################################################# 864// #################################################################################################
777 865
778TEST_CASE("lanes.on_state_create setting") 866TEST_CASE("lanes.configure.on_state_create/details")
779{ 867{
780 LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; 868 LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
781 869