From 694611627265e4ecb8b0e7623f7d9f82812695e3 Mon Sep 17 00:00:00 2001 From: Arne Döring Date: Tue, 20 Nov 2018 11:08:18 +0100 Subject: fix for nimInAction --- tests/niminaction/Chapter3/ChatApp/src/client.nim | 4 ++++ tests/niminaction/Chapter3/ChatApp/src/server.nim | 6 ++++- tests/niminaction/Chapter3/various3.nim | 29 +++++++++++++---------- 3 files changed, 26 insertions(+), 13 deletions(-) (limited to 'tests/niminaction/Chapter3') diff --git a/tests/niminaction/Chapter3/ChatApp/src/client.nim b/tests/niminaction/Chapter3/ChatApp/src/client.nim index 4d139655c..d479ebf43 100644 --- a/tests/niminaction/Chapter3/ChatApp/src/client.nim +++ b/tests/niminaction/Chapter3/ChatApp/src/client.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + import os, threadpool, asyncdispatch, asyncnet import protocol diff --git a/tests/niminaction/Chapter3/ChatApp/src/server.nim b/tests/niminaction/Chapter3/ChatApp/src/server.nim index 8c572aeb0..31da74d16 100644 --- a/tests/niminaction/Chapter3/ChatApp/src/server.nim +++ b/tests/niminaction/Chapter3/ChatApp/src/server.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + import asyncdispatch, asyncnet type @@ -81,4 +85,4 @@ when isMainModule: echo("Server initialised!") # Execute the ``loop`` procedure. The ``waitFor`` procedure will run the # asyncdispatch event loop until the ``loop`` procedure finishes executing. - waitFor loop(server) \ No newline at end of file + waitFor loop(server) diff --git a/tests/niminaction/Chapter3/various3.nim b/tests/niminaction/Chapter3/various3.nim index 478229b00..7b2776d70 100644 --- a/tests/niminaction/Chapter3/various3.nim +++ b/tests/niminaction/Chapter3/various3.nim @@ -1,3 +1,9 @@ +discard """ +output: ''' +Future is no longer empty, 42 +''' +""" + import threadpool proc foo: string = "Dog" var x: FlowVar[string] = spawn foo() @@ -33,9 +39,9 @@ let data = """ {"username": "Dominik"} """ -let obj = parseJson(data) -assert obj.kind == JObject -assert obj["username"].kind == JString +let obj = parseJson(data) +assert obj.kind == JObject +assert obj["username"].kind == JString assert obj["username"].str == "Dominik" block: @@ -60,12 +66,12 @@ var amy = Human(name: "Amy", age: 20) import asyncdispatch -var future = newFuture[int]() -doAssert(not future.finished) +var future = newFuture[int]() +doAssert(not future.finished) -future.callback = - proc (future: Future[int]) = - echo("Future is no longer empty, ", future.read) +future.callback = + proc (future: Future[int]) = + echo("Future is no longer empty, ", future.read) future.complete(42) @@ -85,9 +91,8 @@ import asyncdispatch, asyncfile, os proc readFiles() {.async.} = # --- Changed to getTempDir here. var file = openAsync(getTempDir() / "test.txt", fmReadWrite) - let data = await file.readAll() - echo(data) - await file.write("Hello!\n") + let data = await file.readAll() + echo(data) + await file.write("Hello!\n") waitFor readFiles() - -- cgit 1.4.1-2-gfad0