tokenizer_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package raku
  2. import (
  3. // "strings"
  4. "testing"
  5. "os"
  6. "gitlab.com/beoran/woe/monolog"
  7. // "gitlab.com/beoran/woe/tree"
  8. )
  9. func HelperTryTokenizing(input string, test *testing.T) {
  10. test.Logf("Tokenizing started:")
  11. output := Tokenize(input)
  12. for _, token := range output {
  13. test.Logf("Token %s", token.String())
  14. }
  15. }
  16. func TestTokenizing1(test *testing.T) {
  17. const input = `
  18. say "hello \"world\""
  19. define open a door do
  20. set (door's open) true
  21. let door 's open be true
  22. end
  23. def increment variable by value do \
  24. ( variable = ( variable + value ) )
  25. end
  26. : foo bar, baz, quuux {
  27. print foo, bar, bqz, quux
  28. }
  29. `
  30. HelperTryTokenizing(input, test)
  31. test.Log("Hi test!")
  32. }
  33. func TestTokenizing2(test *testing.T) {
  34. const input = `say`
  35. HelperTryTokenizing(input, test)
  36. test.Log("Hi test!")
  37. }
  38. func TestTokenizing3(test *testing.T) {
  39. const input = `$sym`
  40. HelperTryTokenizing(input, test)
  41. test.Log("Hi test!")
  42. }
  43. func TestMain(m *testing.M) {
  44. monolog.Setup("raku_test.log", true, false)
  45. // monolog.EnableLevel("DEBUG")
  46. retCode := m.Run()
  47. monolog.Close()
  48. os.Exit(retCode)
  49. }