summary refs log tree commit diff stats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/allany.nim4
-rw-r--r--examples/c++iface/irrlichtex.nim6
-rw-r--r--examples/cgi/example.nim2
-rw-r--r--examples/cgiex.nim6
-rw-r--r--examples/cross_calculator/android/readme.txt6
-rw-r--r--examples/cross_calculator/ios/readme.txt4
-rw-r--r--examples/cross_calculator/lazarus/readme.txt16
-rw-r--r--examples/cross_calculator/nim_backend/backend.nim10
-rw-r--r--examples/cross_calculator/readme.txt26
-rw-r--r--examples/cross_todo/nim_backend/readme.txt28
-rw-r--r--examples/cross_todo/readme.txt12
-rw-r--r--examples/curlex.nim10
-rw-r--r--examples/filterex.nim6
-rw-r--r--examples/htmlrefs.nim18
-rw-r--r--examples/htmltitle.nim8
-rw-r--r--examples/httpserver2.nim6
-rw-r--r--examples/iupex1.nim37
-rw-r--r--examples/maximum.nim12
-rw-r--r--examples/parsecfgex.nim4
-rw-r--r--examples/readme.txt4
-rw-r--r--examples/sdlex.nim104
-rw-r--r--examples/statcsv.nim2
-rw-r--r--examples/talk/tags.nim2
-rw-r--r--examples/tunit.nim94
-rw-r--r--examples/wingui.nim9
25 files changed, 184 insertions, 252 deletions
diff --git a/examples/allany.nim b/examples/allany.nim
index de36a1d9b..52a794204 100644
--- a/examples/allany.nim
+++ b/examples/allany.nim
@@ -18,9 +18,9 @@ template any(container, cond: expr): expr {.immediate.} =
         break
     result
 
-if all("mystring", {'a'..'z'}.contains) and any("myohmy", 'y'.`==`): 
+if all("mystring", {'a'..'z'}.contains) and any("myohmy", 'y'.`==`):
   echo "works"
-else: 
+else:
   echo "does not work"
 
 
diff --git a/examples/c++iface/irrlichtex.nim b/examples/c++iface/irrlichtex.nim
index 4dd1d79ee..373a78ce7 100644
--- a/examples/c++iface/irrlichtex.nim
+++ b/examples/c++iface/irrlichtex.nim
@@ -18,13 +18,13 @@ type
   TDimension2d {.final, header: irr, importc: "dimension2d".} = object
   Tvector3df {.final, header: irr, importc: "vector3df".} = object
   TColor {.final, header: irr, importc: "SColor".} = object
-  
+
   TIrrlichtDevice {.final, header: irr, importc: "IrrlichtDevice".} = object
   TIVideoDriver {.final, header: irr, importc: "IVideoDriver".} = object
   TISceneManager {.final, header: irr, importc: "ISceneManager".} = object
   TIGUIEnvironment {.final, header: irr, importc: "IGUIEnvironment".} = object
   TIAnimatedMesh {.final, header: irr, importc: "IAnimatedMesh".} = object
-  TIAnimatedMeshSceneNode {.final, header: irr, 
+  TIAnimatedMeshSceneNode {.final, header: irr,
     importc: "IAnimatedMeshSceneNode".} = object
   TITexture {.final, header: irr, importc: "ITexture".} = object
 
@@ -100,7 +100,7 @@ var node = smgr.addAnimatedMeshSceneNode(mesh)
 if node != nil:
   #node->setMaterialFlag(EMF_LIGHTING, false)
   #node->setMD2Animation(scene::EMAT_STAND)
-  node.setMaterialTexture(0, 
+  node.setMaterialTexture(0,
     driver.getTexture(
       "/home/andreas/download/irrlicht-1.7.2/media/media/sydney.bmp"))
 
diff --git a/examples/cgi/example.nim b/examples/cgi/example.nim
index 17629982a..761197cdb 100644
--- a/examples/cgi/example.nim
+++ b/examples/cgi/example.nim
@@ -4,4 +4,4 @@ write(stdout, "Content-type: text/html\n\n")
 write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
 write(stdout, "<html><head><title>Test</title></head><body>\n")
 write(stdout, "Hello!")
-writeln(stdout, "</body></html>")
+writeLine(stdout, "</body></html>")
diff --git a/examples/cgiex.nim b/examples/cgiex.nim
index 7e3292f35..fb55a731a 100644
--- a/examples/cgiex.nim
+++ b/examples/cgiex.nim
@@ -7,6 +7,6 @@ writeContentType()
 
 write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
 write(stdout, "<html><head><title>Test</title></head><body>\n")
-writeln(stdout, "name: " & myData["name"])
-writeln(stdout, "password: " & myData["password"])
-writeln(stdout, "</body></html>")
+writeLine(stdout, "name: " & myData["name"])
+writeLine(stdout, "password: " & myData["password"])
+writeLine(stdout, "</body></html>")
diff --git a/examples/cross_calculator/android/readme.txt b/examples/cross_calculator/android/readme.txt
index 51fa9c6fd..96bd403ca 100644
--- a/examples/cross_calculator/android/readme.txt
+++ b/examples/cross_calculator/android/readme.txt
@@ -20,11 +20,5 @@ installed on your system, you can simply run "ant debug" to build everything.
 Once the apk is built you can install it on your device or emulator with the
 command "adb install bin/CrossCalculator-debug.apk".
 
-You can use this example as a starting point for your project or look at the
-history of the github project at https://github.com/gradha/nimrod-on-android.
-That repository documents the individual integration steps you would take for
-any Android project (note it uses Eclipse rather than ant to build and
-therefore the build process requires more manual fiddling).
-
 This example runs against the Android level 3 API, meaning devices from
 Android 1.5 and above should be able to run the generated binary.
diff --git a/examples/cross_calculator/ios/readme.txt b/examples/cross_calculator/ios/readme.txt
index 83538aad7..3ea03a367 100644
--- a/examples/cross_calculator/ios/readme.txt
+++ b/examples/cross_calculator/ios/readme.txt
@@ -8,10 +8,6 @@ When the calculate button is used the view controller calls the Nim code to
 delegate the logic of the operation and puts the result in a label for display.
 All interface error checks are implemented in the view controller.
 
-You can use this as a starting point for your project or look at the history of
-the github project at https://github.com/gradha/nimrod-on-ios. That repository
-documents the individual integration steps you would take for any iOS project.
-
 This version of the iOS project is known to work with Xcode 4.2 and Xcode
 4.4.1. The final binary can be deployed on iOS 3.x to 5.x supporting all iOS
 platforms and versions available at the moment.
diff --git a/examples/cross_calculator/lazarus/readme.txt b/examples/cross_calculator/lazarus/readme.txt
index 2d5048445..c704d53fd 100644
--- a/examples/cross_calculator/lazarus/readme.txt
+++ b/examples/cross_calculator/lazarus/readme.txt
@@ -1,8 +1,8 @@
-This example demonstrates how to use Nim with Lazarus. The GUI is generated

-with Lazarus, while the "backend" is written in Nim. To compile the example,

-use this command:

-

-  nim c --app:gui --no_main --no_linking backend.nim

-

-Open the ``nimlaz.lpi`` file in Lazarus and run the program.

-

+This example demonstrates how to use Nim with Lazarus. The GUI is generated
+with Lazarus, while the "backend" is written in Nim. To compile the example,
+use this command:
+
+  nim c --app:gui --no_main --no_linking backend.nim
+
+Open the ``nimlaz.lpi`` file in Lazarus and run the program.
+
diff --git a/examples/cross_calculator/nim_backend/backend.nim b/examples/cross_calculator/nim_backend/backend.nim
index ffa4311f9..c8684581c 100644
--- a/examples/cross_calculator/nim_backend/backend.nim
+++ b/examples/cross_calculator/nim_backend/backend.nim
@@ -1,5 +1,5 @@
-# Backend for the different user interfaces.

-

-proc myAdd*(x, y: int): int {.cdecl, exportc.} = 

-  result = x + y

-

+# Backend for the different user interfaces.
+
+proc myAdd*(x, y: int): int {.cdecl, exportc.} =
+  result = x + y
+
diff --git a/examples/cross_calculator/readme.txt b/examples/cross_calculator/readme.txt
index 12ad558d4..5011792b9 100644
--- a/examples/cross_calculator/readme.txt
+++ b/examples/cross_calculator/readme.txt
@@ -1,13 +1,13 @@
-The cross platform calculator illustrates how to use Nim to create a backend

-called by different native user interfaces.

-

-Since the purpose of the example is to show how the cross platform code

-interacts with Nimrod the actual backend code is just a simple addition proc.

-By keeping your program logic in Nim you can easily reuse it in different

-platforms.

-

-To avoid duplication of code, the backend code lies in a separate directory and

-each platform compiles it with a different custom build process, usually

-generating C code in a temporary build directory.

-

-For a more elaborate and useful example see the cross_todo example.

+The cross platform calculator illustrates how to use Nim to create a backend
+called by different native user interfaces.
+
+Since the purpose of the example is to show how the cross platform code
+interacts with Nimrod the actual backend code is just a simple addition proc.
+By keeping your program logic in Nim you can easily reuse it in different
+platforms.
+
+To avoid duplication of code, the backend code lies in a separate directory and
+each platform compiles it with a different custom build process, usually
+generating C code in a temporary build directory.
+
+For a more elaborate and useful example see the cross_todo example.
diff --git a/examples/cross_todo/nim_backend/readme.txt b/examples/cross_todo/nim_backend/readme.txt
index 16cb592fc..4b31408e3 100644
--- a/examples/cross_todo/nim_backend/readme.txt
+++ b/examples/cross_todo/nim_backend/readme.txt
@@ -1,14 +1,14 @@
-This directory contains the nim backend code for the todo cross platform

-example.

-

-Unlike the cross platform calculator example, this backend features more code,

-using an sqlite database for storage. Also a basic test module is provided, not

-to be included with the final program but to test the exported functionality.

-The test is not embedded directly in the backend.nim file to avoid being able

-to access internal data types and procs not exported and replicate the

-environment of client code.

-

-In a bigger project with several people you could run `nim doc backend.nim`

-(or use the doc2 command for a whole project) and provide the generated html

-documentation to another programer for her to implement an interface without

-having to look at the source code.

+This directory contains the nim backend code for the todo cross platform
+example.
+
+Unlike the cross platform calculator example, this backend features more code,
+using an sqlite database for storage. Also a basic test module is provided, not
+to be included with the final program but to test the exported functionality.
+The test is not embedded directly in the backend.nim file to avoid being able
+to access internal data types and procs not exported and replicate the
+environment of client code.
+
+In a bigger project with several people you could run `nim doc backend.nim`
+(or use the doc2 command for a whole project) and provide the generated html
+documentation to another programer for her to implement an interface without
+having to look at the source code.
diff --git a/examples/cross_todo/readme.txt b/examples/cross_todo/readme.txt
index 2e648a35a..5be01e197 100644
--- a/examples/cross_todo/readme.txt
+++ b/examples/cross_todo/readme.txt
@@ -1,7 +1,5 @@
-The cross platform todo illustrates how to use Nim to create a backend

-called by different native user interfaces.

-

-This example builds on the knowledge learned from the cross_calculator example.

-Check it out first to learn how to set up Nim on different platforms.

-Additional implementations are provided at the external

-https://github.com/gradha/nimrod-crossplatform-todo github repository.

+The cross platform todo illustrates how to use Nim to create a backend
+called by different native user interfaces.
+
+This example builds on the knowledge learned from the cross_calculator example.
+Check it out first to learn how to set up Nim on different platforms.
diff --git a/examples/curlex.nim b/examples/curlex.nim
deleted file mode 100644
index 017956818..000000000
--- a/examples/curlex.nim
+++ /dev/null
@@ -1,10 +0,0 @@
-import 
-  libcurl
-
-var hCurl = easy_init()
-if hCurl != nil: 
-  discard easy_setopt(hCurl, OPT_VERBOSE, true)
-  discard easy_setopt(hCurl, OPT_URL, "http://nim-lang.org/")
-  discard easy_perform(hCurl)
-  easy_cleanup(hCurl)
-
diff --git a/examples/filterex.nim b/examples/filterex.nim
index 3713f4b64..083945254 100644
--- a/examples/filterex.nim
+++ b/examples/filterex.nim
@@ -1,6 +1,6 @@
-#! stdtmpl | standard
+#? stdtmpl | standard
 #proc generateHTMLPage(title, currentTab, content: string,
-#                      tabs: openArray[string]): string = 
+#                      tabs: openArray[string]): string =
 #  result = ""
 <head><title>$title</title></head>
 <body>
@@ -8,7 +8,7 @@
     <ul>
   #for tab in items(tabs):
     #if currentTab == tab:
-    <li><a id="selected" 
+    <li><a id="selected"
     #else:
     <li><a
     #end if
diff --git a/examples/htmlrefs.nim b/examples/htmlrefs.nim
index 5364d61b6..394932773 100644
--- a/examples/htmlrefs.nim
+++ b/examples/htmlrefs.nim
@@ -4,11 +4,11 @@
 
 import os, streams, parsexml, strutils
 
-proc `=?=` (a, b: string): bool = 
+proc `=?=` (a, b: string): bool =
   # little trick: define our own comparator that ignores case
   return cmpIgnoreCase(a, b) == 0
 
-if paramCount() < 1: 
+if paramCount() < 1:
   quit("Usage: htmlrefs filename[.html]")
 
 var links = 0 # count the number of links
@@ -21,17 +21,17 @@ next(x) # get first event
 block mainLoop:
   while true:
     case x.kind
-    of xmlElementOpen: 
+    of xmlElementOpen:
       # the <a href = "xyz"> tag we are interested in always has an attribute,
       # thus we search for ``xmlElementOpen`` and not for ``xmlElementStart``
-      if x.elementName =?= "a": 
+      if x.elementName =?= "a":
         x.next()
-        if x.kind == xmlAttribute: 
+        if x.kind == xmlAttribute:
           if x.attrKey =?= "href":
             var link = x.attrValue
             inc(links)
             # skip until we have an ``xmlElementClose`` event
-            while true: 
+            while true:
               x.next()
               case x.kind
               of xmlEof: break mainLoop
@@ -40,14 +40,14 @@ block mainLoop:
             x.next() # skip ``xmlElementClose``
             # now we have the description for the ``a`` element
             var desc = ""
-            while x.kind == xmlCharData: 
+            while x.kind == xmlCharData:
               desc.add(x.charData)
               x.next()
             echo(desc & ": " & link)
       else:
-        x.next()      
+        x.next()
     of xmlEof: break # end of file reached
-    of xmlError: 
+    of xmlError:
       echo(errorMsg(x))
       x.next()
     else: x.next() # skip other events
diff --git a/examples/htmltitle.nim b/examples/htmltitle.nim
index 7e66fabaa..96bfc7d91 100644
--- a/examples/htmltitle.nim
+++ b/examples/htmltitle.nim
@@ -15,11 +15,11 @@ open(x, s, filename)
 while true:
   x.next()
   case x.kind
-  of xmlElementStart: 
-    if cmpIgnoreCase(x.elementName, "title") == 0: 
+  of xmlElementStart:
+    if cmpIgnoreCase(x.elementName, "title") == 0:
       var title = ""
       x.next()  # skip "<title>"
-      while x.kind == xmlCharData: 
+      while x.kind == xmlCharData:
         title.add(x.charData)
         x.next()
       if x.kind == xmlElementEnd and cmpIgnoreCase(x.elementName, "title") == 0:
@@ -27,7 +27,7 @@ while true:
         quit(0) # Success!
       else:
         echo(x.errorMsgExpected("/title"))
-  
+
   of xmlEof: break # end of file reached
   else: discard # ignore other events
 
diff --git a/examples/httpserver2.nim b/examples/httpserver2.nim
index 13fea9e21..050684d3e 100644
--- a/examples/httpserver2.nim
+++ b/examples/httpserver2.nim
@@ -90,7 +90,7 @@ proc serveFile(client: Socket, filename: string) =
 
 # ------------------ CGI execution -------------------------------------------
 
-proc executeCgi(server: var TServer, client: Socket, path, query: string, 
+proc executeCgi(server: var TServer, client: Socket, path, query: string,
                 meth: TRequestMethod) =
   var env = newStringTable(modeCaseInsensitive)
   var contentLength = -1
@@ -123,12 +123,12 @@ proc executeCgi(server: var TServer, client: Socket, path, query: string,
   send(client, "HTTP/1.0 200 OK" & wwwNL)
 
   var process = startProcess(command=path, env=env)
- 
+
   var job: TJob
   job.process = process
   job.client = client
   server.job.add(job)
- 
+
   if meth == reqPost:
     # get from client and post to CGI program:
     var buf = alloc(contentLength)
diff --git a/examples/iupex1.nim b/examples/iupex1.nim
deleted file mode 100644
index f768fb23f..000000000
--- a/examples/iupex1.nim
+++ /dev/null
@@ -1,37 +0,0 @@
-# Example IUP program
-
-# iupTabs: Creates a iupTabs control.
-
-import iup
-
-discard iup.open(nil, nil)
-
-var vbox1 = iup.vbox(iup.label("Inside Tab A"), iup.button("Button A", ""), nil)
-var vbox2 = iup.vbox(iup.label("Inside Tab B"), iup.button("Button B", ""), nil)
-
-iup.setAttribute(vbox1, "TABTITLE", "Tab A")
-iup.setAttribute(vbox2, "TABTITLE", "Tab B")
-
-var tabs1 = iup.tabs(vbox1, vbox2, nil)
-
-vbox1 = iup.vbox(iup.label("Inside Tab C"), iup.button("Button C", ""), nil)
-vbox2 = iup.vbox(iup.label("Inside Tab D"), iup.button("Button D", ""), nil)
-
-iup.setAttribute(vbox1, "TABTITLE", "Tab C")
-iup.setAttribute(vbox2, "TABTITLE", "Tab D")
-
-var tabs2 = iup.tabs(vbox1, vbox2, nil)
-iup.setAttribute(tabs2, "TABTYPE", "LEFT")
-
-var box = iup.hbox(tabs1, tabs2, nil)
-iup.setAttribute(box, "MARGIN", "10x10")
-iup.setAttribute(box, "GAP", "10")
-
-var dlg = iup.dialog(box)
-iup.setAttribute(dlg, "TITLE", "iupTabs")
-iup.setAttribute(dlg, "SIZE", "200x100")
-
-discard showXY(dlg, IUP_CENTER, IUP_CENTER)
-discard mainLoop()
-close()
-
diff --git a/examples/maximum.nim b/examples/maximum.nim
index ac6160f76..6552a8144 100644
--- a/examples/maximum.nim
+++ b/examples/maximum.nim
@@ -1,6 +1,6 @@
-# Test high level features

-

-import strutils

-

-echo "Give a list of numbers (separated by spaces): "

-stdin.readLine.split.map(parseInt).max.`$`.echo(" is the maximum!")

+# Test high level features
+
+import strutils, sequtils
+
+echo "Give a list of numbers (separated by spaces): "
+stdin.readLine.split.map(parseInt).max.`$`.echo(" is the maximum!")
diff --git a/examples/parsecfgex.nim b/examples/parsecfgex.nim
index 0f37a0378..0fa03ffb5 100644
--- a/examples/parsecfgex.nim
+++ b/examples/parsecfgex.nim
@@ -1,7 +1,7 @@
 
 import
   os, parsecfg, strutils, streams
-  
+
 var f = newFileStream(paramStr(1), fmRead)
 if f != nil:
   var p: CfgParser
@@ -9,7 +9,7 @@ if f != nil:
   while true:
     var e = next(p)
     case e.kind
-    of cfgEof: 
+    of cfgEof:
       echo("EOF!")
       break
     of cfgSectionStart:   ## a ``[section]`` has been parsed
diff --git a/examples/readme.txt b/examples/readme.txt
index 8cfd4f82b..dc3d3fb9b 100644
--- a/examples/readme.txt
+++ b/examples/readme.txt
@@ -1,5 +1,5 @@
-In this directory you will find several examples for how to use the Nimrod 
-library. 
+In this directory you will find several examples for how to use the Nimrod
+library.
 
 Copyright (c) 2004-2012 Andreas Rumpf.
 All rights reserved.
diff --git a/examples/sdlex.nim b/examples/sdlex.nim
index 3dd474d8e..7a4ebf3db 100644
--- a/examples/sdlex.nim
+++ b/examples/sdlex.nim
@@ -1,52 +1,52 @@
-# Test the SDL interface:

-

-import

-  sdl, sdl_image, colors

-

-var

-  screen, greeting: PSurface

-  r: TRect

-  event: TEvent

-  bgColor = colChocolate.int32

-

-if init(INIT_VIDEO) != 0:

-  quit "SDL failed to initialize!"

-

-screen = setVideoMode(640, 480, 16, SWSURFACE or ANYFORMAT)

-if screen.isNil:

-  quit($sdl.getError())

-

-greeting = imgLoad("tux.png")

-if greeting.isNil:

-  echo "Failed to load tux.png"

-else:

-  ## convert the image to alpha and free the old one

-  var s = greeting.displayFormatAlpha()

-  swap(greeting, s)

-  s.freeSurface()

-

-r.x = 0

-r.y = 0

-

-block game_loop:

-  while true:

-    

-    while pollEvent(addr event) > 0:

-      case event.kind

-      of QUITEV:

-        break game_loop

-      of KEYDOWN:

-        if evKeyboard(addr event).keysym.sym == K_ESCAPE:

-          break game_loop

-      else:

-        discard

-    

-    discard fillRect(screen, nil, bgColor) 

-    discard blitSurface(greeting, nil, screen, addr r)

-    discard flip(screen)

-

-greeting.freeSurface()

-screen.freeSurface()

-sdl.quit()

-

-## fowl wuz here 10/2012
\ No newline at end of file
+# Test the SDL interface:
+
+import
+  sdl, sdl_image, colors
+
+var
+  screen, greeting: PSurface
+  r: TRect
+  event: TEvent
+  bgColor = colChocolate.int32
+
+if init(INIT_VIDEO) != 0:
+  quit "SDL failed to initialize!"
+
+screen = setVideoMode(640, 480, 16, SWSURFACE or ANYFORMAT)
+if screen.isNil:
+  quit($sdl.getError())
+
+greeting = imgLoad("tux.png")
+if greeting.isNil:
+  echo "Failed to load tux.png"
+else:
+  ## convert the image to alpha and free the old one
+  var s = greeting.displayFormatAlpha()
+  swap(greeting, s)
+  s.freeSurface()
+
+r.x = 0
+r.y = 0
+
+block game_loop:
+  while true:
+
+    while pollEvent(addr event) > 0:
+      case event.kind
+      of QUITEV:
+        break game_loop
+      of KEYDOWN:
+        if evKeyboard(addr event).keysym.sym == K_ESCAPE:
+          break game_loop
+      else:
+        discard
+
+    discard fillRect(screen, nil, bgColor)
+    discard blitSurface(greeting, nil, screen, addr r)
+    discard flip(screen)
+
+greeting.freeSurface()
+screen.freeSurface()
+sdl.quit()
+
+## fowl wuz here 10/2012
diff --git a/examples/statcsv.nim b/examples/statcsv.nim
index cd1de62af..f2cf809e2 100644
--- a/examples/statcsv.nim
+++ b/examples/statcsv.nim
@@ -28,7 +28,7 @@ while readRow(x):
       for i in 0..x.row.len-1: header[i] = "Col " & $(i+1)
   else:
     # data line:
-    for i in 0..x.row.len-1: 
+    for i in 0..x.row.len-1:
       push(res[i], parseFloat(x.row[i]))
 x.close()
 
diff --git a/examples/talk/tags.nim b/examples/talk/tags.nim
index d47b09e07..12b9a08c3 100644
--- a/examples/talk/tags.nim
+++ b/examples/talk/tags.nim
@@ -1,7 +1,7 @@
 
 template htmlTag(tag: expr) {.immediate.} =
   proc tag(): string = "<" & astToStr(tag) & ">"
-  
+
 htmlTag(br)
 htmlTag(html)
 
diff --git a/examples/tunit.nim b/examples/tunit.nim
index d0e975119..d7b1fcbbd 100644
--- a/examples/tunit.nim
+++ b/examples/tunit.nim
@@ -1,47 +1,47 @@
-import

-  unittest, macros

-

-var

-    a = 1

-    b = 22

-    c = 1

-    d = 3

-

-suite "my suite":

-  setup:

-    echo "suite setup"

-    var testVar = "from setup"

-    

-  teardown:

-    echo "suite teardown"

-

-  test "first suite test":

-    testVar = "modified"

-    echo "test var: " & testVar

-    check a > b

-

-  test "second suite test":

-    echo "test var: " & testVar

-

-proc foo: bool =

-  echo "running foo"

-  return true

-

-proc err =

-  raise newException(EArithmetic, "some exception")

-

-test "final test":

-  echo "inside suite-less test"

-

-  check:

-    a == c

-    foo()

-    d > 10

-

-test "arithmetic failure":

-  expect(EArithmetic):

-    err()

-

-  expect(EArithmetic, ESystem):

-    discard foo()

-

+import
+  unittest, macros
+
+var
+    a = 1
+    b = 22
+    c = 1
+    d = 3
+
+suite "my suite":
+  setup:
+    echo "suite setup"
+    var testVar = "from setup"
+
+  teardown:
+    echo "suite teardown"
+
+  test "first suite test":
+    testVar = "modified"
+    echo "test var: " & testVar
+    check a > b
+
+  test "second suite test":
+    echo "test var: " & testVar
+
+proc foo: bool =
+  echo "running foo"
+  return true
+
+proc err =
+  raise newException(EArithmetic, "some exception")
+
+test "final test":
+  echo "inside suite-less test"
+
+  check:
+    a == c
+    foo()
+    d > 10
+
+test "arithmetic failure":
+  expect(EArithmetic):
+    err()
+
+  expect(EArithmetic, ESystem):
+    discard foo()
+
diff --git a/examples/wingui.nim b/examples/wingui.nim
deleted file mode 100644
index 2c2c387bb..000000000
--- a/examples/wingui.nim
+++ /dev/null
@@ -1,9 +0,0 @@
-# test a Windows GUI application
-
-import
-  windows, shellapi, nb30, mmsystem, shfolder
-
-#proc MessageBox(hWnd: int, lpText, lpCaption: CString, uType: uint): int
-#  {stdcall, import: "MessageBox", header: "<windows.h>"}
-
-discard MessageBox(0, "Hello World!", "Nimrod GUI Application", 0)