/snippets/aop/src/utests/lexing.n

http://github.com/saidai-no/nemerle · Unknown · 41 lines · 30 code · 11 blank · 0 comment · 0 complexity · 854fd6b7fb5df5afbd5a2a6d8fc86a5f MD5 · raw file

  1. #pragma indent
  2. using NUnit.Framework
  3. using Nemerle.Aop.Helper
  4. using Nemerle.Compiler
  5. [TestFixture] public class LexingTest
  6. [Test] public or_operator(): void
  7. def lexer = Lexer(Helper.ConvertToTokenLooseGroup(["||"]))
  8. match(lexer.Peek())
  9. | Token.Operator("||") => ()
  10. | _ => Assert.Fail("Peek operation fails")
  11. match(lexer.Pop())
  12. | Token.Operator("||") => ()
  13. | _ => Assert.Fail("Pop operation fails")
  14. match(lexer.Peek())
  15. | Token.Operator("||") => Assert.Fail("last token was not poped")
  16. | _ => ()
  17. [Test] public and_operator(): void
  18. def lexer = Lexer(Helper.ConvertToTokenLooseGroup(["&&"]))
  19. match(lexer.Peek())
  20. | Token.Operator("&&") => ()
  21. | sth => Assert.Fail($"Peek operation fails: $sth")
  22. [Test] public ellipsis_operator_is_not_splitted(): void
  23. def lexer = Lexer(Helper.ConvertToTokenLooseGroup([".."]))
  24. match(lexer.Peek())
  25. | Token.Operator("..") => ()
  26. | sth => Assert.Fail($"Peek operation fails: $sth")
  27. [Test] public drop_id(): void
  28. def lexer = Lexer(Helper.ConvertToTokenLooseGroup(["identyfikator"]))
  29. lexer.DropId("identyfikator");
  30. Assert.IsTrue(lexer.Empty)