812fee19fec6 — Danielle Hutzley tip 2 years ago
Add number testing
1 files changed, 23 insertions(+), 0 deletions(-)

M test/lexer.c
M test/lexer.c +23 -0
@@ 88,6 88,29 @@ TEST ("Simple Lexing")
 }
 END_TEST;
 
+TEST ("Number Lexing")
+{
+  const char *SIMPLE_PROGRAMME = "pi := int 3.14;";
+  const laal_token_t EXPECTED_TOKENS[] = {
+    { .text = "pi",
+      .position = { .row = 1, .col = 0 },
+      .type = TOKEN_IDENTIFIER },
+    { .text = ":=", .position = { .row = 1, .col = 3 }, .type = TOKEN_BIND },
+    { .text = "int",
+      .position = { .row = 1, .col = 6 },
+      .type = TOKEN_IDENTIFIER },
+    { .text = "3.14",
+      .position = { .row = 1, .col = 10 },
+      .type = TOKEN_NUMBER },
+    { .text = ";",
+      .position = { .row = 1, .col = 14 },
+      .type = TOKEN_SEMICOLON },
+  };
+
+  test_lex (SIMPLE_PROGRAMME, EXPECTED_TOKENS, 5);
+}
+END_TEST;
+
 TEST ("Collection Lexing")
 {
   const char *PROGRAMME = "x := list[{y := 'z'}, \"foo\"];";