From 6faceb3b8c2d8cef4108a2de166588f21562a05a Mon Sep 17 00:00:00 2001 From: cheatfate Date: Wed, 30 May 2018 07:35:27 +0300 Subject: [PATCH] Added removeCallback() test. --- tests/testfut.nim | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/testfut.nim b/tests/testfut.nim index 9b8d81c..df4c9de 100644 --- a/tests/testfut.nim +++ b/tests/testfut.nim @@ -46,6 +46,30 @@ proc test3(): string = if fut.finished: result = testResult +proc test4(): string = + var testResult = "" + var fut = testFuture1() + proc cb1(udata: pointer) = + testResult &= "1" + proc cb2(udata: pointer) = + testResult &= "2" + proc cb3(udata: pointer) = + testResult &= "3" + proc cb4(udata: pointer) = + testResult &= "4" + proc cb5(udata: pointer) = + testResult &= "5" + fut.addCallback cb1 + fut.addCallback cb2 + fut.addCallback cb3 + fut.addCallback cb4 + fut.addCallback cb5 + fut.removeCallback cb3 + discard waitFor(fut) + poll() + if fut.finished: + result = testResult + when isMainModule: suite "Future[T] behavior test suite": test "Async undefined behavior (#7758) test": @@ -54,3 +78,5 @@ when isMainModule: check test2() == true test "Future[T] callbacks are invoked in reverse order (#7197) test": check test3() == "12345" + test "Future[T] callbacks not changing order after removeCallback()": + check test4() == "1245"