summary refs log tree commit diff stats
path: root/lib/packages
diff options
context:
space:
mode:
authorGrzegorz Adam Hankiewicz <gradha@imap.cc>2013-06-18 21:42:53 +0200
committerGrzegorz Adam Hankiewicz <gradha@imap.cc>2013-06-18 21:42:53 +0200
commit4c7607e074de9272f3e7f3b5e0d40c6ee5c8259c (patch)
tree4912420bbf0e1c5c518fef6ec1b47e9d61fe3cbc /lib/packages
parent5b1caed806e017b39c9dd447fde00085fe5aab09 (diff)
downloadNim-4c7607e074de9272f3e7f3b5e0d40c6ee5c8259c.tar.gz
Adds previous slurping as runnable testcase.
Diffstat (limited to 'lib/packages')
-rw-r--r--lib/packages/docutils/highlite.nim15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/packages/docutils/highlite.nim b/lib/packages/docutils/highlite.nim
index f4b2f5867..b1b6c41e2 100644
--- a/lib/packages/docutils/highlite.nim
+++ b/lib/packages/docutils/highlite.nim
@@ -45,7 +45,7 @@ const
     "Label", "Reference", "Other"]
 
   # The following list comes from doc/keywords.txt, make sure it is
-  # synchronized with this array.
+  # synchronized with this array by running the module itself as a test case.
   nimrodKeywords = ["addr", "and", "as", "asm", "atomic", "bind", "block",
     "break", "case", "cast", "const", "continue", "converter", "discard",
     "distinct", "div", "do", "elif", "else", "end", "enum", "except", "export",
@@ -545,3 +545,16 @@ proc getNextToken*(g: var TGeneralTokenizer, lang: TSourceLanguage) =
   of langC: cNextToken(g)
   of langJava: javaNextToken(g)
   
+when isMainModule:
+  var keywords: seq[string]
+  # Try to work running in both the subdir or at the root.
+  for filename in ["doc/keywords.txt", "../../../doc/keywords.txt"]:
+    except: echo filename, " not found"
+    let input = string(readFile(filename))
+    keywords = input.split()
+    break
+  doAssert (not keywords.isNil, "Couldn't read any keywords.txt file!")
+  doAssert keywords.len == nimrodKeywords.len, "No matching lengths"
+  for i in 0..keywords.len-1:
+    echo keywords[i], " == ", nimrodKeywords[i]
+    doAssert keywords[i] == nimrodKeywords[i], "Unexpected keyword"