parser_func_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Public Domain Software
  3. *
  4. * I (Matthias Ladkau) am the author of the source code in this file.
  5. * I have placed the source code in this file in the public domain.
  6. *
  7. * For further information see: http://creativecommons.org/publicdomain/zero/1.0/
  8. */
  9. package parser
  10. import (
  11. "fmt"
  12. "testing"
  13. )
  14. func TestImportParsing(t *testing.T) {
  15. input := `import "foo/bar.ecal" as foobar
  16. i := foobar`
  17. expectedOutput := `
  18. statements
  19. import
  20. string: 'foo/bar.ecal'
  21. identifier: foobar
  22. :=
  23. identifier: i
  24. identifier: foobar
  25. `[1:]
  26. if res, err := UnitTestParse("mytest", input); err != nil || fmt.Sprint(res) != expectedOutput {
  27. t.Error("Unexpected parser output:\n", res, "expected was:\n", expectedOutput, "Error:", err)
  28. return
  29. }
  30. }
  31. /*
  32. TODO:
  33. func TestFunctionCalling(t *testing.T) {
  34. input := `import "foo/bar.ecal" as foobar
  35. foobar.test()`
  36. expectedOutput := `
  37. statements
  38. import
  39. string: 'foo/bar.ecal'
  40. identifier: foobar
  41. :=
  42. identifier: i
  43. identifier: foobar
  44. `[1:]
  45. if res, err := UnitTestParse("mytest", input); err != nil || fmt.Sprint(res) != expectedOutput {
  46. t.Error("Unexpected parser output:\n", res, "expected was:\n", expectedOutput, "Error:", err)
  47. return
  48. }
  49. }
  50. */