changeset 826:d659f7aa055c

Fixed Lexer unittest.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 07 Jun 2008 14:05:28 +0200
parents 51edcd435b30
children 84f562d75053
files src/dil/lexer/Lexer.d src/main.d
diffstat 2 files changed, 11 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/dil/lexer/Lexer.d	Thu Mar 27 16:56:55 2008 +0200
+++ b/src/dil/lexer/Lexer.d	Sat Jun 07 14:05:28 2008 +0200
@@ -2851,20 +2851,17 @@
     else
       src ~= pair.tokenText ~ " ";
 
+  // Lex the constructed source text.
   auto lx = new Lexer(new SourceText("", src));
-  auto token = lx.getTokens();
+  lx.scanAll();
+
+  auto token = lx.firstToken();
 
-  uint i;
-  assert(token == lx.head);
-  assert(token.next.kind == TOK.Newline);
-  token = token.next.next;
-  do
-  {
-    assert(i < pairs.length);
-    assert(token.srcText == pairs[i].tokenText, Format("Scanned '{0}' but expected '{1}'", token.srcText, pairs[i].tokenText));
-    ++i;
-    token = token.next;
-  } while (token.kind != TOK.EOF)
+  for (uint i; i < pairs.length && token.kind != TOK.EOF;
+       ++i, (token = token.next))
+    if (token.srcText != pairs[i].tokenText)
+      assert(0, Format("Scanned '{0}' but expected '{1}'",
+                       token.srcText, pairs[i].tokenText));
 }
 
 /// Tests the Lexer's peek() method.
--- a/src/main.d	Thu Mar 27 16:56:55 2008 +0200
+++ b/src/main.d	Sat Jun 07 14:05:28 2008 +0200
@@ -345,7 +345,7 @@
   cc.addVersionId("D_Version2");
   foreach (versionId; GlobalSettings.versionIds)
     if (Lexer.isValidUnreservedIdentifier(versionId))
-      cc.versionIds[versionId] = true;
+      cc.addVersionId(versionId);
   return cc;
 }
 
@@ -398,7 +398,7 @@
   }
 }
 
-/// Prints a help message for command.
+/// Prints the help message of a command.
 void printHelp(char[] command)
 {
   char[] msg;