textual_test.go 910 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package textual
  2. import (
  3. "testing"
  4. "os"
  5. "path/filepath"
  6. "kumachan/lang/textual/syntax"
  7. )
  8. // NOTE: output only (result NOT checked)
  9. func TestOutputSampleParsingResult(t *testing.T) {
  10. // parseSampleFileDefault(t, "1")
  11. // parseSampleFileDefault(t, "2")
  12. // parseSampleFileDefault(t, "3")
  13. parseSampleFileDefault(t, "4")
  14. parseSampleFileDefault(t, "5")
  15. }
  16. func parseSampleFile(t *testing.T, name string, root syntax.Id) {
  17. var exe_path, err = os.Executable()
  18. if err != nil { panic(err) }
  19. var project_path = filepath.Dir(filepath.Dir(exe_path))
  20. var sample_path = filepath.Join(
  21. project_path,
  22. "lang", "textual", "test", (name + ".txt"),
  23. )
  24. { var f, err = os.Open(sample_path)
  25. if err != nil { panic(err) }
  26. var success = DebugParser(f, sample_path, root)
  27. if !(success) {
  28. t.Fail()
  29. } }
  30. }
  31. func parseSampleFileDefault(t *testing.T, name string) {
  32. parseSampleFile(t, name, syntax.DefaultRoot())
  33. }